Glow renders over everything

hello

using the glow filter, i notice that it renders on top of everything

i mean that if an object is infront of the glowing object, then the glow is seen through wile the object is not visible

i just copied the code from the tutorial and added it to my game
i tried to set the values to default but still having the same issue

[java]
glowFpp=new FilterPostProcessor(main.getAssetManager());
bloomFilter=new BloomFilter(BloomFilter.GlowMode.Objects);
bloomFilter.setDownSamplingFactor(2);
bloomFilter.setBlurScale(1.5f);
bloomFilter.setExposurePower(5.0f);
bloomFilter.setExposureCutOff(0.3f);
bloomFilter.setBloomIntensity(2.0f);
glowFpp.addFilter(bloomFilter);
viewPort.addProcessor(glowFpp);
[/java]

how can i solve this ? is it the expected way for this effect to render ?

screenshot?

1 Like
<cite>@nehon said:</cite> screenshot?

the case seems to appear on some occasions
most of the time it is hiden behind objects, but sometimes, it shows up on top of scene rendering

depending on the camera position/orientation

http://i.imgur.com/OzckSqd.png

Looks like a transparency issue to me rather than a glow issue. Or maybe a combination of both
How do you setup the reddish glowing object material?
do you have depthTest, depthWrite disabled on it? (you shouldn’t)
what material are using the opaque objects? lighting?
If we don’t find something obvious, I’ll need a test case.

<cite>@nehon said:</cite> Looks like a transparency issue to me rather than a glow issue. Or maybe a combination of both How do you setup the reddish glowing object material? do you have depthTest, depthWrite disabled on it? (you shouldn't) what material are using the opaque objects? lighting? If we don't find something obvious, I'll need a test case.

ok i’ll check it out

thx for the help

i think it might be alpha related

as i build some object as a hierarchy instead of a unique node, i get alpha artifacts

<cite>@nehon said:</cite> Looks like a transparency issue to me rather than a glow issue. Or maybe a combination of both How do you setup the reddish glowing object material? do you have depthTest, depthWrite disabled on it? (you shouldn't) what material are using the opaque objects? lighting? If we don't find something obvious, I'll need a test case.

i finaly spotted the guilty code

[java]
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(0);
[/java]

was set to a child node of rootnode (floor)

Node [Root Node] Dynamic
  |___Node [floor] Dynamic
    |___Geometry [0-0] Dynamic
         |___Mesh [2]
    |___Geometry [1-0] Dynamic
         |___Mesh [2]
    |___Geometry [2-0] Dynamic
         |___Mesh [2]
    |___Geometry [3-0] Dynamic
         |___Mesh [2]
    |___Geometry [4-0] Dynamic
         |___Mesh [2]

      ....
  • but i dont understand why it is voiding the depth test for the whole scene as it only concer the scene floor

  • also as i am using particles, i notice the same artifact
    i checked the particle.j3md and depthwrite seems to be off
    wich is predictable but then i was wondering how to have a glow effect behind clouds particles (if possible)

any idea ?

thx

that’s strange indeed…

For the second question what you can do is to change the glow technique of the particle material to write depth
So depth of the particles will be rendered during the glow pass.

<cite>@nehon said:</cite> that's strange indeed...

For the second question what you can do is to change the glow technique of the particle material to write depth
So depth of the particles will be rendered during the glow pass.

thx i’ll check that out

as for the alpha test, i noticed that once i use
mat.getAdditionalRenderState().setAlphaTest(true);
mat.getAdditionalRenderState().setAlphaFallOff(0);

on any node (i tried on the particle system)
then the glow artifact rehappens

<cite>@nehon said:</cite> that's strange indeed...

For the second question what you can do is to change the glow technique of the particle material to write depth
So depth of the particles will be rendered during the glow pass.

i tried may things but the glow always reders on top of the smoke particles with no significant slight effect

        Blend Alpha  (... Modulate,PreMult ..)
        DepthWrite On
        DepthTest On

is there a way to debug the glow buffer so i can see that black smoke is drawn in front of the glow color ?

@curtisnewton said: i tried may things but the glow always reders on top of the smoke particles with no significant slight effect
        Blend Alpha  (... Modulate,PreMult ..)
        DepthWrite On
        DepthTest On

is there a way to debug the glow buffer so i can see that black smoke is drawn in front of the glow color ?


you did this in the glow technique of the Particle.j3md?
Only depthWrite on should be needed

<cite>@nehon said:</cite> you did this in the glow technique of the Particle.j3md? Only depthWrite on should be needed

yes i copied the original, then used it, then added depth write

then i tried other stuffs

strange it has no efffect at all, i’ll keep digging

i made a simple project with a particle system and glow filter

maybe if you got some time, could you be kind to look at it ?

glow+particles

thx

1 Like

+1 for the test case.

Some input: this issue looks to be happening on anything in the Transparent bucket with blend mode alpha. You can sort of fix the issue in the test case by setting GlowColor to ColorRGBA.Black on the particle material [java]sparkMat.setColor(“GlowColor”, ColorRGBA.Black);[/java]

If I had to guess, I would say the issue is coming from Common/MatDefs/Light/Glow.frag which defaults back to vec4(0.0) when there is no glow color or texture, which doesn’t write anything to the color buffer… since the transparent bucket is rendered separately, it’s depths have no effect on the rendering of the opaque bucket, and since there is no colour being written to the buffer on the extract glow pass (using the Glow technique) to ‘over write’, these objects/materials are getting ignored in the glow filter. This would explain why setting GlowColour to ColorRGBA.Black ( vec4(0.0,0.0,0.0,1.0) ).

2 Likes

Thanks James :wink:
Easy fix!

<cite>@thetoucher said:</cite> +1 for the test case.

Some input: this issue looks to be happening on anything in the Transparent bucket with blend mode alpha. You can sort of fix the issue in the test case by setting GlowColor to ColorRGBA.Black on the particle material [java]sparkMat.setColor(“GlowColor”, ColorRGBA.Black);[/java]

If I had to guess, I would say the issue is coming from Common/MatDefs/Light/Glow.frag which defaults back to vec4(0.0) when there is no glow color or texture, which doesn’t write anything to the color buffer… since the transparent bucket is rendered separately, it’s depths have no effect on the rendering of the opaque bucket, and since there is no colour being written to the buffer on the extract glow pass (using the Glow technique) to ‘over write’, these objects/materials are getting ignored in the glow filter. This would explain why setting GlowColour to ColorRGBA.Black ( vec4(0.0,0.0,0.0,1.0) ).

wooow awesome
thx
i’ll have a look
(i also need to be carefull as i modify some glow techniqies for my own needs)

<cite>@thetoucher said:</cite> You can sort of fix the issue in the test case by setting GlowColor to ColorRGBA.Black on the particle material [java]sparkMat.setColor("GlowColor", ColorRGBA.Black);[/java]

the problem is that it seems to render entire (black) squares when the glow technique is processed
wich leads to un-nuanced glow occlusion by the smoke particles polygons
[edit : i ll try to modify the glow technique so it uses the same texture sampler as the one used for the regular rendering technique. should work]

blur and glow image

also i was wondering if with this (glow) technique it was possible to have ray of lights appreaing through the smoke
like whe the sun scatters through tree leaves or clouds ?

ok, for those interesested inmaking it work

here is the working code for the frag shader


#if defined(NEED_TEXCOORD1) 
    varying vec2 texCoord1;
#else 
    varying vec2 texCoord;
#endif


#ifdef HAS_GLOWMAP
  uniform sampler2D m_GlowMap;
#endif

#ifdef HAS_GLOWCOLOR
  uniform vec4 m_GlowColor;
#endif

uniform sampler2D m_Texture;
varying vec4 color;

void main(){
    #ifdef HAS_GLOWMAP
        #if defined(NEED_TEXCOORD1) 
           gl_FragColor = texture2D(m_GlowMap, texCoord1);
        #else 
           gl_FragColor = texture2D(m_GlowMap, texCoord);
        #endif
    #elif USE_TEXTURE
        if (color.a &lt;= 0.01)
            discard;

        #ifdef POINT_SPRITE
            vec2 uv = mix(texCoord1.xy, texCoord1.zw, gl_PointCoord.xy);
        #else
            vec2 uv = texCoord1.xy;
        #endif
        gl_FragColor = texture2D(m_Texture, uv) * color;

    #else
        #ifdef HAS_GLOWCOLOR
            gl_FragColor =  m_GlowColor;
        #else
            gl_FragColor = vec4(0.0);
        #endif
    #endif
}

and the modified glow material part

[code].


Technique Glow {

    VertexShader GLSL100:   Common/MatDefs/Misc/Unshaded.vert
    FragmentShader GLSL100: Shaders/Particles/Glow.frag
    
    WorldParameters {
        WorldViewProjectionMatrix
    }

    Defines {
        NEED_TEXCOORD1
        HAS_GLOWMAP : GlowMap
        HAS_GLOWCOLOR : GlowColor
        USE_TEXTURE : Texture
    }

    RenderState {
        PointSprite On
        Blend Alpha
        DepthWrite On
        DepthTest On
    }
}

}
[/code]

3 Likes
<cite>@curtisnewton said:</cite> also i was wondering if with this (glow) technique it was possible to have ray of lights appreaing through the smoke like whe the sun scatters through tree leaves or clouds ?

Light Scattering … I used it here : http://www.youtube.com/watch?v=TptQ8NL0D3s

<cite>@thetoucher said:</cite> Light Scattering ... I used it here : http://www.youtube.com/watch?v=TptQ8NL0D3s

cool

how did you generate the terrain ?
also it seems to use some zblur effect

really nice

thx mate

terrain is simple perlin noise octaves… “zblur effect” is my “physical camera” shader, thanks =)