Search Unity

[RELEASED] Super Fast Soft Shadows

Discussion in 'Works In Progress' started by Andy-Korth, Jun 5, 2015.

  1. ViralArt

    ViralArt

    Joined:
    Apr 17, 2015
    Posts:
    6
    Currently looking for a 2d light solution for our game.
    However there are information on this asset i have not been able to find clear answers for.

    1. Does it support sprite masks?

    2. It has these shadow masks. But what do they mask? What i need is a kind of light linking. Like unity lighting objects per layer. So i can light the outside of the building and the inside separately.

    3. Ofc when you have lights you have objects/sprites casting that light, In the picture i have a custom sprite shader with diffuse and self illumination to create that effect. Guess i have to add to the sfss shader, maybe even the render component?

    https://imgur.com/a/3tnR3
     
  2. Andy-Korth

    Andy-Korth

    Joined:
    Jun 7, 2013
    Posts:
    140
    @holdingjason Yes, there are a few potential options for you. There's a SFSample that lights the whole sprite evenly- that sounds like what you've seen and it's not what you're looking for. You can also use the linear mode, which lights vertical strips of the sprite based on a line where the sprite stands. There are examples included for that one. The other option would be splitting up the sprite into multiple sprites and rendering some parts of them as normally lit (using the light receiving material) and other parts unlit- with a different material with different settings. That usually works best for trees.

    For the situation you mention with buildings, that's a bit trickier. I would recommend writing a custom SFSample script. If the sample point is in the light, render the building normally so it receives lights like a normal sprite. This means the whole building won't be enveloped in a single color of light.. and the building won't flash lit and unlit as the light moves. If the sample point is dark, then turn down the ambient/lit mix all the way to ambient. This will prevent a light behind the building from showing up on the building. This would work pretty well I think, unless you have multiple light sources.. then illuminating the front of the building would cause the lights behind the building to show up... so hopefullly you can work with those limitations- or this should give you some ideas of what's possible.

    @kornel-l-varga Sorry, we don't offer evaluation versions.

    @Zehru Sorry, no news on it yet. Still a speculative thing!

    @ViralArt We support light cookies. They are sprites that allow you to reshape and recolor lights. Not quite sure what you mean by light linking. You can use scripts to link lights together and make them match intensity, etc. You can definitely control both indoors and outdoors lights that way. Not sure if that's what you were asking there though.

    https://imgur.com/a/3tnR3

    This image could definitely be made with SFSS. Very nice work! It could be a single light, with the tint controlled by a single image, or it could be 7 different lights. (which you would need to do if they turned on and off separately, or flashed with intensity changes.

    I think I understand a bit better... Having two lights, one exterior and one interior would be one sollution, but you could do it with a single light too. If you did two lights you could control how they interact with the scene with culling layers. That would prevent the player from interferring with indoors lights. I think you would want different hand-made masks for the indoors light vs. the outdoors light, and you'd want the precisely aligned with the scene for the best effect.

    The effect up on the top window is the only one that I'm really pondering about, since it's got those window frame sections that receive light a little differently from the building interior. For ease of production, I'd really try not to make separate indoors vs outdoor lights and try to achieve the effect with just an outdoor light and a custom painted light cookie. That might mean applying some of that teal to the background source sprite rather than letting the light do 100% of the teal. Hope that helps!
     
    Zehru likes this.
  3. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    48
    hey there and thanks for the sfss plugin
    i would buy it if i make sure about something that il listed below
    first of all is it truly optimized for mobile device?
    then is it possible to have shadows on background ?i mean like 2dxfx that the shadow of player will be on background too
    (something like the source light is in foreground then the player is between source light and background,whenever player gets between these two the shadow of player will bi on background)
    sorry for bad english
    again many thanks for this great asset
     
  4. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @pourya011 Late reply, but yes, the effect was originally written for Cocos2D, which is a mobile game engine. With half a dozen lights visible onscreen it runs fine on the iPad 2. Mostly it comes down to balancing the number of lights, shadow casters, and light buffer resolution.

    SFSS is strictly a 2D effect (no z-values are used). So objects in the foreground can cast shadows on the background, but objects in background can also cast shadows in the foreground. Does that make sense?
     
  5. ChrisTobiS

    ChrisTobiS

    Joined:
    Jun 15, 2017
    Posts:
    12
    Hi :) Will there be Composite Collider support? I'm working with the new tilemap system and it would be great if we could create SF Polygons with the composite collider (from Tilemap Collider 2D) on tilemaps.
     
  6. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    147
    Hi,
    This is a great asset and its usage is adding a lot to our game.

    I was wondering though, if you have any suggestion for animated sprites to correctly cast shadows? Or is it the plain old "update collider per frame" approach?

    Regards.
     
  7. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,543
    After creating my own 2D lighting system using raycasting & mesh generation, I'm jaw-dropped by the accuracy and visual splendor of this asset package. Documentation definitely needs improvement, both in format and content, and the examples contain some legacy systems, but overall I am very satisfied with this purchase. Well done!

    What's on the roadmap?
     
    Zehru likes this.
  8. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @ChrisTobiS: So one thing to keep in mind is that SFSS doesn't support physics colliders natively, just a UI convenience to copy the polygons with a click in the UI.

    The composite collider seems like it's just a regular polygon collider that automagically batches other polygon colliders into a single collider. This seems really weird to me since I can basically guarantee that at the collision detection level they break those back down into individual polygons. This throws several wrenches at SFSS. It batches a lot of collision geometry together in a way that SFSS has to undo, and it does it automagically at runtime without providing any events or callbacks or anything.

    If you are using it to batch other poly colliders, then add SFSS polygons to those. If you are using a tilemap? I dunno what the best path is. The "Unity way" unfortunately seems to be to add many layers of magic and only expose the final result. :-\ I mean you can guess when to recopy it, and do it whenever you think it has changed? I'm not sure there is a better solution unfortunately.

    @TanselAltinel: My plan has been to support multiple paths per SFPolygon. We've been meaning to do that for a while since polygon colliders can have multiple paths. By exposing a "current frame" property, we could let users animate them. Actually working on this this week since a client paid for some customizations that rely on it. Ping me with a PM, and I can get you a preview version.

    @jeffreyschoch Thanks. :D I'm fairly proud of it. I spent several years trying to figure out how to do projected mesh edge shadows that could support proper penumbras. Any suggestions to improve the documentation (more pictures/diagrams)? We don't really have a public road map no. Most of the features we want to add are blocked by: Unity bugs / missing features (ex: using texture arrays as MRTs), lack of a satisfactory solution (shadow mask blending for directional lights), or time.
     
    jeffreyschoch likes this.
  9. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,543
    Thanks for all your hard work.

    My suggestion for the docs is to have a more comprehensive "Scripts and Properties" section, like you currently do, but with an entry for every script included in the package. Off the top of my head it was missing SFSample, and another component that started with Extended which was for sampling (I'm not at my home computer at the moment). Perhaps the text from each example scene could also be in the docs. It should serve as a one-stop reference for the package ideally.

    Another suggestion I have, unrelated to docs, is for the SFSample system. I'm not sure what's doing the actual work, but it appears to use the SFPolygon shape to determine the vertical shadow lines on the object, but in instances where the base shadow casting shape of the object is not wider than the upper portions, it can potentially ruin the effect. For example, a tree with a skinny base and branches extending out of the trunk. Hopefully you understand. Would it be possible to specify an additional parameter of some kind, which can be used to change the width of the shadow strips?

    Ideally if my light was on the upper left side of the object, the shadow line could cast across the entire right side of the object, regardless of SFPolygon shape.
     
  10. xpachin

    xpachin

    Joined:
    Feb 6, 2014
    Posts:
    46
    i have to say, that looks amazing
     
  11. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    SFSS is currently on sale! https://assetstore.unity.com/packages/tools/sprite-management/sf-soft-shadow-2d-38682

    I've also been working on a new feature that will enable SFPolygon components to have multiple paths, more closely matching the PolygonCollider2D API. As a bonus, you'll also be able to use these extra paths to do sprite animations.

    @jeffreyschoch Noted about the missing docs for SFSample. I've updated that for the next release. The ExtendShadows script is a one line component that calls a bit of the API with some hard-coded values for that scene. Though not perfect, it's hopefully a move in the right direction.

    Oh! I didn't see your question earlier about the SFSample clamping. Clamping the sample position wouldn't really work either. The solution we use to work around it is to split our sprites into pieces that we want lit differently. On a tree for instance, use just ambient light on the sprite for the leaves, while using the SFSample script on only the trunk.
     
    jeffreyschoch likes this.
  12. Leonyx

    Leonyx

    Joined:
    Sep 15, 2014
    Posts:
    4
    I think it would be pretty cool if the shadow collider automatically applied to box colliders like it does polygon colliders!
     
  13. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    598
    I would like to create shadows that render in front of my sprites, since my levels are built with modular sprites I cannot simply bake the shadows in the sprites.

    So how can I go about creating shadows that would:
    1) fit the terrain I want to give shadows to?

    2) make the shadows look good like this for example?


    Can your tool do this for me?
     
  14. nbtdev

    nbtdev

    Joined:
    Jul 12, 2017
    Posts:
    1
    Good day.
    Help in solving a specific problem. On all devices, the light works correctly. But on the Samsung Galaxy s8 artefacts appear in the shadow (attached screenshot). Tell me please, how I can solve this problem?
     

    Attached Files:

  15. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @FeastSC2 I don't see anything casting shadows in the video you linked. It looks to me like their terrain is actual 3D geometry, and then backlit so you can only see the edges. SFSS can't do that for you out of the box. You need something to let it know how to light the edges. SFSS has a feature called "light penetration" that will sort of do it, but it doesn't look good in large amounts like that. If all it knows is where the edge is, it has to guess how to shade it, and must shade them all the same way. (boring)

    You have a couple of options. To get something like Ori, you need 3D models instead of sprites. That might be a lot of rework. Another option is to draw masks for each of your modular sprites for how it would be backlit. Could be sort of automated using a photoshop action or similar. You would also need a bit of code to mix them together with the SFSS lighting. Alternatively, you could paint one big, low-resolution mask for the whole level.

    If you want a no-code solution. Then you need to make SFPolygons to fit the whole level and update them by hand when you move your geometry around. You also need to live with the look of SFSS "light penetration" feature which wasn't really meant to be used this way. Try a small example first.

    @nbtdev Hmm. Looks like an error in the shader compiler on that device. Try switching the graphics driver if you can. (ex: Assuming it's a GLES 3 device, try the GLES 2 driver and see if it fixes the problem.
     
    FeastSC2 likes this.
  16. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    @FeastSC2 Hi!
    hm I couldn't exactly understand what you want to achieve, but is it something like this?
    (I've made this in about 4 minutes, so please don't mind about the very bad quality).

    and actually I've used many assets to make it faster hahah :)
     
    FeastSC2 likes this.
  17. Kirbychwan

    Kirbychwan

    Joined:
    Aug 14, 2012
    Posts:
    430
    @slembcke2

    Hi, quick question about SFSS;

    Is there a supported method to preventing Light/Shadows from affecting specific layers?
    For instance, if you have a bright sky background far back in the zdepth, you wouldn't want light or shadow affecting it, etc because that would look pretty funky.







     
  18. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @Kirbychwan The best solution is don't use the SFSS shader on an object that you don't want SFSS to affect. If you want more than all-or-nothing control there are a couple sliders on the material as well that let you control how strong shadows should appear on the object, and how strongly the light vs. ambient light should be mixed.
     
  19. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    598
    Thanks for taking the time to answer my post,
    Yea that looks like what I want, I think.

    Thanks for taking the time to answer my post,
    I know actual shadows is not exactly what I want. I don't even need it to be lit, what I simply need is a mesh that has a gradient color that goes from fully transparent to fully black opaque. The best would be that I can choose the colors like in Ferr2D's gradient picker.

    So naturally I thought about using Ferr2D (just a simple mesh that would have a gradient on it based on the distance to the edge) but the problem is that he's using the mesh's vertex color to apply the gradient and that's really ugly / not a smooth gradient + it needs a lot of vertices (but it still looks ugly even then).
    So I need to use UV's and apply a texture (based on a gradient picker) to that mesh that would behave in the same way as his distance to edge gradient.

    I actually don't need lighting or anything of the sort, my game's lighting will behave correctly with it I just need the mesh with the gradient UV but I don't know how to achieve this.

    Here's a picture of what I would need, is this something I can find somewhere or must I necessarily build it?
    (I'm not actually that good in math and it seems to me like this would actually require quite a lot of experience to create):
    ApplicationFrameHost_2018-02-05_16-37-08.png
     
  20. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    So if @Zehru example looks okay, I think that was the #3 option I described. Just make a big set of SFPolygons for the whole level and set the light penetration value to be high.

    I'd still consider the one-big-mask option too. An easy-ish workflow would be to:
    • Create the whole level
    • Zoom out and take a screenshot
    • Paint black mask over it in PhotoShop
    • Export that mask layer
    • Stretch it over the whole level
     
  21. BFC_Psym

    BFC_Psym

    Joined:
    Apr 19, 2016
    Posts:
    2
    I am experiencing this issue on the S8 also. I tried using GLES2 and also playing with the various light options without any luck.
     
  22. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    147
    I have achieved dynamic animation shadows based on dynamic animation colliders. It is really great now.

    I couldn't have achieved this if it wasn't for this nice asset. Thanks a lot for your great work! When the game is released, and if it becomes somewhat a hit, I'll provide a detailed explanation for your asset.
     
    jeffreyschoch likes this.
  23. Anemor2000

    Anemor2000

    Joined:
    Jun 12, 2015
    Posts:
    39
    Hi there. We are having an issue with the plugin where lights look bad when the camera zooms out but clear and nice when the camera zooms in. Basically, the farthest the camera, the uglier the light. I attached 2 screenshots to show the difference between 2 zooms. As you can see, the zoomed out light (the small one) is super pixelly while the other one is fine. Any ways to avoid this?
    Thank you
    lights_zoomin.PNG lights_zoomout.PNG
     
  24. lordubik

    lordubik

    Joined:
    Feb 18, 2013
    Posts:
    67
    Hi, in our game we want integrate dynamic shadow.
    your assets could generate dynamic shadow like in the screenshot? :)

    Thanks.

    Track01.png
     
  25. Anemor2000

    Anemor2000

    Joined:
    Jun 12, 2015
    Posts:
    39
    Hello, I solved my problem by changing Shadow Map Scale on the SfRenderer.
    Now we have another problem. We want to have sprites that block light based on their z position (block light if they are in front). It does not seem possible and it gives us the problem that you can see on screenshot below. A light behind an object goes through the object which gives a very weird looking result.

    All objects are placed by their Z axis so if we could put something that blocks if its the light is behind, it would solve our problem.

    Any possible solution hints would be appreciated.
    thanks

    Capture.PNG
     
  26. soulinhki

    soulinhki

    Joined:
    Mar 2, 2014
    Posts:
    9
    Hi,

    Just bought SF Soft Shadow 2D plugin and after buying and trying couple other 2D shadow assets I have to say this is first one that doesn't have some kind of shadow stability issues - great work!

    However, I've run into issue when running my game on iOS device - all soft shadows are hard (ie the penumbra gradient is just solid color). In desktop player everything works as expected. Any ideas what could be causing this? Using Unity 2017.3.1f1

    Regards,
    Sami
     
  27. lordubik

    lordubik

    Joined:
    Feb 18, 2013
    Posts:
    67
    News? :)
     
  28. BFC_Psym

    BFC_Psym

    Joined:
    Apr 19, 2016
    Posts:
    2
    I am having this issue also
     
  29. Fortitude3D

    Fortitude3D

    Joined:
    Sep 7, 2017
    Posts:
    155
    dynamic, looks great :)
     
  30. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    Unfortunately no. We implemented something similar in a custom version of SFSS for a client, but there are problems we haven't figured out a fix for in a generic version. Sorry.

    SFSS doesn't handle depth at all. It would be possible to fix it with a rewrite, but that's probably not going to happen anytime soon.

    A partial fix would be to use the SFSample script. It allows you to light tall objects by sampling the light at their base instead of their pixel location in the world.

    Hmm. We were overdue for another Unity bug to break rendering on us again. -_- A screenshot would help. I'll have to download the iOS tools again and test it out sometime next week maybe. In the meantime, try running with the GLES 2 or GLES3 renderer to see it can be narrowed down to a bug in the iOS Metal renderer.
     
  31. soulinhki

    soulinhki

    Joined:
    Mar 2, 2014
    Posts:
    9
    This is with both Metal and GLES 2 renderer (iOS 11). (OS X player on left, iOS on right)
    editor.png ios.png
     
  32. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    Oh... I bet I know what the problem is. I bet the default renderbuffer format changed again or something. They did that on Android a couple years ago and it changed to ARGB1555. 1 bit alpha makes for very non-soft shadows. ;) It looks like there is a bug in SFRenderer.Start() that could be preventing it from selecting a better format if that is the problem.

    To sidestep that, try enabling HDR rendering for your camera and see if that fixes it. Otherwise I'll try and get an up to date iOS machine set up again and debug it further.
     
  33. soulinhki

    soulinhki

    Joined:
    Mar 2, 2014
    Posts:
    9
    Enabling HDR on camera and mobile graphic settings indeed fixes the issue!

    Would be really nice if this can be fixed to work without HDR though.

    BR,
    Sami
     
  34. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    Ok! Progress! So they changed the default render texture format, and the code that protected against it had a copy paste error in it. (/me facepalm)

    Find this:
    if(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB32)){
    lightmapFormat = RenderTextureFormat.ARGB32;
    } else if(SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGB32)){
    lightmapFormat = RenderTextureFormat.BGRA32;
    }

    Change that second if() to check for BGRA32. I'm guessing that should fix it. I can release a patch if it does.
     
    jeffreyschoch likes this.
  35. JSwanFin

    JSwanFin

    Joined:
    Apr 10, 2013
    Posts:
    16
    I am looking for flexible shadow system for our 2d game. I already bough one but it turned out to be too rigid and not suiting our needs. Our special needs are following:
    1) I understand that you can have light and shadows on background but not in normal mapped sprite? Is that correct? That would be fine for us, we just need that we can use normal mapped character sprites and background with light & shadows
    2) Is there source code included?
    3) Our game is isometric and for example houses are neatly axis aligned in isometric coordinate system (think of isometric tiles, although we are not restricted to fixed sized tiles).

    What I would want to do is to is
    a) add info we already have about the rectangle of a house in isometric coordinate system (we use that infomation for calculating sorting orders for example) as an obstacle to shadow & light system. Your system makes no assumtion that obstacles need to be 2d colliders for example?
    b) Then when the mesh(es) for light and shadow (I assume it is a mesh, I am not an expert) are calculated but before they are rendered to screen, transform vertex positions from isometric coordinate system to Unity world position (or even screenspace for that matter). That would provide lights and shadows that fit in the isometric view and would be easiest for us to do. Is that possible to do?
     
  36. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    1) Yes. You can use SFSS to light/shadow your background, and Unity to do normal mapped lighting on your sprites (or vice versa). You can mix and match the two, just not use both on the same object.

    2) Yes.

    a) Correct. You add SFPolygon components to your game objects. Their API is similar to 2D colliders, but they are completely separate.

    b) Yes, but not out of the box. The built-in shader supports point/line sampling modes, so you can read from the lightmap at the base of the object, instead of on the ground behind it. You would need to extend that to understand your isometric coordinates.
     
  37. JSwanFin

    JSwanFin

    Joined:
    Apr 10, 2013
    Posts:
    16
    Ok, I buy it and see where it leads :) I might have some questions later on.
     
  38. soulinhki

    soulinhki

    Joined:
    Mar 2, 2014
    Posts:
    9
    Yup, this fixes the issue without HDR - Many Thanks!

    Br,
    Sami
     
  39. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    19
    Would it be hard to implement this asset for other stuff too? Like using it for:
    1. occlusion effects / revealing objects / fog of war kind of stuff?
    2. Triggering stuff when in area of light / shadow?
    3. Enemy sight where there is light, or use a light on the enemy as sight (enemy can't see in shadowed areas)
    4. Or explosions that don't reach you if you hide behind a wall (set up would be: a light on the explosion that doesn't "detect" you in the shadowed parts).
    etc
     
    Last edited: Mar 25, 2018
  40. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @BACALL
    1) We did some contract work to add that. Ex: http://www.tearthrough.com/ Doesn't look like they have any new screenshots up that use it, but then again it's not a huge stretch of the imagination. We also implemented a fog of war bit separate from the visibility, but they weren't interested in that. So it's possible, but since we implemented it for a contract we can't just give out the code for it.
    2) Not really. The effect doesn't really run on the CPU, and copying it back would be very expensive. It also doesn't render parts that aren't visible on the screen. You need good old raycasts for that.
    3) A a graphical effect (yes) or similar to #2 (again, raycasts)?
    4) Nope, raycasts again.
     
  41. Zehru

    Zehru

    Joined:
    Jun 19, 2015
    Posts:
    84
    Hi @slembcke2 . After checkin @BACALL questions I also have a question :)
    Is it possible to know which direction the light or shadow is being casted to generate some raycasts?
    Sorry if my question sounds quite noob hahaha
     
  42. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    The raycast would start at the light's position, and move towards the target point. The direction would just be (target - light position). Is that what you mean?
     
    Zehru likes this.
  43. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    47
    Hi there!

    Loving your asset, the lights and shadows are awesome and a perfect fit for my game.

    I'm having some trouble tho. When I have multiple lights in scene the shadows and lights are blocky and glitchy, and changing the map scales don't work.

    SingleTorch.png
    Here a screenshot with only one torch, perfect shadow, lovely ambient.

    LotsOfTorches.png Here with multiple torches, glitchy, some of them directly don't work at all (every one of that torches has the same light, there are prefabs).

    I copied the config from the forest example.

    Am I missing something?
    Thanks!
     
    Last edited: Apr 12, 2018
  44. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    The shadow is casting in the right direction from the light here, but there is no light near it. I think you maybe moved the pivot of the rect transform (the light source's origin) without moving the rest of the rect (where the cookie texture masks out the light).

     
  45. Elendow

    Elendow

    Joined:
    Apr 9, 2014
    Posts:
    47
    You're right, the shadow is fine, but not the light... But the RectTransform is in place... RectTransform.png

    UPDATE: SOLVED! I removed the Metal from the graphics API (I'm working on Mac).
    Solved.png

    Also, I've made a little script that generates SFPolygons using a CompositeCollider (ideal for tilemaps). Feel free to use it :)
     

    Attached Files:

    Last edited: Apr 13, 2018
    luislodosm likes this.
  46. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @Elendow Aurgh! The Metal renderer, that thing has been bad news since they released it. I'm really nervous about them pushing it more and more as production ready, because it still seems to trigger all sorts of bizarre bugs.

    I would highly suggest submitting a bug report for the problem you had.
     
  47. Lechuza

    Lechuza

    Joined:
    Oct 3, 2014
    Posts:
    19
    Is there a way of getting the light direction inside the soft shadow shader?
    I'm trying to do sort of like a back lighting or rim lighting of some sprites, and would like to check the light direction to know which mask or mask channel to check against, at least that's how I am thinking it of doing it at the moment.
    Thanks in advance! Keep up the great work.
     
  48. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263
    @Lechuza Unfortunately no. The lightmap SFSS generates has all the lights accumulated together, and it's not possible to separate them or figure out directions. You might be able to do a hybrid approach where you use Unity lights on your foreground objects and SFSS lights for your background objects.

    The fourier series lighting I posted about a while back could do that since it stores something more like a simple light probe for each pixel. I think the idea is permanently stalled though. SFSS doesn't make enough to justify a rewrite, and Unity is missing a bunch of MRT functionality to do it efficiently. :(
     
  49. Lechuza

    Lechuza

    Joined:
    Oct 3, 2014
    Posts:
    19
    That's a real shame, I managed to get something going. The problem is the highlight masks are hand drawn, which goes well with this particular style but they are not accurate pertaining the light direction. I tried a hybrid system with Unity light and 2D lights mixed in (like a light prefab), the problem with that is since I don't know which 2D light is contributing to the lighting of that pixel I also don't really know which side of the normal map to light up, and Unity lights end up dictating the directionality of the highlights even though that "light prefab" is not reaching that object. Really unfortunate to see the current system, as good as it is, is not enough to get that effect.
     
    Last edited: Apr 21, 2018
  50. slembcke2

    slembcke2

    Joined:
    Jun 26, 2013
    Posts:
    263