• Advertisement
Sign in to follow this  

Pass MultiTexCoord via Vertex Shader

This topic is 2677 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

Hi,

I'm trying to do something pretty simple but it does not work for some reason.
I have a cgfx file with a very basic set of vertex/pixel shader:



struct IN
{
float4 position : POSITION;
float3 minCurv1 : TEXCOORD0;
};

void vert(IN input,
out float4 oPosition: POSITION,
out float4 oMinCurv1 : TEXCOORD0)
{
oPosition = mul(mvp, input.position);

oMinCurv1 = float4(input.minCurv1.xyz, 1.0f); // nor working
oMinCurv1 = float4(0.0f, 1.0f, 0.0f, 1.0f); // working
}

void fFull(float4 minCurv1 : TEXCOORD0,
out float4 c0 : COLOR0)
{
   c0.xyz = minCurv1.xyz;
c0.w = 1.0f;
}




All I want is to pass data (mesh curvature data in my case to the pixel shader via the vertex shader and its TEXCOORD0, TEXCOORD1... semantics). Assigning a constant green color in the vertex shader works (my mesh gets all green), but assigning the data I'm suppose to get in input.minCurv1 does not work (data seem to be random).

From the application side, I pass the parameters this way:
glMultiTexCoord3fv(GL_TEXTURE0, &(v[0]->gammaMin->x));

Am I doing something wrong?
Thanks!

Share this post


Link to post
Share on other sites
Advertisement
What does your client side code look like when you do your drawing?

Also I'd consider just using generic attributes instead of the deprecated MultiTexCoord system. It leaves less extension-specific stuff to remember.

Share this post


Link to post
Share on other sites
Thanks for your answer.

I actually found the problem while copying the code into this post. My coordinates TEXCOORD0 got overwritten later in the drawing function, can't believe I did not see this one earlier :'(

What would be the correct way to do it using generic attributes?

Thanks again!

Share this post


Link to post
Share on other sites
I'm not really used to cg (glsl man myself), but essentially you'd declare a named attribute in the vertex shader, call glGetAttribLocation to get the attrib offset, then use glVertexAttribPointer to load your texcoords into the shader.

You can find a tutorial for how to do this with CG I'm sure, all of the special inputs (vertex, normal, texcoord etc) are deprecated now in favor of generic attributes.

Share this post


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

  • Advertisement