Jump to content
  • Advertisement
Sign in to follow this  
fazekaim

OpenGL need help in multitexturing using opengl shading language (solved)

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

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]

Share this post


Link to post
Share on other sites
Advertisement
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();

Share this post


Link to post
Share on other sites
When the compiler fails, I write the compiler error message.
The shaders are compiled successfull.
Is there any other compiler output?

Share this post


Link to post
Share on other sites
should work what card do u have?

instead of passing it as 4 attribute floats try a single vec4 eg gl_MultiTexCoord5 or color

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

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!