Jump to content

High quality glowing sphere?


asperger
 Share

Recommended Posts

Is there any way to make a high quality glowing sphere?

At first I thought I could use the glowlayer but that only seems to work for imported meshes?

https://www.babylonjs-playground.com/#LRFB2D#1

Then last  experiment with the HighlightLayer by increasing the blur size:

https://www.babylonjs-playground.com/#1KUJ0A#137

Now with the latter the quality is really bad. Any recommendation?

 

Edit:

I did manage to create a shader that works with three.js but im not sure how to translate it to make it work with babylon.js.
If anyone can manage to make it work with babylon then we have a high quality  glow thats fast.

<script id="vertexShader" type="x-shader/x-vertex">
uniform vec3 viewVector;
uniform float c;
uniform float p;
varying float intensity;
void main()
{
vec3 vNormal = normalize( normalMatrix * normal );
    vec3 vNormel = normalize( normalMatrix * viewVector );
    intensity = pow( c - dot(vNormal, vNormel), p );
    
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
</script>
 
<script id="fragmentShader" type="x-shader/x-vertex">
uniform vec3 glowColor;
varying float intensity;
void main()
{
    vec3 glow = glowColor * intensity;
gl_FragColor = vec4( glow, 1.0 );
}
</script>
Link to comment
Share on other sites

11 minutes ago, asperger said:

Weird. It seems I didnt see that part in the documentation:

glowLayer.addIncludedOnlyMesh(mesh);
 
Interesting. I can also control the intensity and texture quality. Pretty great. The performance is far better than that of the HighlightLayer.

It will still work without that function. You might have forgotten setting an emissiveColor?

Link to comment
Share on other sites

4 hours ago, asperger said:

The problem is that the glow layer always seems to be in the foreground.

You can put things in front of the glow layer using the rendering group id (GlowLayer defaults to -1):
http://playground.babylonjs.com/#IEW571#1
https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...