I’m interested in implementing distance falloff to the lighting in my game. Are there any resources available tailored to jMonkey that document its usage? Thanks in advance.
…or can you be more specific?
Part of the problem is that I don’t know the correct term for what it is.
There’s a picture of what distance falloff would be on that page.
I’d hate to bump my own thread, but I still can’t find any information on what this lighting thing.
I want something passive like a fog or something to cover far away things so that I can differentiate close things to far things. I was looking more towards having the object look darker (like it was far away) but couldn’t find that either!
Anyway, hopefully you guys know what it’s called or something, as I am not finding diddly squat on it.
There are quite a few things available… and if they don’t do exactly what you’re looking for, you can always modify them!
Are two that come to mind.
FXAA can always help with blending /shrug
I use fog for that. I’ve customized my lighting shader to include it in the shader, though… and then I just set the fog color to black.
A fog calculation looks something like: (I encode the fog distance cut off in the alpha of the fog color)
float fogDensity = 1.2;
float fogDistance = fogColor.a;
fogColor.a = 1.0;
float depth = z / fogDistance; float fogFactor = exp2( -fogDensity * fogDensity * depth * depth * LOG2 ); fogFactor = clamp(fogFactor, 0.0, 1.0); gl_FragColor = mix(fogColor, gl_FragColor, fogFactor);
If you’ve never dealt with shaders before then you may want to try other things.
The FogFilter post processing filter provides the ability to customize the color also: http://hub.jmonkeyengine.org/javadoc/com/jme3/post/filters/FogFilter.html
I personally prefer to do fog in the rendering as opposed to a post-proc effect just because I can then better control to what it applies. The post-proc effect will apply fog to everything always.