Jump to content
  • Advertisement
Sign in to follow this  
Ray1234

Shader TexCoord problem

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

I'm working on some vertex/pixel shaders for my engine for my terrain. I have 4 pairs of shaders set up for differing numbers of textures involved (single texure all the way up to 4 textures and a blend map). My problem is with the texture coordinates. I can take a chunk of my terrain and set it to tile the texture 2x2 for each layer, and if I use the single texture shader it works perfectly. Any time I use more than a single texture layer (blend map + more than 1 texture) it reverts back to 1x1 tiling, including the first layer that was working previously. In my shader, I'm doing the following in the single texture version: ... dcl_texcoord v2 // alpha map dcl_texcoord1 v3 // texture 1 ... mov oT0.xy, v2 mov oT1.xy, v3 And, in the 2 layer shader (for example), I'm simply adding the next coordinate: ... dcl_texcoord v2 // alpha map dcl_texcoord1 v3 // texture 1 dcl_texcoord2 v4 // texture 2 ... mov oT0.xy, v2 mov oT1.xy, v3 mov oT2.xy, v4 In the pixel shader for the single, it's simply: texld r0, t0 texld r1, t1 mul r0, r1, v0 For the 2 layer one: texld r0, t0 texld r1, t1 texld r2, t2 lrp r1, r0.y, r2, r1 // r0.y is from the blend map mul r0, r1, v0 For whatever reason the second one loses the tiling information. It doesn't just stretch it past the halfway mark (as if it were clamped) it actually reverts to a 1x1 tiling. Anyone run into this before or have some suggestions for me? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure if I understood your problem, forgive me if not.
I have had an issue with multitexturing and glsl: the first texture always worked in the expected way, while the second never even worked. I solved this by using:

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture);
glEnable(GL_TEXTURE_2D);


followed by

glUniform1iARB(glGetUniformLocationARB(shader, "tex[0]"), 0);


The last instruction sets the variable tex[0] in the shader to the first texture unit, while the first code posted sets the first texture unit to the 'texture' texture.
Perhaps you need to set the units and the texture used.
Hope this helps.

Share this post


Link to post
Share on other sites
Well, I'm using DirectX at the moment, so I'm not sure what, if any, of that applies to me. Here's an illistration of the problem I'm encountering.

shader_problem.png (171kb)

The only difference with the second one is that it's reading the third texture stage. All the texture coordinates, in fact the entire vertex buffer, are identical with both of them.

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!