Light diffuse colors in fragment shader

Started by zbych, October 31, 2012, 04:58:59 PM

Previous topic - Next topic

zbych

I wanted to add to my shader diffuse colors for lights. Everything was fine on Samsung Galaxy S2, but on lower devices like LG-GT540 or Samsung Galaxy Mini it looks like I got zeros in diffuseColors array ??? What might be cause of this behavior? I can pass color for light in my own uniforms but I wanted to use existing ones.

EgonOlsen

I don't see a reason for this. Injecting the values should be indepent of the device. But...both devices use the Adreno 200 GPU which is, in my opinion, a piece of junk when it comes to shader support. The shader compiler is a mess and simply creates garbage code out of otherwise fine working shaders. Maybe that's the case here...try to fiddle around with your shader, especially make sure that you always use x.0 instead of x when is comes to float values. Try to use some constant instead to see if that works etc... Never use loops in the fragment shader on Andreno.

zbych

#2
Thanks for advices. I will try to change... something ;) I had similar behavior when I have added "full" attenuation calculations - on Galaxy S2 it was ok but on the other two devices it has no effect, it looks like a distance from light to vertex was always 0. I think the value was so small so it was truncated to 0 or it was overflow and it was treated as 0 also - so for now I have to remove linear and quadratic attenuation, and left only spot exponent with constant attenuation - I know it make no sense.
Anyway I will try to experiment, but I was trying to set light intensity in range from 0.0 to 1.0 and pass value from Light.getIntensity() as another uniform and it worked.