Jump to content

Glow effect: alternative to godrays that is easy on the CPU?


qqdarren
 Share

Recommended Posts

I've been using god-rays (aka BABYLON.VolumetricLightScatteringPostProcess) to give a nice fiery, pulsating, glow effect on a couple of meshes. I like the effect, but when I tested on an ipad it stuttered for a couple of seconds then restarted with them disabled.  Even on my notebook (reasonable CPU, but no dedicated GPU) they tend to make the machine go hot.

So, I'm looking for an alternative that is not so processor intensive. Maybe that means a custom shader? Or particles? Or transparent gradients?? I'd really appreciate links to babylon playground that show off some possibilities. Maybe you've done a glowing radioactive object? Or a forcefield round a spaceship? Or a fireball? Something along those lines.

Thanks in advance for any inspiration you can give!

Link to comment
Share on other sites

It is by far the toughest question I had and to be no honest, I copy pasted push from the array (js naming) cause I am Lazy and Suffix by Mesh (also copy pasted from the time in the method). I basically did not think about it :-)

Do you think the guy who added script after java really thought about this ? (I am not in any case comparing myself to this guy but I just really like this answer) :

http://stackoverflow.com/questions/245062/whats-the-difference-between-javascript-and-java

Link to comment
Share on other sites

is that possible choose some meshes ( like transparent mesh  or glass ... ) for ineffective 

http://www.babylonjs-playground.com/#CDHKK#3  some thing is wrong between 2 sphere

this fixed when used 2 layer 

http://www.babylonjs-playground.com/#CDHKK#4

and any parameter or option for make custom glow?

 

Link to comment
Share on other sites

Hey,

Yep so by default it is using one pass for all the meshes for efficiency but if overlapping meshes are critical you can use several layers.

About options, you can set on the highlight layer constructor :

    /**
     * Highlight layer options. This helps customizing the behaviour
     * of the highlight layer.
     */
    export interface IHighlightLayerOptions {
        /**
         * Multiplication factor apply to the canvas size to compute the render target size
         * used to generated the glowing objects (the smaller the faster).
         */
        mainTextureRatio?: number;

        /**
         * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size 
         * of the picture to blur (the smaller the faster).
         */
        blurTextureSizeRatio?: number;

        /**
         * How big in texel of the blur texture is the vertical blur.
         */
        blurVerticalSize?: number;

        /**
         * How big in texel of the blur texture is the horizontal blur.
         */
        blurHorizontalSize?: number;

        /**
         * Alpha blending mode used to apply the blur. Default is combine.
         */
        alphaBlendingMode?: number
    }

then the blur sizes are accessible dynamically at run.

On the mesh you can choose the color and or using the emissive texture as a color input.

Alpha tested mesh will be discarded automatically.

What other options would you want or custom arts being open? Feel free to open the entry points you need in the code and PR. Else I could open them for you.

CU

 

Link to comment
Share on other sites

  • 2 weeks later...

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...