(June 2019) Monthly WIP & Screenshot Thread

I noticed that BloomFilter has no effect on PBR materials, but I can’t say if that’s by design or what. This is what a bunch of cubes with emissive colors look like with PBRLighting:

Imgur

Without some glow, it doesn’t look like what I would expect of an “emissive” object. Anyway, looking inside jME’s .j3md files I found that, unlike Lighting.j3md, the Glow technique on PBRLighting.j3md does not define HAS_GLOWMAP and HAS_GLOWCOLOR, so I decided to play with it.

    Technique Glow {

        VertexShader GLSL100 GLSL150:   Common/MatDefs/Misc/Unshaded.vert
        FragmentShader GLSL100 GLSL150: MatDefs/Emissive.frag

        WorldParameters {
            WorldViewProjectionMatrix
            ViewProjectionMatrix
            ViewMatrix
        }

        Defines {
            NEED_TEXCOORD1

            // I added the next 2 lines to my PBRLighting.j3md
            HAS_EMISSIVEMAP : EmissiveMap
            HAS_EMISSIVE : Emissive

            NUM_BONES : NumberOfBones
            INSTANCING : UseInstancing
            NUM_MORPH_TARGETS: NumberOfMorphTargets
            NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
        }
    }

Since PBRLighting.j3md has no GlowMap or GlowColor, I changed it to EmissiveMap and Emissive respectively. I also created an Emissive.frag file as follows (which is basically Glow.frag only replacing GLOW with EMISSIVE):

#import "Common/ShaderLib/GLSLCompat.glsllib"

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

#ifdef HAS_EMISSIVEMAP
  uniform sampler2D m_EmissiveMap;
#endif

#ifdef HAS_EMISSIVE
  uniform vec4 m_Emissive;
#endif

void main()
{
    #ifdef HAS_EMISSIVEMAP
        #if defined(NEED_TEXCOORD1) 
           gl_FragColor = texture2D(m_EmissiveMap, texCoord1);
        #else 
           gl_FragColor = texture2D(m_EmissiveMap, texCoord);
        #endif
    #else
        #ifdef HAS_EMISSIVE
            gl_FragColor =  m_Emissive;
        #else
            gl_FragColor = vec4(0.0);
        #endif
    #endif
}

And this is the result :

Imgur

I think it is much better now! :smiley:

By the way, I’m using here @Apollo’s MipmapBloomFilter, which I think looks better than the regular BloomFilter.

15 Likes