need help in multitexturing using opengl shading language (solved)
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.
[Edited by - fazekaim on January 2, 2005 7:53:14 AM]
sounds like its dumpped out to software, check the compiler logs to see if it says anything.
btw, in your vertex shader you are better off doing gl_Position = ftransform();
btw, in your vertex shader you are better off doing gl_Position = ftransform();
When the compiler fails, I write the compiler error message.
The shaders are compiled successfull.
Is there any other compiler output?
The shaders are compiled successfull.
Is there any other compiler output?
they can compile fine, but might not be in hardware for some reason, thus you should check the logs to make sure
should work what card do u have?
instead of passing it as 4 attribute floats try a single vec4 eg gl_MultiTexCoord5 or color
instead of passing it as 4 attribute floats try a single vec4 eg gl_MultiTexCoord5 or color
You have write. I received this warning:
The GLSL vertex shader will run in software - number of hardware supported vertex attributes exceeded.
I have Radeon 9600XT with 256MByte ram.
How many attributes can I have with this card?
thanks.
The GLSL vertex shader will run in software - number of hardware supported vertex attributes exceeded.
I have Radeon 9600XT with 256MByte ram.
How many attributes can I have with this card?
thanks.
www.google.com knows, but anyways, you know, you could just as easily specify for texture stage 4, a 4 component tex coord, and just inside your vertex shader, treat it like its your texturesinN floats,
now for my own question, what does an attribute do in glsl? i had always thought of attributes as a generic way of looking at normal, position, color ect. but seeing normal vertex properties (position, tex coord, ect) AND attributes, has me a bit confused, anyone care to explain?
thanks
-Dan
now for my own question, what does an attribute do in glsl? i had always thought of attributes as a generic way of looking at normal, position, color ect. but seeing normal vertex properties (position, tex coord, ect) AND attributes, has me a bit confused, anyone care to explain?
thanks
-Dan
Ademan555 :
an attribute is just a generic way of setting per vertex infomation, they can either be your own or standard GL per vertex values (such as normals).
fazekaim :
You can find the max attributes by using glGet with the token GL_MAX_VERTEX_ATTRIBS_ARB, however you are garented 16 apprently.
However, each one is a vec4, so by using 4 floats you've used 4 vec4s up
an attribute is just a generic way of setting per vertex infomation, they can either be your own or standard GL per vertex values (such as normals).
fazekaim :
You can find the max attributes by using glGet with the token GL_MAX_VERTEX_ATTRIBS_ARB, however you are garented 16 apprently.
However, each one is a vec4, so by using 4 floats you've used 4 vec4s up
hrm, thats what i thought, so how would you set the attributes then for his shader? because wouldnt attribute0 be position? and such? so youd have to know which attribute his floats were being assigned to.
oh and by the way OP, this is a long shot, but you could try making it just one vec4 also... if openGL tags on the attributes to whatever open attrib is available, it may do it one by one and thus waste 3 attribs by using each float as an attribute rather than packing them (though i think youd still be under the limit)
hope that helps
-Dan
oh and by the way OP, this is a long shot, but you could try making it just one vec4 also... if openGL tags on the attributes to whatever open attrib is available, it may do it one by one and thus waste 3 attribs by using each float as an attribute rather than packing them (though i think youd still be under the limit)
hope that helps
-Dan
I'm confused too. I received this value:
GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:4096
GL_MAX_VARYING_FLOATS_ARB:44
GL_MAX_VERTEX_ATTRIBS_ARB:32
I excedeed the 32 attributes? How?
How can I add values from a VBO to an uniform variable?
I know how to implement using attribute, but using uniform variable? It is possible?
GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:4096
GL_MAX_VARYING_FLOATS_ARB:44
GL_MAX_VERTEX_ATTRIBS_ARB:32
I excedeed the 32 attributes? How?
How can I add values from a VBO to an uniform variable?
I know how to implement using attribute, but using uniform variable? It is possible?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement