Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Volumetric Light Beam - Volumetric Lighting solution compatible with Mobile, VR and WebGL

Discussion in 'Assets and Asset Store' started by techsalad, Oct 9, 2017.

  1. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    techsalad likes this.
  2. papand7

    papand7

    Joined:
    Oct 19, 2019
    Posts:
    3
    Hi, I have used your package in my current project but i am having issues with Light Beams going through walls, how can i resolve this issue?

    Thanks.
     
  3. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey,

    Thank you for your message.

    If you are using a version of the plugin prior to 2.0, or if you are using "SD Beams", you have 2 dynamic occlusion solutions: Dynamic Occlusion Raycasting or Depth Buffer. Here is some info to help you choose between the 2 options: https://saladgamer.com/vlb-doc/comp-dynocclusion-sd-raycasting/#which-dynamic-occlusion-should-i-use

    If you are using VLB 2.0, you can use a HD Beam and enable Volumetric Shadows.

    I hope it helps. Do not hesitate if you have any questions.

    Thanks!
    TS
     
  4. papand7

    papand7

    Joined:
    Oct 19, 2019
    Posts:
    3
    Thanks, i am using VLB 2.0 with URP i cannot find the HD Beam script is it only for HDRP?
     
  5. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey !

    No, the HD Beams work for all render pipelines, built-in, URP and HDRP.

    With the version 2.0, the plugin imports a single unitypackage file under the Assets/Plugins/VolumetricLightBeamPackage folder. Have you properly imported it following the readme instructions (or this help page: http://saladgamer.com/vlb-doc/#install-the-plugin)?

    Thanks
    TS
     
    Last edited: Dec 8, 2022
  6. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    This is really awesome. Is there a way to change VLB's rendering pipeline at runtime? My application switches between BiRP and URP at runtime so I need VLB to be compatible too. :)
     
    techsalad likes this.
  7. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Thank you very much.
    I didn't even know if was possible to change render pipeline at runtime.
    So no the plugin doesn't support that. Depending on the current pipeline in use, it will generate the shaders specifically for this render pipeline.
    It might be possible to support it, but I have to evaluate first the amount of work needed.
    Thanks
    TS
     
  8. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    69
    Thanks! Can you point me to the code where shaders are generated? Maybe I can also take a look. I really like the quality of the volumetric light beams so far and hopefully I can get this integrated into my project.

    To change render pipeline at runtime, you can set two quality levels in the Quality settings, one for BiRP and one for URP (which has the rendering pipeline asset assigned). And then at runtime: `QualitySettings.SetQualityLevel(1);` to switch to URP and ``QualitySettings.SetQualityLevel(0);` to switch to BiRP.
     
  9. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey,
    Generating shaders is done in ShaderGenerator.Generate function. It's called multiple times:
    • When loading the Config asset (when opening Unity)
    • When changing the current render pipeline property in the Config asset
    • When exporting a standalone build (via OnBuildPreprocess)
    • When changing build target (via OnBuildTargetChanged)
    I hope it helps.
    Cheers
    TS
     
    Last edited: Mar 11, 2023
    TigerHix likes this.
  10. Doom-Slayer

    Doom-Slayer

    Joined:
    Jun 13, 2022
    Posts:
    3
    Hello

    Bought the Asset and went to try it out, but immediately ran into a constant error when using Volumetric Shadow HD. If the volumetric Shadow HD component exists at all it spits out errors every frame and changing settings doesn't seem to change anything.

    This happens both in my own scenes, as well as the URP demo scene. Version 2021.3.7f1.

    There are 2 errors that repeat over and over.

    Error 1
    RenderTexture.Create failed: colorFormat & depthStencilFormat cannot both be none.
    UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    VLB.VolumetricShadowHD:processOcclusionInternal () (at Assets/Plugins/VolumetricLightBeam/Scripts/HD/VolumetricShadowHD.cs:199)
    VLB.VolumetricShadowHD:Update () (at Assets/Plugins/VolumetricLightBeam/Scripts/HD/VolumetricShadowHD.cs:249)

    Error 2
    Invalid surface for grabbing pixels. Verify that the RenderTexture is a valid color surface. Only a single color target may be grabbed.
    UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,System.Collections.Generic.List`1<UnityEngine.Camera/RenderRequest>,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)
    VLB.VolumetricShadowHD:processOcclusionInternal () (at Assets/Plugins/VolumetricLightBeam/Scripts/HD/VolumetricShadowHD.cs:199)
    VLB.VolumetricShadowHD:Update () (at Assets/Plugins/VolumetricLightBeam/Scripts/HD/VolumetricShadowHD.cs:249)

    EDIT:

    So I believe this is due to a conflict of some kind between FlatKits Outline/Fog Renderer features, https://assetstore.unity.com/packages/vfx/shaders/flat-kit-toon-shading-and-water-143368 . Having either of them causes this to break, but doesn't for any other Renderer Feature.
     
    Last edited: Mar 11, 2023
  11. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,
    Thank you very much for your message and for the report.
    I'll test on my side with the assets you mentioned and try to figure out what's going on.
    I'll keep you posted.
    Thanks
    TS

    EDIT: the "Fog Renderer" feature is also part of the "Flat Kit toon shading" plugin?
     
    Last edited: Mar 11, 2023
  12. Doom-Slayer

    Doom-Slayer

    Joined:
    Jun 13, 2022
    Posts:
    3
    Yup, both are from "Flat Kit toon shading" and are Renderer Features you add to the "UniversalRenderPipelineAsset_Renderer". Settings don't seem to matter, it seems to be just the presence of either Renderer Feature causing it. Much appreciated!

    EDIT2 : So using Forward Rendering with the Flatkit Outline and/or the Flatkit Fog, its possible to Play with the errors in the Editor, and the errors only show up a single time in Play mode, and then don't repeat. Also as far as I can tell... it seems like Volumetric Lighting, and the Outline/Fog all work perfectly fine despite the errors shows up (in Editor/Play Mode)
     
    Last edited: Mar 12, 2023
    techsalad likes this.
  13. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    I bought the "Flat Kit: Toon Shading and Water" plugin and I managed to reproduce the same issue.

    After some investigation, I think the problem is caused by the Flat Kit plugin, because you can easily reproduce the issue without the Volumetric Light Beam plugin by simply adding a camera rendering to a depth Render Texture (in addition to Flatkit Renderer features of course):

    - Create a depth Render Texture
    Screenshot_63.png

    - Add a camera in your scene which outputs to the RT
    Screenshot_34.png

    And you'll get the same errors.
    I tried to update to more recent Unity versions, up to the latest (2022.2.10), but I still had the same errors.

    So maybe get it touch with the Flat Kit developer, because it looks like something in its Renderer features breaks a basic camera outputting to a depth RT...

    I hope it helps
    TS

    EDIT: I think I found a workaround, sending you a custom version via PM.
     
    Last edited: Mar 12, 2023
  14. Nanachi88

    Nanachi88

    Joined:
    Aug 10, 2022
    Posts:
    14
    I am working in mobile platform. Would adding noise increase a lot of performance cost? I have tested in by comparing the bacthes, setpass call, and FPS, the result is that no difference at all. It looks nice and too good to be true, but I am hesitating to use it.
     
  15. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey,
    Thank you for your message.
    The 3D Noise feature is really cheap, so you should be able to enable it without noticeable performance cost.
    The important thing to consider on mobile is to stick to SD beams. HD beams are unfortunately too costly to run on mobile.
    I hope it helps!
    TS
     
  16. Doom-Slayer

    Doom-Slayer

    Joined:
    Jun 13, 2022
    Posts:
    3
    Works perfectly! I pulled through the updated VLB plugin and loaded that in. I wasn't using the Flatkit specific Renderer, but I set my forward renderer with the Flatkit renderer features in index 0, and changed the VLB index setting to 1, and it works like a charm.

    I have put a comment to the Flatkit discord to raise the bug up, and will link to your forum post, so hopefully this won't show up in future for anyone else!
     
    techsalad likes this.
  17. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Glad to hear that, thanks a lot for your feedback!
    I'll publish this new feature to workaround issues with other plugin's renderer features in a future update.
    If you enjoy using the plugin and my support, please consider writing a short review on the store, it would be very appreciated! http://u3d.as/WQU#reviews
    Thanks :)
    TS
     
  18. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Hi, thanks for the scene you sent me, I've not looked at it yet but will once I get back to indoor lighting.

    I've found an effect I'm very happy with using HD beams for my street lights (thanks!), but unfortunately there are rendering issues when used with Amplify Impostors. White dots appear where the impostor and HD beam overlap in screen space - the beam does not need to hit the impostor. So if the impostor is far away and you look through the beam, the same effect occurs.

    For clarity, the tree is an Amplify Impostor. This is a flat mesh with only 12 verts.

    Any ideas what could cause this?

    I'm also posting in the Amplify Impostors forum, I'm not sure which side this is on. It would be great if these two assets could function together.

    https://forum.unity.com/threads/amplify-impostors-next-generation-billboards.539844/page-33 (for any users with the same problem to hopefully keep track of both talks).

    URP, 2021.3.20f1, Volumetric Light Beam 2.0.1, Amplify Impostors 0.9.8.3.
     

    Attached Files:

    Last edited: Mar 28, 2023
  19. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    I am not familiar with Amplify Impostors, but I guess they are using a transparent material. Can you check on which render queue they are drawn please?

    Volumetric Light Beams' render queue can be configured in the VLB config asset. By default HD Beams are rendered on render queue 3100.
    2023-03-29_09-32-50.png

    I would say you have to make sure the HD beams are rendered after the impostors, please make sure it's the case.

    EDIT: could you please record a video of the issue? It's quite hard to tell what's going on with a tiny screenshot :)

    Thanks
    TS
     
    Liam2349 likes this.
  20. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Hi, thanks for your response and sorry about the small screenshots, hopefully this is more helpful:


    I have now tried the rendering queue and it didn't change anything unfortunately. I believe Amplify Impostors uses real transparency.

    EDIT: I have found the same issue with SD beams, when looking through the beam geometry.
    EDIT: It does seem like it could be render queue related, because if I have the beam behind the impostor, the issue doesn't occur, but changing the queue position doesn't help.
     
    Last edited: Mar 29, 2023
  21. Liam2349

    Liam2349

    Joined:
    Mar 10, 2016
    Posts:
    78
    Hi everyone, techsalad asked me for a repro scene and it looks like this is an issue with Amplify Impostors. Similar rendering artifacts also occur without Volumetric Light Beam. I don't think there is any issue with Volumetric Light Beam. Thanks to techsalad for taking a look!
     
    techsalad likes this.
  22. Micuda

    Micuda

    Joined:
    Nov 11, 2016
    Posts:
    12
    Hello, thanks for the great asset!

    I have a question - In my game I am doing a raycast and setting the beam length according the resulting ray length(in script: lightBeam.fallOffEnd = raycastHit.distance). I would like to achieve behaviour, when the beam cone cap on the ending cone side has always the same diameter, no matter how far it is from the beam source.

    I tried to modify beam.spotAngle value in the runtime, again based on the raycast ray lenght (in script lightBeam.spotAngle = minSpotAngle + minMaxSpotAngleDiff*(raycastDist/maxRaycastDist)), but this is giving me incorrect result, as the cone cap is still changing size. Is there some simple way how I can make the cone cap size constant all the time?
     
  23. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,
    Thank you for your message. Yes I think it’s possible to achieve. I am currently not in front of my computer so can’t check the code. I’ll have a look asap and I’ll keep you posted :)
    Thanks!
     
  24. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    So I checked the code and it's already possible. You can use the "coneRadiusEnd" property to set the radius you want for the ending cap. It will compute the proper spot angle. It works for both SD and HD beams.

    Please let me know if it helps or if you need something else.
    Thanks!
     
    Micuda likes this.
  25. Micuda

    Micuda

    Joined:
    Nov 11, 2016
    Posts:
    12
    Thank you very much, works like a charm, my cone radius now remains constant!

    However, I am using Trigger Zone and I found out that trigger collider was not being updated together with beam mesh, (not even by calling "GenerateGeometry()" in Update), so I just made a work-around by calling TriggerZone "ComputeZone()" method each frame and now the collider size is changing as well. But it feels to me like a hack, so is there something better what I can do in order to make Trigger Zone's trigger being updated regularly?
     
    techsalad likes this.
  26. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey, I am happy it works :)

    Regarding the TriggerZone feature, it doesn't support realtime changes like stated in the documentation: https://saladgamer.com/vlb-doc/comp-triggerzone/#realtime-changes

    The reason is the performance: modifying the light beam shape in realtime is fine because the mesh geometry is not changed: all the changes are done on the GPU. But it's not possible to do that for the TriggerZone, the changes must be done on the CPU, meaning we have to recompute a mesh shape, which is kind of costly. That's why the plugin doesn't support it.

    However, if you don't recompute the TriggerZone of several beams at the same time, make sure to not call ComputeZone() each frame, and only when the beam shape has changed, it should be fine. So no it's not really a hack :)

    I hope it helps :)
    Thanks
     
    Micuda likes this.
  27. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    After upgrading to version 2.0.2 (having removed the older version from a project entirely and then extracting as directed), there were 4 errors caused by Assets/VolumetricLightBeam/Scripts/MaterialManager.cs lines 167, 168, 223 and 224: "error CS1503: Argument 3: cannot convert from 'UnityEngine.Rendering.BlendMode' to 'BlendMode'".

    Resolved by changing "BlendMode" on line 297 of MaterialManager.cs to "UnityEngine.Rendering.BlendMode".
     
  28. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey,
    Thanks for reporting.
    Which unity version are you using?
    I haven't encountered this compilation error...
    Thanks!
    TS
     
    adamgolden likes this.
  29. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    2022.2.17f1
     
    techsalad likes this.
  30. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,549
    I created a new project (3D URP) to confirm - it had no such issue, so it must be something in my project specifically that wasn't compatible for whatever reason (either another asset or my own code somewhere). The simple fix mentioned solved it for me anyway [and whoever else it might happen to, if anyone] so.. *shrug* :)
     
  31. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Thanks a lot for the details!
    I may implement your change anyway, it won't hurt :)
    Cheers!
    TS
     
    adamgolden likes this.
  32. Verne33

    Verne33

    Joined:
    Apr 12, 2020
    Posts:
    32
    Hi. First of all, want to say I'm beyond happy with the asset, the attention to detail in the docs and component is first class!

    I was experimenting using these lights as laser light shows in VR, like nightclub EDM show style, however I've found they are a bit blurry (maybe transparent is a better word) for that use-case. Was able to get it a bit more laser-like tweaking parameters like traditional transparency, boosting side thickness, but not perfect.

    Basically was wondering if you agree VLB is not good for this laser use-case, or else if you had recommendations for how to achieve that look, or recommendations for other assets. Thanks and I look forward to future releases on the store!
     
    techsalad likes this.
  33. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    Thank you very much for your message :)

    Yes you can totally achieve lasers with VLB. I don't know how you want to make them look, but some games like Hexagroove on the Nintendo Switch have achieve results like that:
    hexagroove1.jpg

    If you want lasers more like in Splinter Cell, I wouldn't say the plugin has been designed for this use-case in mind, but it's possible. Here is a quick test I did:
    Screenshot_65.png

    If you don't want any opacity fall-off along the distance, put the Attenuation Equation to Linear and the Attenuation Start Distance to the maximum value:
    Screenshot_66.png

    You'll also have to switch the Shader Accuracy property to High, so the falloff is computed per pixel (so it would appear only on the last pixels of the beam). Otherwise it's computed per vertex, and since the tessellation of the beam geometry is pretty low, you'll see some falloff anyway.

    I hope it helps!
    Thanks :)
     
    Verne33 likes this.
  34. code-and-design-inc

    code-and-design-inc

    Joined:
    Oct 29, 2016
    Posts:
    13
    hello.
    Using lights in unity2022.3.3f1 makes the lights disappear in the game tab if I press Play. After that, unless you change the layer of the light object, it will not be displayed except during play.

     
  35. code-and-design-inc

    code-and-design-inc

    Joined:
    Oct 29, 2016
    Posts:
    13
  36. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    By default the Volumetric Light Beam geometry is rendered on the "Transparent FX" layer:
    Screenshot_1.png

    This can be overridden here btw: http://saladgamer.com/vlb-doc/config/#override-layer

    Can you please make sure your game camera is rendering this layer in its Culling Mask?
    Screenshot_72.png

    Thanks
    TS
     
    code-and-design-inc likes this.
  37. Nanachi88

    Nanachi88

    Joined:
    Aug 10, 2022
    Posts:
    14
    upload_2023-7-17_18-10-22.png

    When debugging my mobile game, I got this MeshSkewing error, any suggestion?
     
  38. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hey, I never encountered this error.

    You have this error in editor or when executing your standalone build on your mobile device (or both)?

    Could you please provide me more info?
    • Unity version?
    • Built-in Pipeline, URP or HDRP?
    • Type of mobile device?
    Thanks
    TS
     
  39. Yothuba

    Yothuba

    Joined:
    Oct 4, 2019
    Posts:
    21
    Hello, I'm having a problem with my cookie scrolling.
    I have a problem with cookie scrolling.
    I have created a simple script that gets the cookieHD from an external script and adds up the scroll, but the cookie does not rotate on the screen. Is this a specification?

    Code (CSharp):
    1.     [SerializeField] float speed = 1f;
    2.     private VolumetricCookieHD cookieHD;
    3.  
    4.     private float timer = 0f;
    5.     // Start is called before the first frame update
    6.     void Start()
    7.     {
    8.         cookieHD = GetComponent<VolumetricCookieHD>();
    9.     }
    10.  
    11.     // Update is called once per frame
    12.     void Update()
    13.     {
    14.         timer += Time.deltaTime * speed;
    15.         cookieHD.rotation = timer;
    16.     }
     
  40. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    Thank you for your message and sorry for the issue you encounter.

    It's supposed to work like you do.
    I tried your script and it rotates the cookie properly:
    Animation2.gif


    What happens if you try to manually change the Rotation property at runtime (without the script)?
    Screenshot_74.png

    Thanks
    TS
     
  41. Yothuba

    Yothuba

    Joined:
    Oct 4, 2019
    Posts:
    21
    Thank you.
    In my environment, manual changes are reflected.
    I will verify in other environments.
    Can you tell me what version of unity you have?
     
  42. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    I was using 2023.1.0, but tried with various other versions too.
    What version are you using?
    If you select the beam being modified by your script during playtime, do you see the « Rotation » property changes?
    Thanks!
    TS
     
  43. virtual-avex

    virtual-avex

    Joined:
    Apr 4, 2021
    Posts:
    1
    Sorry for the late reply.
    I tried it in the new environment and it worked fine.
    It seems that there was a problem with the project...

    Also, another question... are you planning to add a Assembly Definition
    to the assets as standard?
     
  44. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    No worries and thank you for the feedback, I’m glad it’s working now!

    The plugin used to have asmdef included until version 2.0.1. But I had to remove them when I decided to ship the plugin files through unity package via the installer system to workaround file’s renaming issues. So no I don’t plan to add them again…

    Thanks
    TS
     
  45. hoyoyo80

    hoyoyo80

    Joined:
    Jan 31, 2018
    Posts:
    58
    Hi. Im test using SD but the emitter/light source is showing it shape.can i hide this?Thanks
     
  46. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,
    I am not sure to understand what you mean by "showing it shape".
    Could you please provide me a screenshot highlighting the issue you encounter?
    Thanks
     
  47. McKinleyMassacre

    McKinleyMassacre

    Joined:
    Dec 8, 2018
    Posts:
    2

    I too am using FlatKit and getting this error like crazy. Might I ask for that workaround as well?
     
  48. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Hello,

    The "workaround" has been published in version 2.0.2 through the Custom renderer index for Depth Camera feature: http://saladgamer.com/vlb-doc/config/#custom-renderer-index-for-depth-camera

    So here is what you need to do:
    - In your URP asset, add the "default forward renderer" in addition to the "flat kit renderer". Note the index of the default renderer (1 in the screenshot)
    Screenshot_39.png

    - Go in the VLB plugin config and set the renderer index (1) this new property:
    Screenshot_40.png

    - Press play to force refresh the volumetric ligth beams, and the errors should be gone

    Please let me know if it works!
    Thanks :)
     
  49. McKinleyMassacre

    McKinleyMassacre

    Joined:
    Dec 8, 2018
    Posts:
    2
    That did work, thank you so much!!
     
    techsalad likes this.
  50. techsalad

    techsalad

    Joined:
    Oct 9, 2017
    Posts:
    376
    Glad to hear that! Thank you for the feedback :)