@phr00t said: @johncl -- yeah, I need to update the fog color dynamically for all my materials when the day/night shift happens. It was a minor pain... but once the code was there to do it, I forgot about it :D
Once you give a Material a color instance then you can change that color without resetting it to the Material. So just make sure to give all of your materials the same fog Color instance and then you only have to worry about changing that one color instance.
@mifth said: @pspeed , may I use your code for my LightBlow shader? I already have a task for it: http://code.google.com/p/jme-glsl-shaders/issues/detail?id=3
@pspeed said:
Once you give a Material a color instance then you can change that color without resetting it to the Material. So just make sure to give all of your materials the same fog Color instance and then you only have to worry about changing that one color instance.
Ah cool. I always thought things like Color objects were immutable stuff. That would simplify it immensely… Well if I can get it working with the post process water.
Here is a fix to how to compute the fog via a frag shader… The way it is currently, brightness is not taken into effect at all. sooo… vec3(0.4, 0.1, 0.1) would look the same as vec3(1.0, 0.0, 0.0). To make sure the fog is rendered at the actual color you have defined, replace the last gl_FragColor = mix, blah) with:
@t0neg0d said:
Here is a fix to how to compute the fog via a frag shader... The way it is currently, brightness is not taken into effect at all. sooo... vec3(0.4, 0.1, 0.1) would look the same as vec3(1.0, 0.0, 0.0). To make sure the fog is rendered at the actual color you have defined, replace the last gl_FragColor = mix, blah) with:
I'm not entirely sure I understand the "vec3(0.4, 0.1, 0.1) would look the same as vec3(1.0, 0.0, 0.0)."... is that the color of the fog or the color of the pixel?
Fog as previously implemented (or at least as implemented in my shaders) is a straight distance-based attenuation. As a point gets farther away, you see less of the point and more of the vapor between you and the point... and I think in that case that coloring the vapor (as you've done) is incorrect.
Can you give a more specific example where things are not what they are supposed to be?
@pspeed I caught that right after posting this. I’m trying to find the solution atm. Correct color… or completely opaque. I’d like both! Hopefully it won’t be long now. Or… maybe you have the magic solution already? O.o That would be awesome.
@pspeed When I tried to use it, blue is blue wether or not you set it to vec4(0, 0, 1, 1) or vec4(0, 0, 0.2, 1)… the mix function in the code at the beginning of this post doesn’t render different brightness of the same color (because of the lack of the alpha channel). Anyways… this one works (As far as I can tell. For some reason, you need to scale to color values of the fog to have it render correctly… so if you have a minute or three to play around with this… do tell me if you see the difference.