Jump to content
  • Advertisement
Sign in to follow this  

help about glsl to cg script

This topic is 3892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

now i want to rewrite the glsl script to cg script,but it fail to work, the glsl script: uniform vec4 translation; uniform vec4 camera; uniform float timer; void main(void) { vec4 regularPosition = gl_Vertex; regularPosition.y += cos(timer*0.75); vec4 correctPosition = regularPosition + translation; gl_TexCoord[0] = gl_TextureMatrix[1] * correctPosition; gl_TexCoord[1] = gl_MultiTexCoord0*2.0; gl_TexCoord[2] = camera - correctPosition; gl_TexCoord[3] = correctPosition; gl_Position = gl_ModelViewProjectionMatrix*regularPosition; } here is the cg script i wrote: struct ApplicationVertex { float4 position: POSITION; float4 texCoord0: TEXCOORD0; }; struct VertexFragment { float4 color0: COLOR0; float4 texCoord0: TEXCOORD0; float4 position: POSITION; }; uniform float4x4 modelViewProjMatrix : state.matrix.mvp; uniform float4x4 textureMatrix : state.matrix.texture; void main(ApplicationVertex av, uniform float4 translation, uniform float4 camera, uniform float timer, out float4 color0: COLOR0, out float4 texCoord0: TEXCOORD0, out float4 texCoord1: TEXCOORD1, out float4 texCoord2: TEXCOORD2, out float4 texCoord3: TEXCOORD3, out float4 position: POSITION) { float4 regularPosition = av.position; regularPosition.y += cos(timer*0.75); float4 correctPosition = regularPosition + translation; texCoord0 = mul(textureMatrix,correctPosition); texCoord1 = av.texCoord0*2.0; texCoord2 = camera - correctPosition; texCoord3 = correctPosition; position = mul(modelViewProjMatrix, regularPosition); } i seems that i have't find correct matrix in cg accroding gl_TextureMatrix[1] in glsl , is uniform float4x4 textureMatrix : state.matrix.texture in cg right?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!