Sign in to follow this  

help about gl_texturematrix in glsl

This topic is 3557 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[1];

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[1] in cg right?

Share this post


Link to post
Share on other sites
Quote:
i seems that i have't find correct matrix in cg accroding gl_TextureMatrix[1] in glsl ,

is uniform float4x4 textureMatrix : state.matrix.texture[1] in cg right?


Yes, they are the same.
If you need to debug then you need to output the matrix to gl_FragColor in your fragment shader.
You could also replace it with your own uniform.

uniform mat4 MyTextureMatrix1;

Share this post


Link to post
Share on other sites

This topic is 3557 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this