help about glsl to cg script
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?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement