[solved] Texturescale and shaders

i'm using the Reflection Renderpass and shader from this thread:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=7405.0



I want the 1st Texture (the floor) to be scaled and the current shader does not take the scale factor (set by Texure.setScale(50,50,50)) into account.

How can this be fixed?  :slight_smile:



vertex shader:


varying vec4 viewCoords;
uniform sampler2D reflection;
uniform sampler2D tex;
void main()
{
   vec4 projCoord = viewCoords / viewCoords.q;
   projCoord = (projCoord + 1.0) * 0.5;
   projCoord.x = 1.0 - projCoord.x;
   vec4 reflectionColor = 0.5 * (texture2D(reflection, projCoord.xy) + texture2D(tex,gl_TexCoord[0].st));
   gl_FragColor = reflectionColor;
}



fragment:


varying vec4 viewCoords;

void main()
{
   gl_TexCoord[0]  = gl_MultiTexCoord0;
    //This calculates our current projection coordinates
   viewCoords = ftransform();
   gl_Position = viewCoords;
}

Vertex Shader:

varying vec4 viewCoords;

void main()
{
   gl_TexCoord[0]  = gl_MultiTexCoord0 * gl_TextureMatrix[0];
    //This calculates our current projection coordinates
   viewCoords = ftransform();
   gl_Position = viewCoords;
}



You can also multiply gl_MultiTexCoord0 by 50.0 instead of gl_TextureMatrix[0] and get the same thing you wanted.

heh ok now its scaled but the texture is not wrapped, the texture only appears once in the lower left corner  :slight_smile:



note to self: order a glsl book to look up such things …

wait i'm an idiot, the texture wasn't set to Wrap at all  :slight_smile:



it works now, thanks Momoko_Fan :slight_smile: