Search Unity

Corgi God Rays - Volumetric Lighting for URP [RELEASED!]

Discussion in 'Assets and Asset Store' started by funkyCoty, Apr 11, 2022.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Link!
    Asset store url: https://assetstore.unity.com/packages/slug/218231
    Demo: https://drive.google.com/file/d/1kex3Pv74I4GoAx0AGoOmHZB5T7ga_2_r/view?usp=sharing

    What's this?!

    A simple and fast volumetric lighting solution for URP!

    Features!!
    Quickly and easily add in volumetric lighting for URP.

    Features
    • Very simple drop in. Add RenderFeature and add Post Process Volume Component and BAM, immediately have God Rays that you can edit in real time.
    • Highly optimized volumetric lighting system, with some options for making it even faster if necessary.
    • Works with VR and even Single Pass Instanced rendering (SPI)
    • MSAA compatible

    Documentation here: https://docs.google.com/document/d/1eOMmk70YQnLXw6-K4MffmFDoWbW-PXgIY3vk8eeRMPs

    Pics:
    Unity_9cEJRTCrGm.png Unity_x6tnIYRxjY.png


    Need help?
    Just email me: coty@wanderingcorgi.com
     
    Last edited: Apr 17, 2022
    Claytonious likes this.
  2. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    The first release is now live! If you run into any problems, please email or DM me! coty@wanderingcorgi.com

    Please include your Unity version and URP version.
     
    Last edited: May 5, 2022
  3. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Just pushed the first update!

    edit: also, I've added a demo to the original post
     
    Last edited: Apr 17, 2022
  4. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Hi, I'm considering purchasing this.
    Does it only work with the scene's directional light? Or will it allow for volumetric spotlight beams and point lights as well?
    Thanks!
     
  5. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    It supports all of the light types URP supports. So it should work with Directional, Spot, and Point Light modes. That being said, it is also limited by URP to only 8 lights at a time, until I can find a work around.
     
  6. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Thats amazing! Would you be able to provide more screenshots or examples of it working for Spot light beams and Point lights?
    I'm trying to weigh my options for volumetric effects because there are so many on the market, lol. Is this screen space only? Any performance issues?
    Thanks!
     
  7. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    The second screenshot in the OP is a point light, for reference. Yes, things are done in screen space. It just samples the shadow maps generated by unity. There are a bunch of performance sliders/toggles in the RenderFeature settings.

    The additional light stuff is handled in the same shader as the directional light, so its still just 1 draw call to compute the volumetric texture. The only cost is sampling the shadowmap on the gpu. If your target platform is mobile, I'd still recommend disabling additional light support (which is just a single toggle in the settings).
     
    Last edited: May 5, 2022
  8. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Super cool, I'm glad someone has finally created an all-in-one solution that doesn't require additional meshes on lights.
    I'll be giving it a try as soon as I can! Thanks for the info!
     
  9. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Yeah I've used other solutions in the past, I was always annoyed by the complicated setups and general unnecessary slowness on the cpu side. I tried to keep things as simple as possible while still doing what you really want it to do.

    If you find any issues, please reach out either here, dm me, or email me at coty@wanderingcorgi.com so I can help resolve anything that pops up. It's an early release so there's bound to be some quirks.
     
    Claytonious and JudahMantell like this.
  10. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    Cool, I look forward to giving it a try!
     
    Last edited: Apr 26, 2022
  11. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Just pushed a small update. Backported the plugin to also work on URP 11.

     
  12. sunboxgames

    sunboxgames

    Joined:
    Jul 30, 2021
    Posts:
    5
    Hi, loving this volumetric solution! It is just what we need in our project! :)

    Asset works great in Unity editor but I have an issue building the project with this asset. I am using Unity 2022.1.0.b6 with URP version 13.1.5 and there is a problem compiling the shader with this URP version:

    Shader error in 'Hidden/CorgiGodRays/ApplyGodRays': undeclared identifier 'unity_StereoEyeIndex' at Games/the-game/Library/PackageCache/com.unity.render-pipelines.core@13.1.5/ShaderLibrary/SpaceTransforms.hlsl(33) (on d3d11)

    Shader error in 'Hidden/CorgiGodRays/ScreenSpaceGodRays': undeclared identifier 'unity_StereoEyeIndex' at Games/the-game/Library/PackageCache/com.unity.render-pipelines.core@13.1.5/ShaderLibrary/SpaceTransforms.hlsl(33) (on d3d11)


    Thanks for any advice or an update.

    Domen
     
  13. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Are you building for a VR title? That error is saying the SPI stuff isnt available. As a work around until I can figure out why it is being stripped, you can open the data file in your project and uncheck "shader stripping" in the godrays data file settings.
     
  14. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Just pushed an update!

     
  15. sunboxgames

    sunboxgames

    Joined:
    Jul 30, 2021
    Posts:
    5
    The shader stripping was unchecked by default with the same result. The latest update fixed all build errors. Thanks for your quick response!

    Domen
     
    funkyCoty likes this.
  16. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Ah yeah sorry, I forgot to mention that somebody emailed me with more info on the same error you were getting. I managed to replicate it and thus fix it, so it should be good to go in the latest version. It was just a problem with relying on something that was only in a particular URP version. It's more version agnostic now!
     
  17. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
     
  18. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Another small update!
     
  19. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Update incoming! This one has a lot of stuff requested by a few users recently.

     
  20. Wujus

    Wujus

    Joined:
    Jul 22, 2018
    Posts:
    1
    Hi, I'm thinking of buying your asset. Does it work with URP deferred renderer and if so, does the 8 lights limit still apply?
     
  21. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Is there a demo where I can fly around? Would like to asses the quality in other situations. First person camera, Large distant objects, Top-down, Flight Sim, etc.
     
  22. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    I haven't tried the deferred renderer yet, but it probably does work. I'll try it out later and let you know. As for the 8 light limit, that actually does not apply to my plugin (anymore). The godrays have an internal limit of 128 lights, but this is arbitrary and could be raised if requested.
     
  23. eejitb

    eejitb

    Joined:
    Apr 7, 2014
    Posts:
    6
    @funkyCoty
    Hi - adding the RenderFeature turns on a default god ray on all scenes, regardless of whether that scene contains a volume or not. Is there a way around this, so only scenes that have any god rays are ones where a volume has been manually added?
     
  24. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    I may be wrong, but I believe Unity/URP does not currently provide a way for developers to easily query if a volume system has a particular volume component. The way developers query the stack it always returns a volume with some default values. So, I think your best bet for now is to simply add it to all your volumes and use the overrides to turn the settings down to 0.

    I'll try to improve this in a future version so that if no volumes have settings for it it'll just be off by default.
     
  25. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Update just pushed to the asset store!
     
  26. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
  27. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Trying to build to quest 2 using Vulkan, URP 12.1.6, Unity version 2021.3.14, and getting this error. When I double-click the error it goes to line 82 in "Hidden/CorgiGodRays/ApplyGodRays" shader. Any help would be great.

    Shader error in 'Hidden/CorgiGodRays/ApplyGodRays': 'Sample': no matching 3 parameter intrinsic method; Possible intrinsic methods are: Texture2DArray<float4>.Sample(SamplerState, float3|half3|min10float3|min16float3) Texture2DArray<float4>.Sample(SamplerState, float3|half3|min10float3|min16float3, int2) Texture2DArray<float4>.Sample(SamplerState, float3|half3|min10float3|min16float3, int2, float1|half1|min10float1|min16float1) Texture2DArray<float4>.Sample(SamplerState, float3|half3|min10float3|min16float3, int2, float1|half1|min10float1|min16float1, out uint status) at line 82 (on vulkan)
    Compiling Subshader: 0, Pass: , Vertex program with DEPTH_AWARE_UPSAMPLE GODRAYS_ADDITIVE_LIGHTS GODRAYS_ENCODE_LIGHT_COLOR GODRAYS_MAIN_LIGHT INSTANCING_ON LIGHTMAP_ON STEREO_MULTIVIEW_ON _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS _LIGHT_COOKIES _MAIN_LIGHT_SHADOWS_CASCADE _SHADOWS_SOFT
    Platform defines: SHADER_API_MOBILE UNITY_ASTC_NORMALMAP_ENCODING UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_NO_CUBEMAP_ARRAY UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_RGBM UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF3
    Disabled keywords: DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON LIGHTMAP_SHADOW_MIXING SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF2 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_VIRTUAL_TEXTURING _ADDITIONAL_LIGHTS_VERTEX _CLUSTERED_RENDERING _MAIN_LIGHT_SHADOWS
     
  28. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    You're trying to run a volumetric lighting plugin on Quest 2? Lol sorry, even if I resolved this error for quest I think you'd find that it would be unacceptably slow. You cannot even have shadows in most quest games, let alone trace through them in real time on quest for volumetrics.
     
  29. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    This doesn't seem to be working in Unity 2022.2.11
     
  30. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Thanks for letting me know. Do you have any errors on hand? I'll look into it this weekend hopefully.
     
  31. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Hey, I just sat down to take a look at this, but it seems to be okay in Unity 2022.2.11f1, for me? If you have any errors please share them with me here, and I'll take a closer look as soon as possible.

    Unity_le497GrDDD.png
     
  32. michalpiatek

    michalpiatek

    Joined:
    Feb 26, 2021
    Posts:
    81
    Hey @funkyCoty . I've just purchased the package. There are several obsolete functions being used, mostly I have resolved but the final one I don't know how to proceed with is this one:
    Code (CSharp):
    1. Assets\CorgiGodRays\Scripts\GodRaysRenderPass.cs(261,30): error CS0618: 'RenderingUtils.fullscreenMesh' is obsolete: 'Use Blitter.BlitCameraTexture instead of CommandBuffer.DrawMesh(fullscreenMesh, ...)'
    This appears several times after importing the project, all in GodRaysRenderPass.cs
    I'm on Unity 2022.2.18f1 URP 14.07

    My project is setup in a way where usage of obsolete methods won't let other scripts compile, so I can't really use the package. Do you have a workaround I could apply or a new version cooking up? If so when do you expect it to be available? Cheers!
     
  33. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Hey. I'll take a look this weekend. I really wish Unity would quit pushing breaking changes every version, haha.
     
  34. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
    Got a chance tonight to look at this. I went ahead and pushed a fix for Unity 2022+
     
    michalpiatek likes this.
  35. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727
     
  36. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    727