Search Unity

[RELEASED] - Screen Space Area Lights (SSAL)

Discussion in 'Assets and Asset Store' started by MPanknin, Mar 25, 2013.

  1. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi Thomas,

    There are a couple of steps involved. I'll try to explain them briefly.

    Before rendering of the actual lights takes place, the following steps are performed once per frame.

    In Camera.main.LateUpdate:
    1. Update frustum rays for position reconstruction in the lights fragment shader. (Cheap)
    2. Update some matrices (ViewProjInverse, NormalMatrix etc.). (Cheap)
    3. Update buffer with shader replacement. AlbedoBuffer, TransparencyBuffer. NormalBuffer is only generated in forward rendering. In deferred mode the existing NormalBuffer is used. This means, there are two or three additional calls to Camera.RenderWithShader. (Might be expensive, depending on the complexity of your scene)

    In Camera.main.OnRenderObject:

    For each light in your scene:
    1. Update light (Set matrices and render buffer).
    2. Render light as fullscreen quad. A single light in forward rendering mode requires two draw calls. One for the visual emitter and another one for drawing the fullscreen quad. If you do not need the emitter mesh, then it's a single draw call per light in forward rendering. In deferred path, each light needs two or four draw calls (two without and four with the emitter mesh).



    Hope this helps, and thank you for changing the thread title!

    Cheers,
    Martin
     
  2. Tjomas

    Tjomas

    Joined:
    Jan 1, 2012
    Posts:
    27
    Hi,

    after several attempts, the redLights 1.04 package was finally accepted by the AssetStore.
    redLights now works in Unity3D (3.5 and 4.X) in both rendering paths (deferred and forward) ;)

    Further changes:
    - Unity3D 3.5 4.X (deferred and forward rendering)
    - DX 11 support
    - Linear lighting is currently only supported in deferred rendering path.

    Cheers,
    Thomas
     
  3. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Yei. What I was waiting for to buy :)
    Good job
     
  4. superjayman

    superjayman

    Joined:
    May 31, 2013
    Posts:
    185
    Hi,

    This looks great, Do you have the Demo version which is updated, I tried the previous one however it was not working. I like to demo it before purchase, thanks!
     
  5. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Sorry to say I still cant buy this asset using Unity 3.5, Asset Store shows version 1.04 but says it needs Unity upgrade to version 4.0.1

    I've not published any assets myself but am under the impression that you have to upload to the store using Unity 3.5 if you want users with that version to be able to buy it.
     
  6. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,

    i bought your pkg. Awesome work man.But in animated texture first frame get white. Its look very bad please....help me.

    Regards,
    play_edu
     
    Last edited: Jun 9, 2013
  7. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    Have the same issue.
    expect quick fix :)
     
  8. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    @Play_Edu and @rahuxx:

    I'm happy to provide you with a quick solution to the problem. But in order to locate the error, it's always helpful, if you can give me more detailed information on what exactly is going wrong. Are there any exceptions/warnings thrown in the console window, what unity version are you using, and so on. Or maybe just make a screenshot that illustrates the problem.

    Thanks
     
  9. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi superjayman, I'm afraid there is no preview-package that you can download and import into a unity project simply for testing purposes. The demo scenes that are available for download are additional reference material, that showcase some of the features of our unity package. But they require, that you have purchased the package first.

    There are however multiple live demos, that show redLights in action, which you can find on our website:
    http://de.redplant.de/lab/ssal.html
     
  10. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    @elbows. I will look into it, asap.
     
  11. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,

    Thanks for replay,

    Please.....Follow the Stapes.
    Open the apartment Scene file.Then in TV. Apply (Whirlwind Generative Sequences file). after Finish the loop 1 frame get white.


    regards
    play_edu
     
  12. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    I've just sent you a PM. Please let me know, if that solves the problem.
     
  13. crazyhorse666

    crazyhorse666

    Joined:
    Feb 25, 2012
    Posts:
    37
    Here we go ...


    projected shadows !
    area of effect volumes per light
    angle of effect from source
    source from mesh or 3d primatives
    apply as texture overlay :wink:to an existing material
     
  14. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,

    Thanks for solved problem.
     
  15. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hey, thx for your wishlist. Input is always welcome. :)

    Could you elaborate a bit more, what you mean by:
    1. Area of effect volumes per light? The area of effect / range of the lights can already be controlled by adjusting the various falloff parameter.
    2. Angle of effect from source? Do you need a more conical shape of the lit area?
    3. Apply as texture overlay to an existing material? I'm not sure, what you mean with this one...

    Arbitrary mesh emitters will be tricky, however, we are currently implementing support for elliptical light emitters.
    Yep and shadows are still on our TODO-List. But other features such as basic-support for mobile have a higher priority at the moment.

    Cheers,
    Martin
     
  16. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    No problem, that's what we are here for. :)
     
  17. user150221

    user150221

    Joined:
    Nov 10, 2012
    Posts:
    25
    1. Maybe they mean volumetric light, which really only applies to their later suggestion to have light volume primitives or meshes. Or maybe not, since you don't touch the builtin spot/point lights so it'd be kind of pointless.
    2. They may mean something like IES light profiles. Custom falloff functions basically.
    3. I'm not sure either. If I would guess, maybe they mean e.g. you have a mesh like a neon sign. It has a glow shader, but you want a front and back plane to act as the area lights, without the planes being visible. This is usually called reflection impostors or "image proxies". The area light planes would be what show up in specular reflections, since the actual mesh would not. That is why they get the name. I'm not sure if you already have this system or not.

    Primitive area light volumes would be interesting, and infinitely more feasible than mesh area lights. The most useful would be cylinders, as they cannot be faked with any built in lights. Spheres would be the same as point lights, but the only difference would be that the light takes up actual volume, and would show in the specular as an actual sphere instead of a point.

    I linked to one of the PS4 Killzone slides above, but there are more PDFs and PPTs (with comments) out there if you look. All the lights in the game are area lights, they are volumetric, and they use IES profiles.


    So, on to my questions...

    Is what I described in #3 something SSAL does currently? I'd like meshes to be visible but the area planes not-- just the specular/lighting contributions.

    Is SSAL open source? I saw that you originally tried to implement this in the pre-pass lighting shader. That personally is my goal and if I bought it I'd like to port it to that shader. Of course being in screenspace, maybe the math has changed so much I won't be able to make heads or tails of it? It seemed to me your issue with passing data to the area lights could have been solved by using the cookie texture -- baking the needed data into the texture, and then decoding it in the shader. Someone said in that old thread that they got area lights working in the prepass shader too. I'm also targeting DX11 only, so I have other methods at my disposal too.

    Or, is there a chance of ever revisiting the non-screenspace method?
     
  18. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi jonwd7,

    thx for the linked slides. Very interesting stuff!

    Yes, my main problem with implementing area lights in the pre pass was the lack of possibilities to pass down custom parameters. Baking this information into the cookie texture would be an option imho, but you would loose the ability to easily adjust the lights settings at runtime.

    The math actually didn't change that much between pre-pass and screenspace. It's actually mostly identical. Both version use a depth-buffer for reconstruction of the world position, once this is figured out, the lighting calculations are pretty much the same.

    However, doing it in screenspace we have to generate the necessary renderbuffers by hand, which of course comes with a performance penalty. But the biggest advantages of the screenspace approach is the fact, that you do not loose support for forward rendering, which seemed to be important for many people. If you don't need that, then doing it in pre-pass might be more feasible, since you can completely rely on the render buffers, that are generated by unity.

    Regarding the reflection impostors. I think, we are doing something different. Each light consists of two components atm. The visual emitter plane with / without a texture and the actual fullscreen quad that renders the lighting contribution. Both components are independent from each other. So if you only want to see the light inside your scene but not the emitter plane, then you can simply disable the respective mesh renderer. That's what we are doing in our cornell box demo. Right now the specular contribution depends on the light settings, not the emitter mesh. We could integrate something like a separate reflection texture easily, if that is, what you are after.

    Primitive light volumes are planned for a future release and yes, they are way more easy to implement, than complex mesh emitters. Right now, we are implementing elliptical emitters. Once that is done, we will continue with primitives (cubes, spheres and maybe cylinders).

    IES profiles sound very interesting too, but I need to read up a bit on that topic, before I can decide, if this can/should be integrated into our package.

    Yes, the redLights come with full source code including shader, scripts and example scenes.

    Hope this helps. If you have anymore questions, I'm here. :)

    Cheers,
    Martin
     
  19. crazyhorse666

    crazyhorse666

    Joined:
    Feb 25, 2012
    Posts:
    37
    hi ,
    1. ability to set a cube or sphere volume to limit effect of the light for instance 1/2 the area of a room etc
    2. yes conical area light
    3. the ability to us the mesh plane as a light over the top of its base shader without creating a new area plane the same size as the intended source

    ps i have a dx11 scene deferred render that linear lighting .it is impossible to light with your area lights i just dont see them in the view at all the scene is lit dynamically and i am using ibl materials from skyshop any idea why they are not showing up ?
    :-?
     
  20. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi crazyhorse666, I just sent you a PM.
     
  21. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Just a small update for today.
    Started working on primitive light emitters, as requested... :)
    Spherical and cylindrical shapes are working (kind of).

     
  22. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Another requested feature for the upcoming release.
    Each rectangular light emitter now has a new parameter 'angle', that influences the angle of effect of the lit area.

     
  23. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    And basic support for custom falloff functions.
    However, the way to proper IES support is still long.... :-?

     
  24. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    Really nice updates :)
    Thank you
     
  25. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Wow. If you add ies support it will be an instant buy from me.
    Good Work!
     
  26. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    632
    Sorry if this was already answered but is there a way to have a light that goes all the way around and is that what this is?
     
  27. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi, yes that's exactly what it is. The cylindrical/spherical components emit light in all directions equally.
     
  28. crazyhorse666

    crazyhorse666

    Joined:
    Feb 25, 2012
    Posts:
    37
    hi can u give me the workaround for this white frame pls ! i have the same needs
    no console errors just first frame is white ...
    unityversion 4.1.5F1 win 8
     
  29. crazyhorse666

    crazyhorse666

    Joined:
    Feb 25, 2012
    Posts:
    37
    Hi !
    fantastic looking great..
    :)
    didnt get your PM where should i be receiving it ?

    keep up the good work i am currently working on an interior scene entirely lit using skyshop and your arealights so all in realtime ..
    looking good ..
     
  30. crazyhorse666

    crazyhorse666

    Joined:
    Feb 25, 2012
    Posts:
    37
    OMG this is great so you cn pass a cookie texture to the shader ? :)

    WISHLIST...

    can i add

    The ability to duplicate arealight rename it and assign a new video sequence at the moment it will not allow assigning a new sequence name so tyuo have to create another new arealight making it tiresome to realign to scene etc

    Animated texture arealight using a MP4 or normal video tex and option for use of a sprite sheet (rows and columns) rather than an image sequence as source.

    Mesh culling ....inclusion and exclusion.
    Animated on /off light switching random/Flickering/timed/triggered
    Animated Intensity.

    :)
     
    Last edited: Jul 10, 2013
  31. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Please check your inbox. I just sent you the patched file. This fix will be included in the next release btw...
     
  32. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Check your inbox. Top menu / notifications / inbox.

    Thx, I would love to see some screenshots of that scene! :)
     
  33. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    529
    Just bought it, i espect to use intensively!
     
  34. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Thx for the purchase. I'm curious to see what you will create with it!
     
  35. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Another small update before the weekend.

    Started working on shadows. It's basically SSSS from the first GPU Pro, but with a bit of my own interpretation mixed in, since I couldn't wrap my head around around some parts of the article. Below you see a comparison between the builtin unity shadows and our implementation. It's still work in progress though.







    Have a nice weekend!
     
  36. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    Interesting. Are you planning on your shadows to be able to replace the unity shadows for all intended purposes or just some special cases like with SSAL lights?

    Unity shadows are something that simply need a complete overhaul.
     
  37. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Beautiful lights. Purchased them today but was disappointed to see that my custom shaders weren't receiving light from the area lights. What is required for custom surface shaders to be compatible with the area lights?

    Answered my own question. The shader needs a _Color property output along with the albedo.
     
    Last edited: Jul 14, 2013
  38. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Right now, it's for SSAL only.

    Maybe in the future we could provide something like a separate SSSS package. I have to think about it.
     
  39. mrbdrm

    mrbdrm

    Joined:
    Mar 22, 2009
    Posts:
    510
    At first i thought that it's for static lights, but when i read it's real-time and your making a new shadows better than what we got with pro.
    it's a must buy, don't care about the price :)
    keep it up i love it.
     
  40. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Simple request:

    When a light is created through GameObject->RedLights, would you mind adding code to immediately select the object? It'd also be convenient to place the object not at 0,0,0, but perhaps at the sceneview camera's location.

    When loads of these are placed, the current workflow isn't user friendly.

    Other Issue:

    You may see this issue pop up more over time, so it may be worth looking into: Levels that are constructed in a modular workflow may not have they vertices line up 100%. As a result, you get T-Vertices along edges of geometry. This causes little sparkles along the edges in the viewport. Those sparkles are pixel-sized holes in the geometry that see through to what is behind the object. This is typically the skybox, which is usually brighter than the lit geometry. Since redlights is screenspace, those sparkles turn into black blobs! Here is a screenshot:

    $glitch.jpg

    I do have workarounds for this, but I was wondering if there was one on your end. Thoughts?
     
  41. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Hi, I just sent you the patched file for light placement and automatic selection. If anyone else needs it, just pm me.
     
    Last edited: Jul 15, 2013
  42. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    632
    Is there a way to control the fov the light reaches around?
     
  43. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Just a heads up: Enabling the Anti-Aliasing Image Effect that comes with unity pro breaks the area lights. This is running in deferred mode.
     
  44. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Which filter are you using? Another user reported problems with the FXAA3Console filter, but we weren't able to reproduce it.
     
  45. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Yes, in the upcoming release, there will be a new parameter, that influences the angle of effect. See post on previous page.
     
  46. xexex

    xexex

    Joined:
    Jan 17, 2012
    Posts:
    15
    Multi Camera issue
    I used two cameras in this scene,each camera render half screen,but there is something wrong

    $ssal.png
     
  47. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    Yes, FXAA3Console. I can reproduce easily. Simply add both the area light and antialiasing script to the camera and keep them enabled. Run the engine. The area lights are not rendering. If you uncheck the anti-aliasing, they show up.

    One other thing: the Area Light Renderer also breaks tonemapping. There is no adaptation when tonemapping is enabled.
     
  48. MPanknin

    MPanknin

    Joined:
    Nov 20, 2011
    Posts:
    361
    Ah, it occurs only in 4.x, works perfectly fine in 3.5. I'll look into it...
     
  49. xexex

    xexex

    Joined:
    Jan 17, 2012
    Posts:
    15
    Hi,MPanknim
    Can you fix this,thanks!
     
  50. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,081
    So, eh, it seems these are pretty expensive to render. According to the profiler, each area light takes over 1ms to render on a Geforce GTX 460. And even though these are screenspace effects, the cost is constant whether the lights are onscreen or not.

    My renderer and camera are set to deferred as well.

    $redlightsrenderer.jpg

    Even in your included demo scene the lights are expensive. Duplicating lights adds another 1-2ms each.

    I don't think people can put these to good use in a production setting unless they're optimized in some fashion. Instead of adding features, this should be the next step.

    Just a side note to those reading the post: Never use raw FPS as a measure of how fast something renders. Only the millisecond timing tells the truth in context with everything else. Use the profiler!