Materials using shaders and multiple UV coordinates?

Evak

16-07-2007 04:12:02

I have a shader that blends two sets of textures using vertex colors. I have the covering texture and the texture and the texture underneath blended using the vertex color.

untill now I only used 1 UV and all was fine, I decided to put the two different surfaces on different UV channels using the regular texture units in the .material file, but the 2nd UV channel seems to be ignored. Now I'm uncertain whether I am supposed to set the UV channel being used in the ogre .material texture unit, or in the shader itself.

So, Do I set the UV channel in my 2nd material file or my shader source code?

Here's the result of a quick test where I use 2 UV's set in ofusions texture units.



LEFT Side, material with one UV channel shared by both sets of terrain textures.

RIGHT Side: material with 2 UV channels, the sandy texture uses a second UV tiled 10x more than the striped texture. As you can see, the UV coordinates are not changed, but some weird effect happens with the lighting, so the material is much darker with an off bright highlight.

Anyone know why the 2 UV's don't work, and whats wrong?

Lioric

16-07-2007 17:05:56

If you need a different set of texcoords (uv's) for the second channel, add them in max, and modify the shader to use the second uv's to sampling the proper texture, the shader needs to be modified to work correctly with the proper uv channels, in your previous example files, you were using the texcoord1 for the tangent and in the fragment shader you were using the texcoord0 and texcoord1 channels for the eye and light vectors and texcoord2 for the uvs

When a new set of uv's are in the object, in this case, in the vertex shader the texcoord0 and texcoord1 will be for the uvs and the texcoord2 will be for the tangents

Or if you need a different scale for the second channel (but the same uv set) use a scale value in your shader (add a parameter in the fragment shader)


...
texcoordChannelN = input.texcoord * scaleN;
...

Evak

16-07-2007 18:57:48

heh, man. I thought I had figured out how to convert these shaderFX shaders, but each time I need to make changes I find a new level of complexity :(. Thanks for the tips though, they should be usefull for the coder thats helping me with these shaders, and maybe I can figure it out myself in time.