Search Unity

Volumetric Objects

Discussion in 'Made With Unity' started by MattCarr, Jun 29, 2012.

  1. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    After adding volumetric objects to version 1.5 of the Advanced Surface Shaders package on the Asset Store, I thought I should put together a video showing some of what can be achieved with them.


    Click here to watch on Youtube

    This video was built using the volumetric objects as of version 1.5.2. We'll be adding more options to future versions as well as more shapes, the most exciting of which is the cone volume which so far in testing is able to produce some amazing looking light shafts, particularly with fog and dust textures.

    You can see more of the shaders and effects over in the Advanced Surface Shaders forum thread.
     
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,900
    simply great!

    lars
     
  3. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    Thanks lars. Version 1.5.2 is available now and also contains cone volumes which are extremely useful for creating great looking light shafts for spotlights as well as many other potential uses.


    Click for larger version
     
  4. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    This looks great. I'm curious, what technique did you use for this?

    I played around with volumetrics in Unity a while back using replacement shaders by rendering geometry additively into depth buffers - back then front faces then summing the distances to get the depth. Worked great for any volume shape, even non convex and intersecting volumes as well as camera-in-volume correctness. The main issue I ran into was, because I was doing it with replacement shaders everything had to be the one colour or if multiple volumes overlapped it wouldn't be able to blend the colours correctly. Always wanted to revisit it but never found the time - guess I don't have to now :).
     
  5. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    Thanks Cameron. While I obviously don't want to give all the details away here (owners of the package are of course free to check out the source), the current volumetric objects in the package (cube, sphere, cone) are actually only basic mesh objects (cubes at the moment) and the shape of the volume is created in the shader. Info about the shape is passed to the shader and raycasting is done on the GPU to determine if a pixel is within the volume and the distance the ray travels through the volume.

    The texturing inside the volume involves ray marching.

    I have started experimenting with applying volumetric effects to any geometry and it can be pretty cool too. I'll need to switch gears for a week or two with this package and focus on more shader variations for mobile platforms, but after that I'll look into adding support for arbitrary geometry. I think the use cases for that are far less common than those involving the 3 shapes available now though. Box fog volumes and light shafts are pretty commonly useful and awesome :).
     
  6. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Thanks for the info, totally different approach to what I was doing - which was based on Nvidia's Fog Polygon Volumes paper. Not as advanced as what you're doing, loving the world space sampled textures.
     
  7. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
  8. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    I am very interested. Do you have any benchmarks (eg. Angrybot) running on mobile platform? I just want to know roughly how expensive this is on a mobile platform.

    Also, I have a suggestion - would be it possible to implement an option to extend the fog volume (and shape) to conform to the volume where it is in? eg. if you place it in a let's say pyramid shape room with the tick of an option, it will automatically conform to the shape and size of the room. Also does it support different fog/texture effects? Eg. can I load custom fog textures?
     
    Last edited: Jul 6, 2012
  9. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Cool stuff Matt! ;)
     
  10. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    Answered this over here :).

    Thanks mate :).
     
  11. hellraizerhhh

    hellraizerhhh

    Joined:
    May 26, 2010
    Posts:
    619
    Amazing! That made the angry bots level a billion times better and more lifelike. Very subtle but really gives it that extra push in the right direction. Great work
     
  12. Sasstraliss

    Sasstraliss

    Joined:
    Feb 24, 2013
    Posts:
    10
    Broken in Unity 5
     
  13. Utopien

    Utopien

    Joined:
    Feb 15, 2016
    Posts:
    46
    hey look amazing does your volumes react to light
    ?