Adding volumetric lights in unity

How do I add volumetric lights in unity with needle. I’ve tried with some plugins but its not working on web build. Please help me with it. Thanks

Original Post on Discord

by user 738335937485864961

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Here is what I found for you :brain: Discord

Hello Tobi216, to add volumetric lights in Unity using Needle, it seems you should use the Volume component as it handles post-processing effects which can include volumetric lighting. The relevant documentation does not specify a dedicated component for volumetric lights, but typically such effects are part of the post-processing stack. Here’s how you can create a Volume component in Needle Engine (see the documentation):

import { Volume, VolumeProfile } from "@needle-tools/engine"; // Make sure to import needed modules

// Define a class that extends Behaviour and adds a Volume component
export class VolumetricLightExtension extends Behaviour {
    sharedProfile?: VolumeProfile; // Assign a volume profile if needed

    awake() {
        this.sharedProfile = new VolumeProfile(); // Initialize the volume profile
        // Add and configure the volumetric light effect on your volume profile here

You can assign this class as a component to a GameObject in your Unity scene. Make sure to properly configure the volume profile to create the volumetric lighting effect. If Needle Engine does not provide a volumetric light effect out of the box, you might need to attach a custom post-processing effect that simulates volumetric lighting.

Remember to comply with the WebGL limitations when working with post-processing effects, as not all effects available in Unity might work on web platforms. If you have any specific custom effect or plugin that you want to work with, you can register and apply that custom effect within the Volume component as described in the documentation. Please keep in mind that you might face limitations or require adjustments when porting certain effects to WebGL.

1 messages left GPT 4

There’s various things that “volumetric lights” can mean – fully volumetric lights that do pathtracing are typically very expensive in terms of performance, whereas geometry-based volumetric lights are very cheap. Which one are you looking at?

I’m looking at geometry based volumetric lights

by user 738335937485864961

Volumetric light or “god rays” to add in this area

by user 738335937485864961

As long as they’re meshes they should be exported like everything else – are they using custom shaders?


by user 738335937485864961

How do they look in Unity / what package are you using?

Hey… right now I’m using planes and transparent png’s for volumetric lights

by user 738335937485864961

But it is not going to look good if we pass through it

by user 738335937485864961

Could you please explain the volumetric lights that do path tracing as you mentioned here?

by user 738335937485864961

That’s often a post effect, something like this:
If you’re targeting high-end mobile or desktop that would be one approach, I would not recommend using that for VR though

Typically you’d fade the planes out based on user/camera distance so that you can never clip through them

(either via script or via shader)

Thanks! Will try and let you know

by user 738335937485864961