Bloom/Glow on procedural texture?

I’ve decided to forgo the pregenerated textures for the stars and do them on the fly through GLSL using a simplex shader without a texture LUT.



It works fine (except for one small bug), but it seems I can’t apply a bloom/glow to it. It doesn’t seem to matter if I set a GlowColor to it. I thought that, by using a Post Filter it would be able to do it, but it appears that it’s not working, or maybe I’m too tired to see where the problem is.



Would that be possible?

The glow stuff is built into the material lighting shader, idk how it works but its not only the post-pro effect.

@normen said:
The glow stuff is built into the material lighting shader, idk how it works but its not only the post-pro effect.


Hmmm. Then I guess I could extract that code and switch it directly into my noise3d shader... Or I could, maybe, daisy chain to it, but I don't think that would work either since the post filter needs a texture to apply the glow to and all I have is a pixel in my shader...

Edit: I'll need to get some Zzz first I think. I'm not thinking straight. Well, worse than usual. ;)

Just copy the additional Techniques from Lighting.j3md to your material definition file. I did that in my RealSlimShader, too and it works (at least SSAO does).

2 Likes

oh @madjack i didn’t think it would happen but i’m just gonna RTFM you :smiley:



https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:bloom_and_glow

search for “Making your home brewed material definition support Glow”

1 Like

Yes. I know. :stuck_out_tongue:



I did say I was tired, didn’t I? :stuck_out_tongue:

Unfortunately using the Glow Technique didn’t give a good result. It looks pretty bleak. :frowning:



Here’s the generated texture without glow:





And here’s the same texture with the Glow Technique enabled.





The setup is pretty basic.



The geometry:

[java]



Sphere sun = new Sphere(60, 60, radius);

bodyGeometry = new Geometry("System Body", sun);

Material mat = gMgrs.getAssetManager().loadMaterial("Materials/Stars/NoiseStar.j3m").clone();

mat.setColor("sunColor", star.getColor());

mat.setColor("GlowColor", ColorRGBA.Red);



[/java]



The technique is the normal glow technique.


Technique Glow {

VertexShader GLSL100: Common/MatDefs/Misc/SimpleTextured.vert
FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag

WorldParameters {
WorldViewProjectionMatrix
}

Defines {
HAS_GLOWMAP : GlowMap
HAS_GLOWCOLOR : GlowColor
}
}


So, huh... ideas? Suggestions?

Don’t use GlowColor, just set your texture as the GlowMap

I can’t. It’s procedurally generated. It only exist in video hardware memory.

you mean your shader generates it?

Yes. And it’s animated too. :smiley:

ok…well in that case…one solution would be to render your object as is in the glow pass, but it will be rendered twice…



Try it and see if you don’t get too much performance hit

replace this line with the path to your shader

[java]

FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag

[/java]

Hmm.



Changed

[java] FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag

[/java]



with



[java] FragmentShader GLSL130: CustomShader/noise/noise4d-simplex.frag

[/java]



But except for making things brighter and losing over 130 FPS, there isn’t much glowing going on. :confused: Maybe I was expecting too much.

Maybee you set your bloompass wrong, try a higher downsampling factor or a different congiuration. If you set it to low you wont really see any glow.



(Best you just have a normal testobject and see if it works right)

Yeah maybe try with the glowColor, but with a low bloomIntensity and a higher blur scale.

It could do the trick, your texture already look bloomy, what needs to be bloomed are the edges

Right now I’ve set things like this:



Exp. Power : 5.0

Bloom Intensity: .75

Exp Cut off : 16.0

Blur Scale : 6.0

Down sampling : 4.0



The effect is nice but I’m getting artifacts when there are some objects between the sun and the camera.



Is there a way to set those from my shader so the “filter” is applied from there only on the texure? But… I guess doing so would remove the glowing “corona” around the sun… Hmm.

@madjack Any chance of getting a look at the shader code when you’re finished? I’m always interested in learning something new when it comes to shaders :slight_smile:

@madjack said:
It's because of the glow. I'm getting artifacts when there are some objects between the sun and the camera.


It's a bit involved. I first create the geometry using the parameters for a particular star. That geometry uses NoiseStar.j3m which calls the vert/frag. Using the sphere's vertices I generate the texture.

I'm using a 4D LUT-less simplex noise generation shader. The first 3 coords (x/y/z) used are those of the vertex currently being processed. The fourth argument used is Time. Since at each iteration of each vertex time has slightly changed there's an "animation".

The best way to find out how it works is to check it out. ;)

I'd suggest you go at the source : webgl-noise

Oh it’s done. The shader is pretty fine. :smiley:



Here’s what it looks like with a glow on it, although we can’t see it in this image, there’s artifacts like I stated above.



http://www.danyrioux.com/files/sun_shader.png

1 Like

As far as sharing the shader… Hmmm…