Search Unity

True Volumetric Lights (Now Open Source)

Discussion in 'Shaders' started by Michal_, Mar 10, 2016.

  1. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    Stuff about the Adam demo is where you will find stuff about their volumetric lighting solution.

    eg:

    http://unity3d.com/pages/adam

     
    one_one likes this.
  2. dreamerflyer

    dreamerflyer

    Joined:
    Jun 11, 2011
    Posts:
    927
    bug.jpg Maybe this is shadow bug?
     
  3. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Love the stuff, however, found some interesting glitch, half of the screen is showing the effect half do not. And when I twik resolutions sometimes it is better. VL bug report.jpg
     
  4. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,457
    They do not seem like they will release this. I mean they have had volumetric lighting in development for a while. Release half broken for U4 and then stop supporting. So highly doubt it will be released anytime soon. Would be a beta cinematic effect on the roadmap.
     
  5. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    Of course they are going to release it.

    It says so on the Adam page itself:

    Exactly when we will get them is another matter. Sometime this summer is highly likely though.
     
  6. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,457
    You are right. Did not notice that. Cool!

    Only thing is I thought Adam part 2 and the extensions were going to be released in Unite Europe.
     
  7. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    I'm not sure what you mean. It looks correct to me.
    Never seen anything like it. I'll take a look if you manage to create repro project.
     
  8. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Actually that looks very similar to the problem I had at first, and which still occurs at startup for a second. Not 100% what made it go away in my case though.



    I decided to work on a system that would handle "Light LOD's" in an attempt to claw back some of the performance lost to the volumetric light AND lots of lights in the scene using shadows. Kinda premature optimization at the current point in time, but the FPS got really low unless I turn of the SSAA (which is also a performance hog) and live with jittery aliasing. As I HATE having to look at aliased geometry (even when only prototyping), and I will have to do this optimization anyway, I might as well do it now.

    So I decided to use a 3 phase approach:

    Phase 1 is to add a script to all lights that will fade out aspects of the light at certain distances (to the camera) set per light, and switches stuff off at a slightly higher distance.
    What I want the script to do is first fade out shadows and switch them off, then fade out the volumetricLight script and switch it off, then fade out the actual light and switch it off.
    As I can tweak the distance settings per light I can tune this to be as hard to notice as possible. At a certain range, the light not having shadows is hardly noticable for most lights, so I can be more aggressive here, but for some I might want to keep shadows longer (big, moving background elements affected by it for example).
    This already partially works and gives me a nice FPS boost when I zoom out the view, or move away from lighting hotspots.

    Phase 2 is to add another, global script which will control the scripts written in Phase 1, and holds some thresholds about how many lights can cast shadows or use volumetric light at any given time, and then switches the Light control scripts for each light to use that or not depending on their size in the current scene.
    That should allow me to limit the impact of lighting hotspots with as minimal visible impact as possible.

    Phase 3
    is adding fake volumetricLight Volumes, meshes with special transparent shaders. They will replace the true VolumetricLight Volumes as soon as these get "culled". They will not be free, being transparent shaders, but given the geometry should be rather low poly, and come 5.4 hopefully could be instanced, should be cheaper than the true volumetric light.
    Idea is to make the shader for these match the look of the volumetric lighting as closely as possible, so I can fade out the volumetric lighting just after fading out the shadows... they might not be quite as good looking as true volumetric light, but they should still give the look of volumetric light in the distance.
    Also, for the lights that go their actual lighting culled in the distance, I will leave this fake volume active... hard to notice something actually being lit by these lights most probably, the absence of a lightbeam might still be noticable.

    For some lights, I might actually forgoe real light (and thus also volumetric lighting)... for example searchlights aimed at the sky.
    The fake Volumes will make it look like these are actually emitting light.


    What do you think of my plan? I was a little bit concerned at first because I have now quite a lot of testing for lights to be culled or faded back in going on every frame, but compared to the CPU cost of shadowmapping, or the GPU cost of actually rendering the shadows and the volumetric lights this seems to be negligible.
     
  9. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    @yc960, nevermind, I found it. The way I render full screen quad for directional light is little unfortunate. It can get clipped. I moved it closer to the camera as a hot fix.
     
  10. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Sounds good to me. Probably a good approach in general. You would benefit from this even if you start using different volumetric fog technology. Managing visibility of a few dozen lights (or how many you have) is hardly going to be a bottleneck. And you probably don't have to do it every frame either.
    I would also try to drastically reduce sample count for lights with shadows turned off and disable volumetric noise with distance. That noise can be pretty expensive.
     
  11. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Thanks for your suggestions... will give it a try when further working on the system.

    Well, I hoped I could manage more lights in a bigger level this way. I might go one step further and spatially partition the lights, with triggers to activate/deactivate a light partition. All the lights outside the current partition (dunno, maybe 500mx500m Area?) are off, and their light control script only become active when the camera moves into the partition. Given that I will most likely need the spatial partitions anyway later (for AI LOD and stuff like that), I might just create this for the lights for now.
    Now that I mention it, maybe using triggers would be a good way to cut down on the light control scripts eating too much resources? By deactivating the light control script after a certain trigger has been left (don't know if working with so many triggers is REALLY more efficient than running a couple of scripts doing some Vector.Distance calls and simple Math every frame).
    I could go with the inverse and have a large trigger on the camera itself, that would check all the light colliders and activate the control script.
    Of course, I could make the scripts run at a reduced update rate the further away the camera is.... so many options.

    Lets see first how the simple, unpartitioned and triggerless version behaves in my small prototype showcase scene.


    Didn't had the chance yet to watch the Adam short... any indication if Unitys volumetric fog approach is any good?
     
    Last edited: Jun 15, 2016
  12. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    In their talk, they mentioned voxel based approach to volumetric lighting, however the fact they ran the scene at 1440p on 980 card is encouraging, which means they managed to curb the cost somehow.
     
  13. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    The 'Bart Wronski volumetric fog' method is a technique that interested a lot of people because it looks good and is practical on modern graphics cards. Still not a dead cheap effect, but at least practical for realtime applications in some scenarios. And as far as I'm aware this Unity stuff is an implementation of Bart Wronskis technique.
     
  14. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    But beyond that there are many questions. I'm not sure what different types of lights it works with for a start. (emphasis in the Adam scene was on the new area lights). I'm expecting it to be very useful in some scenarios but that there will still be a place for a handful of other volumetric lighting/fog systems for Unity.
     
  15. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    It is supposedly the same technique as the one introduced in Assassin's Creed 4 (and used in many other games since then). The paper is available online or in GPU Pro 6 book. It is a more general approach but both techniques has their advantages and disadvantages.

    "Classic" raymarching approach (this, Killzone etc.) - volumetric effect is computed and immediatelly stored in 2d texture that is later applied to the final image.
    • You can render at native resolution and get best possible quality with crisp edges.
    • Keeps quality even for distant lights
    • Works with pretty much any shadow technique
    • Doesn't support transparent objects out of the box
    • Trading quality for performance is problematic. You can render at lower resolutions but you have to deal with all the "mixed resolution" rendering problems (halos, bleeding, etc.)
    • Probably more expensive per light but can give you better quality
    Voxel based approach (Unity?, Assassin's Creed, Frostbite etc.) - volumetric effect is computed for "every" point in front of the camera. It is stored in 3d texture for future use.
    • You must render at very low resolution to make it practical. No crisp edges or shadow details. For example, AC4 used 160x90x64 resolution. Roughly 1 000 000 voxels. It would require hundreds of millions of voxels to match the highest quality of the classic technique.
    • Probably not very practical for long drawing distances because of the limited number of depth slices. The range for AC4 was only 100 meters.
    • Shouldn't work very well with current Unity shadows. The shadows have high frequency information and the voxel resolution is very low. That should lead to under-sampling artifacts, aliasing, flickering etc. AC4 used blurred exponential shadows to remove high frequency signal. I'm curious what Unity will do here. Maybe just a temporal super-sampling?
    • Works with transparent object. 3d texture stores light information for every point so you can easily apply this to transparent objects.
    • It is very simple to trade quality for performance. You simply change number of voxels. 3d texture filtering will take care of the rest.
    Whatever they do, I doubt it will work for everybody. There is so many different projects out there. I'm curious if they make it integral part of Unity or keep it as a separate asset.
     
    Baldinoboy and elbows like this.
  16. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    If that is the case, I will stick with your solutions. And one more thing, how to make the ray appear more distinct in directional lights? Currently it is mostly hit and miss for me. Shadow dist 1k. 1.jpg
     
  17. ATLAS-INTERACTIVE

    ATLAS-INTERACTIVE

    Joined:
    Mar 3, 2014
    Posts:
    1,351
    @Michal_ I have a big issue with a new project.

    Whenever I attach the VolumetricLight to a spotlight, and the Renderer script to the camera, I get this:
    screen_1920x1080_2016-06-18_14-24-41.png
    Which gets gradually brighter:
    screen_1920x1080_2016-06-18_14-25-07.png

    Does this not work with spotlights?
     
  18. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    604
    Really well done! The atmospheric effect is much better than uSky, which I unfortunately bought before I discovered this. Proper 10/10. The only issue I see right now is that it only works with Defered rendering.
     
  19. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Did you look at the readme and the sample scenes? There are some good examples. Try to increase scattering coefficient and tweak the MieG parameter to your liking.
    It usually does. I don't know what your problem is. One of the sample scenes is using spotlight. Does that work for you? Are you using HDR + deferred? Any errors in the console?
    Thank you. Better atmospheric scattering is actually next on my list. As for the deferred requirement, I only do what I find interesting and going back to forward rendering isn't one of those things I'm afraid. I know some people would like to see this as a paid asset to get proper support but I'm a full time game developer already, so that's a no go.
     
  20. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Update time. I played with the atmospheric scattering some more I found out that it doesn't work very well with the current system. Rendering the sky in half resolution + blur degrades the quality a lot. Especially at sunset/sunrise. I'll have to use different optimization strategy. And since both systems now don't have much in common, I made atmospheric scattering a separate project. I'll deal with their compatibility later.
    Atmospheric scattering is still far from complete. Kind of a brute force implementation atm. No light shafts. You can try it, it is on GitHub. Use at your own risk. It can currently control sky color, atmospheric fog, direct and ambient light color/intensity. I'll give more information as I go.
    I'll make separate thread when it is in better shape. Take it as a preview for now.
     
    Crossway, moure and Elecman like this.
  21. Beinscheibe

    Beinscheibe

    Joined:
    Sep 24, 2013
    Posts:
    78
    Hey, the atmospheric scattering looks great.

    But I found another little bug concerning Directional Lights. I also disabled occlusion culling to check that it's not the problem.
    I created a short video to demonstrate what's happening. In certain camera angles, it looks like the whole screen get's tinted with the light color.

    Do you know what might cause this?

     
  22. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Somebody here had a similar issue a while back. It had something to do with cascades. Can you try it with only one shadow cascade or try to tweak the cascade distances?
     
  23. Beinscheibe

    Beinscheibe

    Joined:
    Sep 24, 2013
    Posts:
    78
    Thanks for the info. Disabling shadow cascades fixes the problem. I could also lower the first cascade if using two or four, so this would also work. ;D
     
  24. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,350
    The atmospheric scattering looks stunning. I will be definitely interested in this. Make sure the sun is a true HDR object so it works well with bloom. So far the only atmospheric scattering package which looks realistic is uSky pro 2.0, but that doesn't have an HDR sun either.

    Edit:
    Also make sure that it works well with regular (height) fog. That is something uSky pro 2.0 currently doesn't do either.

    Some things I noticed with a quick look:
    -The sun height above the horizon should change as the camera height changes.
    -The sun disappears if the camera is very high.
    -The sun is not an HDR object.
     
    Last edited: Jun 20, 2016
  25. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Just a quick update:

    I have repurposed an old lieghtbeam shader from a discontinued asset no longer sold through the asset store for my fake volumetric light. Had to hack it because the way the lighting was "calculated" was just the opposite from how this system does it (with this volumetric lighting, the volumetric lighting /rays get more prominent the directer you look into a spotlight. With the old lightbeam shader, the lightbeam gets more prominent when seen from the side, adn fades to almost invisible when looked at from the front).

    I am no shader guru, so it was a hacky trial-and-error job resulting in a usable, yet far from perfect result. Expecially the rays when looked at from behind would become too visible, unlike how the volumetric light script would show it. So I added a C# script that manages the shader alpha to become invisible when looked at from behind (not the most efficient way to do it I guess, will have to sit down, learn more about shader programming and move this to the shader I guess).

    In the end I am 75% there, I have lightrays that do not use the volumetric light afar, and then gradually get blended over to volumetric light as the camera gets closer. Still not perfect (the shader cannot really replicate the soft look of the volumetric light script at the standart settings, and the "leaking light" around the light rays themselves (hard to describe) is of course not replicated... might use another mesh object to achieve that, give the light more volume when looked at from the front.

    This, and all the other tweakings done before (turning off shadows for less important lights for example) has allowed me to claw back a LOT of FPS.... framerate is pretty stable now, which is good.
    I guess the big culprit was the realtime shadows on too many lights though. If only this could be done per scene, and not per light.... :/
     
  26. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    im a sucker for atmosphere and as others have came closest to the look i was after for years.
    immensely thankful for this bit of tech.
    please consider a donate button. if there was ever a reason for one - this is it.
     
  27. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    Very nice. I tried it very briefly and it seems very nice already. If you can make lightshafts work with it at some point then ooh!

    Last night I was briefly trying to get the Atmospheric Scattering Blacksmith project from Unity working to remind myself what that atmospheric scattering was like in comparison. For reasons I haven't established yet I didn't get it working properly, but it did occur to me that the sample scene they include in the project might be useful for testing both of your projects. (it has skyscrapers as well as mountains).

    I'm afraid I'd also like to report a couple of typos in your atmospheric scattering project. The github project name has a missing h. And the following typo is in the readme: AtmosphericSactteringRenderer
     
  28. SimStm

    SimStm

    Joined:
    May 24, 2013
    Posts:
    44
    First of all, excellent work on this. I made some interesting tests in some of my scenes and it's absolutely gorgeous.

    But I'm having some weird problem in one of my scenes (where I pretend to use this)

    I'm using Deftly to manage my character in a top-down game. In my "flashlight" prefab I have a spotlight who is the light source from my object. When I apply the Volumetric Lights script in this spotlight, everything works like intended. But, when I attach my flashlight prefab to my Deftly Character (the flashlight works like a weapon in the Deftly's weapon manager) and play the game, EVERY LIGHT who uses the Volumetric Light script works like intended, and only the spotlight FROM MY INSTANTIATED PREFAB doesn't work.

    Another strange thing is that if I drag and drop the prefab into my scene, the volumetric light works perfectly, so it seems that the instantiated prefab (who is a Clone from the original flashlight prefab) just doesn't generate the volumetric light effects correctly.

    I was wondering if you think this bug is some way caused by the fact that the prefab is actually instantiated via script (cloned/instantiated prefab), and if there's a way to (maybe) "manually generate" the volumetric lights via script or something like that in runtime. I'm looking where the "weapon" is instantiated in Deftly scripts so maybe I can figure out where to start.

    Here is some screenshots to show what is happening here...

    In-game with the Prefab Instantiated by Deftly:


    Script setting in my scene:


    ---------------------------------
    Drag and dropping the original prefab into the scene (In-game):


    Script setting (exactly the same as the instantiated prefab) in my project:
     
  29. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    392
    @Michal_ This is really nice bro any plans to get this working in unity 5.4 VR?
     
  30. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Thank you guys. Sometimes it is your positive feedback that keeps me going. Edit: A friend told me it sounds like I'm going to kill myself. That is not what I meant. I meant that it keeps me working on open source projects.

    @Elecman
    That's what I call a makeshift sun. I'll make a better one or at least give you option to turn it off and use your own.

    @gian-reto alig
    Sounds good. Shadows will be always expensive, there no way around that. Send me a screenshot when you are ready.

    @crackfox
    I was asked about the donate button before and I haven't decided yet. But it really feels great when people want to give you money even though they don't have to.

    @elbows
    Thanks for the typos. I'll fix them. It looks like a spell checker is a must for me.
    I didn't really try the blacksmith demo apart from "stealing" the assets for my demo. But I read the blog post back in the day. If I remember correctly then their solution can't render sky. They are using static skyboxes and atmospheric scattering is used only for fog and light shafts. They also focused on artistic control. Their solution isn't physically based. I'm going for the opposite - physically based atmosphere with limited user control.

    @SimStm
    Nothing comes to mind. I'll take a look at the code when I have time. What happens if you disable/enable the light? I'm not familiar with Deftly, does it do something special or simply calling Instantiate(Prefab)?

    @punk
    5.4 yes but currently no plans for VR. I don't have a VR kit and I don't plan to buy one.
     
    Last edited: Jun 23, 2016
  31. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    392
    Fair enough ;) great job tho as is
     
  32. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Yes, sadly.... because shadows are really needed for grounding objects in the scene. I wish I was enough of a shader / low level tech guru to actually try to come up with a better way to handle shadows from multiple lights... but then, I would most probably have no time anymore to work on my prototype.

    Will post Screenies, but first want to improve the lightbeams more.... currently they look good, until you look at them from the front... the geometry is a hollom cone, so of course the effect is not that great from the front (which is most probably why the original implementation was fading them out when looking at them from the front). Also, they lack some of the softness of your volumetric lights. Must sit down again and analyze the shader code some more.


    Something I have noticed with your volumetric lights is that for spotlights, I get quite a lot of the "lightray" effects when looking at them from the front... but when turning the view so I see them from the side, there is no longer a "lightray" (or "lightbeam") effect...
    Is this a limitation of the technique used, or has it to do with my settings? Lights are not that strong though, could also be that my settings are artificaly boosting the effect when looking from the front.

    I'll create a stronger, "searchlight" like spotlight in my scene to test (forgot this morning, will do that tomorrow), but just something I noticed (because I had to adjust the lightbeam shader, who created an opposite effect, just for that).


    Oh, and I second that call for a donate button. Your Volumetric Light System is far better than I hoped from an Opensource project (and is a great thing to have no matter if Unity just presented their own implementation... choice is always a goodthing), so I would gladly donate something.
     
  33. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    1. MieG parameter is used in Henyey-Greenstein phase function to control amount of light scattered based on light direction. Set it to 0 and you'll get same amount of scattered light for every direction.
    2. Also if you have a thin spot light with long range then it will be more visible from the front than from the side. That's because "view rays" travel longer distance in the illuminated area and more light is scattered towards camera if you look from the front.
     
  34. gian-reto-alig

    gian-reto-alig

    Joined:
    Apr 30, 2013
    Posts:
    756
    Ah, that explains a lot... I think I might be using a way to high MieG setting. I'll give it a try


    Thanks a lot for your answer

    Gian-Reto
     
  35. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,490
    Ah I didnt realise you had already borrowed some blacksmith demoscene assets when I wrote my post.

    My vague memory of trying their blacksmith atmospheric scattering when it first came out was that performance wasnt great. I only tried it again now because I wanted to see if it still worked and what the lightrays looked like. But I couldnt get the lightrays bit to work with modern versions of Unity and I doubt I'll waste much time investigating why.

    I assume you'd like to get lightrays working with your solution at some point?
     
  36. punk

    punk

    Joined:
    Jun 28, 2013
    Posts:
    392


    @Michal_ thought I'd post a pic, I'm loving this, it really add's a lot of atmosphere - thanks so much for sharing
     
    Michal_, Martin_H and hopeful like this.
  37. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Yeah, everything in the original demo and everything I put on GitHub is from the Blacksmith demo. I hope it is ok, I didn't bother to read the licence...
    I still want to add light shafts support but it will take longer than expected. As I said before I can't use the same tech as before.
    I also encountered several other problems that are slowing me down. For example, it looks like I can't create 3d texture with half/float pixel format (or Alpha8, that would speed up volumetric noise). I can create 3d render texture with float format but it looks like I can't render into it slice by slice. I didn't try to bind entire 3d render texture and use geometry shader to choose the depth slice yet. Maybe that will work? I will have to use compute shader otherwise and limit it to Win+DX11 for no apparent reason. Sorry, rant over :) It just feels like all I'm doing lately is finding workarounds to Unity problems.
     
    moure and yc960 like this.
  38. yc960

    yc960

    Joined:
    Apr 30, 2015
    Posts:
    228
    Agreed, if not for the great community, I would have switched to Unreal/Crysis/Lumber yard in an instant.
     
    Ghosthowl and Michal_ like this.
  39. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    hi michal,

    atmospheric fog looks stunning. its really a milestone.
    is it viable to use both of the system simultaneously?

    btw if propping up a donation thing is to cumbersome, you can maybe put up your amazon wishlist or something similar.
    im sure alot of people here would participate.

    thanks again for the fantastic tech.
     
  40. ArchoTek

    ArchoTek

    Joined:
    Jun 28, 2016
    Posts:
    2
    Hey there!
    I´ve been following this thread for quite some time now, and recently started integrating it into my own game. First off, it's absolutely gorgeous, and performs really well, as far as that's possible. I've got one issue though...

    I really can't make it look right: for one, when I'm in a wooded area and configure everything to have nice godrays and the like when I then go onto meadow areas, the lighting is completely overdone and everything is yellow from the scattering. Then I make it look nice in the meadows, but it will look bad in the woods. Can you maybe explain everything a bit, so I can get a better hang of how it all works? I'd love to integrate it properly, but so far it's not really easy.

    Regardless, thanks for the amazing asset!
    - V_R
     
  41. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Probably not at the moment. I planned for both to use similar tech but that's not going to happen. I still want to make them compatible at some point though
    Could you send me screenshots? PM me if you don't want to show it here. The effect itself should theoretically be the same with the same settings. The result is additively blended to the scene as a last step. That makes it more visible on dark background. Maybe that is your problem? You can use Frame Debugger to inspect individual steps of the algorithm. CommandBuffer.AfterLighting will show you the effect before it is applied to the scene and CommandBuffer.BeforeForwardAlpha shows it after it has been applied to the scene. Both before tone mapping and other post process effects.
     
    Martin_H likes this.
  42. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    thanks for the reply michal,

    i just have to say again that the volumetric asset is brilliant. the more time i am spending with it the more i love it.
    the noise parameter is a stroke of genius. it can really give more life to the scene in a subtle way.

    i cant seem to get it going as imported package though. it works with the original project source files.
    the problem is that the VL renderer turns itself off when i hit play.

    here is the error log:

    NullReferenceException
    UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/buildslave/unity/build/artifacts/generated/common/runtime/ShaderBindings.gen.cs:170)
    VolumetricLightRenderer.Awake () (at Assets/Scripts/VolumetricLightRenderer.cs:160)

    null buffer passed to RemoveCommandBuffer
    UnityEngine.Camera:RemoveCommandBuffer(CameraEvent, CommandBuffer)
    VolumetricLightRenderer:OnDisable() (at Assets/Scripts/VolumetricLightRenderer.cs:222)

    any ideas what i am doing wrong?
     
  43. Soul-Challenger

    Soul-Challenger

    Joined:
    Dec 30, 2010
    Posts:
    152
    @Michal_ Could you please explain your workflow for creating the 3D noise texture? I was able to open and edit the .bytes file after renaming it .dds but couldn't figure out how to get it back in a usable state.

    Noticed performance gets real bad if the noise texture scale is above a certain value.
     
    Martin_H likes this.
  44. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    @crackfox Make sure you have all the files. It can't create material from BlitAdd shader. Either BlitAdd.shader is missing or it didn't compile for some reason.

    Not really :) That's my trusty old texture that I use every time I need a solid noise. For at least a decade now. I don't remember where I got it exactly. It certainly wasn't hand made. I made several similar textures for specific use cases though. They were all procedurally generated from code.
    If you want to manually edit a dds texture then Photoshop with dds plugin from NVidia is probably your best bet. I also used DirectX Texture Tool on several occasions.
    But maybe you just can't load the modified texture? The loader I wrote for this plugin is tailored for this one old (dx9) dds 3d texture. Maybe you saved the dds texture in newer format or you changed texture dimensions etc. Send me the modified texture and I'll make the loader little bit more robust.

    Yeah, I think it is a texture cache problem where you sample the 3d texture at pretty much random locations but I didn't really look into it. Changing texture format to Alpha8 could help but Unity doesn't cooperate.
     
  45. Soul-Challenger

    Soul-Challenger

    Joined:
    Dec 30, 2010
    Posts:
    152
    Yes, I tried different export settings with the NVidia dds plugin and every time I got horizontal strata of full/no density fog.

    For creating the textures from scratch, one way would be using maya: applying a 3Dtexture to a plane, translating it over x frames and rendering the slices as a sequence...
     
  46. Michal_

    Michal_

    Joined:
    Jan 14, 2015
    Posts:
    365
    Would you send me the texture? I don't have access to Photoshop atm.
    Yeah, I won't be able to help you with that. I always procedurally generate my 3d textures.
     
  47. crackfox

    crackfox

    Joined:
    Jan 2, 2016
    Posts:
    29
    works great now when importing aswell.
    thank you.
     
  48. Enrico-Monese

    Enrico-Monese

    Joined:
    Dec 18, 2015
    Posts:
    76
    Don't know if someone already pointed this out, but it seems that it doesn't work well on macOS metal. Fine on OpenGL 4.1 tho
     
  49. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    455
    Can it be used with a custom sky like time of day? I can't used it with Azure sky box, when I look at the sun it become disable.
     
  50. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,332
    I too want to thank you for generously sharing your amazing work here! This thing is among the most impressive assets I've seen so far, and the performance hit isn't as big as I feared it would be. Keep up the great work, you rock!
    I hope the thing UT works on goes in another direction so that both solutions may complement each other or cover different usecases.
     
    Crossway likes this.
unityunity