Hello!
I created this shaders:
vertex shader:
attribute float texturesin1;
attribute float texturesin2;
attribute float texturesin3;
attribute float texturesin4;
varying float texturesout1;
varying float texturesout2;
varying float texturesout3;
varying float texturesout4;
void main(void)
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_TexCoord[2] = gl_MultiTexCoord2;
gl_TexCoord[3] = gl_MultiTexCoord3;
texturesout1 = texturesin1;
texturesout2 = texturesin2;
texturesout3 = texturesin3;
texturesout4 = texturesin4;
}
fragment shader:
uniform sampler2D deeptexture;
uniform sampler2D lowtexture;
uniform sampler2D hightexture;
uniform sampler2D toptexture;
varying float texturesout1;
varying float texturesout2;
varying float texturesout3;
varying float texturesout4;
void main (void)
{
vec4 deep = texture2D(deeptexture, gl_TexCoord[0].st );
vec4 low = texture2D(lowtexture, gl_TexCoord[1].st );
vec4 high = texture2D(hightexture, gl_TexCoord[2].st );
vec4 top = texture2D(toptexture, gl_TexCoord[3].st );
vec4 newcolor =
texturesout1 * deep +
texturesout2 * low +
texturesout3 * high +
texturesout4 * top;
gl_FragColor = newcolor;
}
This shader helps me to draw a terrain with 4 textures depending on high. I compute the texture combination values, and I pass it to the vertex shader. THe values are stored in a vertex buffer object.
My problem is, that if I pass the textureout values through the vertex shader, and I want to use it in the framgent shader, it is extremely slow (0.1fps). When I use a constant value in the framgent shader, it is running with 400fps.
How can I fix this problem?
thanks.