Jump to content
  • Advertisement
Sign in to follow this  
rapunzel

uniform arrays in GLSL

This topic is 4609 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 am writing a shader, that shall perform lighting calculations for multiple light sources (4). It is based on real light distributions. To achieve this, I wanted to pass all the needd information to the shader into uniform arrays, e.g.: uniform float maxIntens[4]; uniform float minIntens[4]; the infomration of the light distibution is stored in different textures on differnt texture units (of course), so I also defined this: uniform sampler2D texture[4]; Now I just use a loop to calculate through all three light sources. THe problem is 1st: THe InfoLog output of the shader says, that the uniform variable texture doesn't exist, though I am definetily using it. And more weired it sometimes renders the image correct, which means that it found the texture in the unit. Another problem: I use another array to tell which light source of the 4 is actually used, so that I can switch on and of some lights: uniform bool inUse[4]; The calculation in the loop is only performed if inUse[actualLoopIndex] == 1, otherwise not. And sometimes it renders, sometimes the complete program becomes terribly slow, even with only one light source activated. I am afraid that there is a problem in using arrays as uniforms, is that possible. Well I am using an ATI card by the way. thx for any suggestions. PS: I have a single light source version (without using any arrays) of this shader running and it works perfectly and fast ...

Share this post


Link to post
Share on other sites
Advertisement
post the code so we can see whats going on.

However, I suspect you are being done in, speed wise, by the conditionals in the fragment shader. Unless you are running ATI's newest hardware you wont have true conditionals in the fragment shader, it will just run all the code and select the correct output.

anyways, post code, it might well help..

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!