I have tried to implement blooming for a project I am working on (Physics based Solar System), to simulate rays from the sun and to illuminate the paths of the planets.
So far I have succeeded in getting selective blooming using seperate RenderPasses and having a glowlist containing Spatials which should have blooming, and a occludelist containing Spatials which should be able to occlude the glow.
My problem is as follows:
If I add the Line Spatials to the glowlist, they are not “blooming”.
If I add my entire scene to the glowlist (rootNode), only selective parts of the scene are “blooming”. :?
To clarify, I have added these screenshots: (Click URL to enlarge)
(Case #1: Blooming on Sun and added Lines to glowlist)
If I understand correctly, I am not doing that at the moment.
I render the scene normal, then I have a extra renderpass that renders bloom / occluding items without bloom.
rootNode setup:
Ships
Planets
L Planet Node
L Planet Model
L SwitchNode Mesh
L QuadImage
L Low Poly
L High Poly Mesh
L Billboard Quad text
L Lines
L Path Line (coloured line)
L Zero-z Line (green line)
L (selected) CameraNode
Lines
L Blue outward running Z-zero lines
L Blue circular Z-zero lines @ 0.5 AU
PassManager setup:
Renderpass background (skybox) //Something I tried to get correct blending with the blooming, can be integrated in normal
Renderpass normal (rootNode) // Self explanatory, all parts of the scene are (indirect) children of the scene.
Renderpass bloom (High Poly Sun Mesh, Line Path Node of planet, Lines Node of rootNode) // see bottom line for more explanation.
Renderpass controlpass (mouse, control box) //clears Z-Buffer and renders the mouse/control box
Construction of BloomPass:
// This is very messy because I have been trying an x amount of setups to get occluding to work without having to duplicate my entire scene. ( I KNOW this is not the best way to do it. )
This one just stuck because it correctly does not apply blooming to the occluding spatials, but still looks correct in blending.
(Spatials are rendered as black by settings a total black MaterialState in the BloomRenderPass)
BUT the problem still occured if I just make a normal BloomRenderPass and attach the rootNode/only the to be rendered spatials.
private void constructBloom() {
bloompass = new BloomRenderPass(DisplaySystem.getDisplaySystem().getRenderer().getCamera(), 1) {
@Override
public void doRender(Renderer r) {
Iterator<Spatial> oclist = super.spatials.iterator();
while (oclist.hasNext()) {
Spatial next = oclist.next();
if (occludelist.contains(next)) {
next.setRenderState(swtch[2]);
next.updateRenderState();
}
}
super.doRender(r);
Iterator<Spatial> ocblist = super.spatials.iterator();
while (ocblist.hasNext()) {
Spatial next = ocblist.next();
if (occludelist.contains(next)) {
next.clearRenderState(RenderState.RS_MATERIAL);
next.updateRenderState();
}
}
The Controlbox part looks really ugly at the moment and is made up out of Quads. (I ran into ugly visual problems if I introduced light with the controlbox using Boxes). It functions but still needs many basic things, like Spatialtransformer etc.
It looks awesome, I was interested to see bloom working with lines. You’ve probably got other things to look into, but the starfield class would look nice:
Update part of the RenderState. In essence, you can run the mouse over the box and it will change the materialstate, making it look like you have it selected, and you can select a part of the box which then can be recognized and do the things you want it to do.
OrbitHandler, small piece of code uses a CameraNode to translate the camera in such a way that you can easily use orbital controls (zoom/pan/tilt) and also translate that centerpoint. It also has a function that will let you translate the camera to a new point in a x number of frames.
It still needs to know what the “Up” vector is, (because this changes, and I had some problems using the Up from camera.)
Congrats on the successful demo. It looks great btw. If you could post it to a webstart, it would be cool to link to it from the jME site as an external demo.