Jump to content

2nd UV coord set not working?


SpiderPig
 Share

Go to solution Solved by SpiderPig,

Recommended Posts

Hey Josh, using the first coord set I can send any value over to the shader and it works.  But it won't work for the 2nd set.

This is how I'm setting the data.

for (auto v = 0; v < mesh->CountVertices(); v++) {
	mesh->SetVertexTexCoords(v, 2.0f, 0.0f, 1);
}

In my custom frag shader I'm doing something like this.

if(tex_coords.z == 2.0f){
	color = vec4(0,1,0,1);
}
else{
	color = vec4(1,0,0,1);
}

In my tests 'z' is never equal to 2.  I have tried 'w' as well.

I've looked over the vertex shaders and the coords are not being modified anywhere in the shaders to cause the 2nd coord set not to work.

 

I tested the x and y components and they do work.

This works.

for (auto v = 0; v < mesh->CountVertices(); v++) {
	mesh->SetVertexTexCoords(v, 2.0f, 0.0f, 0);//<- first uv set
}

Shader that works.

if(tex_coords.x == 2.0f){//<- testing x instead of z
	color = vec4(0,1,0,1);
}
else{
	color = vec4(1,0,0,1);
}

 

Not sure how to put together a simple example for this one, but if there's a way you can take a look to see if the the 2nd coord set data is actually being transferred to the GPU maybe?

Link to comment
Share on other sites

Can you check a > test instead of an exact equals? Something like this:

for (auto v = 0; v < mesh->CountVertices(); v++) {
	mesh->SetVertexTexCoords(v, 2.0f, 0.0f, 1);
}

 

if(tex_coords.z > 1.0f){
	color = vec4(0,1,0,1);
}
else{
	color = vec4(1,0,0,1);
}

 

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

if ( in_TexCoords.z > 0.5f ) {
	color[0] = vec4( 0.0f, 1.0f, 0.0f, 1.0f );
	
}
else {
	color[0] = vec4( 1.0f, 0.0f, 0.0f, 1.0f );
	
}

It seems that from left to right the 'z' value is going from 0 to 1.  I'm going to check other areas in my code.  It is possible I'm accidently overwriting this value somewhere...

TexCoord_Bug.thumb.png.8d045aa413ea48716e79c6acb9981b46.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...