A bug with Glow Shader

When applying the glow shader and some glowing things, using the “unshaded” material have some fractional alpha color (between 0 and 1), the whole scene starts tweening and shading off. This is especially visible because in my application it happens in cycles and it comes in and out. When there is no alphed objects, all is fine, but as they appear - the bad happens.



Can I use alphed objects with the glow shader?

as it should be, without alpha:







as it bugs, with alpha, but the only effect should be with the golden rays. all else should not be affected. here you can see, how the mouse cursor (red) gets tweened and the violet particles get blurred and the rays get stronger:



uh…looks like a clearing issue.

It’s kinda hard to figure what’s wrong though, could you make a test case?

Finally I have been able to fabricate a test case. The idea is that the triangle that is in the centre of the orange quad is changing it’s alpha from 0 to 1 and back over time. The other 3 triangles, although, objects of the same class, are updated with a different update loop, which does no changes to their material. However, they are affected by the change of the central triangle. I think that maybe the fact that I use a pre-defined color from ColorRGBA might be the cause of the spread of the chang to the color… am I right? But still, the clearing issue remains and you can see it with the three other triangles. Please also note that the clearing issue with the glow filter is known to me for a long time. It can be fixed by drawing something in the space, so, when I need a black background, I, usually, put a full-screen black quad there. But here now, please see and tell me, what’s wrong?



[java]

package testcase;



import com.jme3.app.SimpleApplication;

import com.jme3.app.state.AbstractAppState;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.FastMath;

import com.jme3.math.Quaternion;

import com.jme3.math.Vector3f;

import com.jme3.post.FilterPostProcessor;

import com.jme3.post.filters.BloomFilter;

import com.jme3.scene.Geometry;

import com.jme3.scene.Mesh;

import com.jme3.scene.Mesh.Mode;

import com.jme3.scene.VertexBuffer.Type;

import com.jme3.scene.shape.Quad;

import com.jme3.system.AppSettings;

import com.jme3.util.BufferUtils;



public class Testcase extends SimpleApplication {



BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects); //BloomFilter.GlowMode.SceneAndObjects)



class Background {

Quad quad = new Quad(300, 300);

Geometry geom = new Geometry(“bckg”, quad);

Material mat;



public Background() {

}



public void ready(Testcase app) {

app.guiNode.attachChild(geom);

geom.setLocalTranslation(200, 100, -10);

}



public void update(float tpf) {

if(mat == null) {

mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Orange);

geom.setMaterial(mat);

}

}

}



class TestObject {



Mesh mesh;

Geometry geom;



String name;



Material mat;

ColorRGBA color = ColorRGBA.Blue;

ColorRGBA glowColor = new ColorRGBA(0.4f, 0.4f, 0.1f, 1.0f);



Vector3f pointA = new Vector3f(0, 0, 0);

Vector3f pointB = new Vector3f(100, 0, 0);

Vector3f pointC = new Vector3f(0, 100, 0);



float alpha = 1f;

float dAlpha = 0.001f;



Quaternion q = new Quaternion();



public TestObject(String name) {

this.name = name;

mesh = new Mesh();

geom = new Geometry("test " + name, mesh);

mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(pointA, pointB, pointC));

mesh.setMode(Mode.Triangles);

mesh.updateBound();

}



public void ready(Testcase app, float x, float y, float z) {

app.guiNode.attachChild(geom);

geom.setLocalTranslation(x, y, z);

}



public void update(float tpf) {

if(mat == null) {

mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, color);

mat.setColor(“GlowColor”, glowColor);

geom.setMaterial(mat);

}



alpha += dAlpha;

if(alpha < 0) {

alpha = 0;

dAlpha = -dAlpha;

}

if(alpha > 1) {

alpha = 1;

dAlpha = -dAlpha;

}



geom.setLocalRotation(q.fromAngles(new float[] {0, 0, alpha * FastMath.TWO_PI}));



System.out.println(“alpha=” + alpha);



doColorThing();

}



private void doColorThing() {

System.out.println(“test object " + name + " do color thing”);

color.a = alpha;

glowColor.r = alpha;

mat.setColor(“Color”, color);

mat.setColor(“GlowColor”, glowColor);

}



public void updateA(float tpf) {

update(tpf);

doColorThing();

}



public void updateB(float tpf) {

update(tpf);

}

}



class TestState extends AbstractAppState {



TestObject testObject;

Background background;



TestObject testA;

TestObject testB;

TestObject testC;



public TestState(Testcase app) {

testObject = new TestObject(“a”);

testA = new TestObject(“b”);

testB = new TestObject(“c”);

testC = new TestObject(“d”);

testObject.ready(app, 350, 250, 0);

testA.ready(app, 100, 100, 0);

testB.ready(app, 200, 200, 0);

testC.ready(app, 200, 300, 0);

background = new Background();

background.ready(app);

}



public void updateObject(float tpf) {

testObject.updateA(tpf);

testA.updateB(tpf);

testB.updateB(tpf);

testC.updateB(tpf);



background.update(tpf);

}



}



TestState state = new TestState(this);



private void initSetup() {

setShowSettings(false);

AppSettings s = new AppSettings(true);

s.setTitle(“test case”);

s.setResolution(800, 600);

s.setFullscreen(false);



bloom.setEnabled(true);

bloom.setDownSamplingFactor(1);

bloom.setBloomIntensity(3.25f);

bloom.setBlurScale(3f);

bloom.setExposurePower(2);

}



public void simpleInitApp() {

FilterPostProcessor fpp = new FilterPostProcessor(assetManager);

fpp.addFilter(bloom);

guiViewPort.addProcessor(fpp);

}



public void simpleUpdate(float tpf) {

if(!state.isEnabled())state.setEnabled(true);

state.updateObject(tpf);

}



public static void main(String[] args) {

System.out.println(“hello world!”);

Testcase testcase = new Testcase();

testcase.initSetup();

testcase.start();

}



}



[/java]

@noncom said:
[java]
public void simpleUpdate(float tpf) {
if(!state.isEnabled())state.setEnabled(true);
state.updateObject(tpf);
}
[/java]


Unrelated, but why do you do this when the state will already get its own update method called every frame?

And yes, if you modify the values of ColorRGBA.Blue then it will modify all blue colors. Don't do that. A simple ColorRGBA.Blue.clone() would have taken care of that.
1 Like

Oh yes, that’s true… I forgot about that. For quite a while already, I program over my custom framework over JME3 and the basics is long ago burried in the framework so bear with me.



And alright, the color change I got it now, I will use clone(), but what about the clearing issue?

Ummm… so no one has a similar clearing issue? Maybe that’s the video adapter nVidia GeForce GT420 problem?

Sorry I missed your post with the test case.
I’ll look into it and report back

Ummm… so no one has a similar clearing issue? Maybe that’s the video adapter nVidia GeForce GT420 problem?

I ran your test case, the triangles over the black background leaves a solid blue color behind. nVidia GT520 (linux). Don’t think it’s a driver issue but I have no clue how to fix it :slight_smile:

At least now I have a company :smiley:

You are adding the FilterPostPorcessor to the guiViewPort.
The guiViewPort is set to not clear color… or it would clear the rendered scene…so here is your clear issue.

adding

guiViewPort.setClearColor(true);

to the simpleInit fixes your issue.

But i’m not sure why you are adding it to the gui viewport…is that a mistake or is that on purpose?

1 Like

Thank’s for the hint! As for the viewport, well, currently I am making mostly 2D graphics… so I use the guiViewPort really much. So I think that the filter should be applied to it exactly?

Thank’s for the hint! As for the viewport, well, currently I am making mostly 2D graphics… so I use the guiViewPort really much. So I think that the filter should be applied to it exactly?
Yes, but you have to clear the color. So if at some point you want to put something in the 3D scene, it won't be visible... You can make 2 graphics as well in the main viewport by setting the camera to ortho (same coordinate system as the guiViewport) ,you'll be able to apply filters with no issue and use the guiViewPort for GUI. viewport.setCamera(cam, true); (the true is for ortho mode)
1 Like