We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How to add lensflare to your scene

Home Forums Tutorials How to add lensflare to your scene

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #30896
    core3d
    Customer

    OK here you go;
    1. You need Lensflare.js in you app directory.
    Lensflare.js

    2. Enable your app to import modules in your myapp.html file.

     <script src="v3d.js"></script>
      <script type="module" src="myapp.js"></script>

    3. Import Lensflare module to your myapp.js file.

    import * as verge from '../../build/v3d.module.js';
    import { Lensflare, LensflareElement } from './Lensflare.js';

    This needs to be on top of your file after “use strict” line.

    4. Add an omnilight on your scene as “Omni001” in your 3D application (blender or max or maya)

    5. Add lensflare textures on your app directory inside (../textures/lensflare/).

    6. Add lensflare code to your runcode section.

    var textureLoader = new v3d.TextureLoader();
    
                    var textureFlare0 = textureLoader.load('textures/lensflare/lensflare0.png');
                    var textureFlare3 = textureLoader.load('textures/lensflare/lensflare3.png');
                                    
                      var light = app.scene.getObjectByName('Omni001');
            
                      var lensflare = new Lensflare();
                      lensflare.addElement(new LensflareElement(textureFlare0, 700, 0, light.color));
                      lensflare.addElement(new LensflareElement(textureFlare3, 60, 0.6));
                      lensflare.addElement(new LensflareElement(textureFlare3, 70, 0.7));
                      lensflare.addElement(new LensflareElement(textureFlare3, 120, 0.9));
                      lensflare.addElement(new LensflareElement(textureFlare3, 70, 1));
                      light.add(lensflare);

    Thats all.
    Happy lensflaring.
    Thanks to zjbcool for his awesome example about importing modules.

    #30914

    Awesome! Thanks for sharing your solution! :good:

    Chief 3D Verger | LinkedIn | Twitter

    #30926
    web
    Customer

    Thx you very much for that write up. This is pure gold.

    #30947
    zjbcool
    Customer
    #31580
    visualizer
    Customer

    Wow
    looks interesting !

    can you provide a simple example file as well?
    For newbie & no programmer like me it would be great guide.

    Its really nice idea :good: you shared here !

    :good:

    #39421
    gf3d
    Customer

    Hi there, i´ve been using this and it works fine…..

    The only thing!!!!

    the flare disappear when behind 3d objects in the scene….

    I know this is what flares should do…..but is there a way to
    prevent them from doing this?

    Greets

    Ger

    #43483
    jdhutchinson
    Customer

    Does this require the Enterprise version of Verge?

    In reference to the line:

    import * as verge from '../../build/v3d.module.js';

    #43939
    jdhutchinson
    Customer

    i Couldn’t add the build v3d module line :scratch:

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.