Search Unity

Flat Lighting (FL)

Discussion in 'Assets and Asset Store' started by BogdanGochev, Jul 29, 2016.

  1. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Flat Lighting is an asset package which includes a complete lighting system designed for the creation of flat atmospheric graphic styles. It is heavily optimized for performance and works on shader models 3.0 and above.

    Tested on mobile and desktop devices.

    The package includes:

    - Custom lighting sources (spot, point and direct light).
    - Simple, but powerful and fast shadow mapping.
    - Custom lighting shaders. This includes surface shaders that interact with Unity lighting system and receive light from Unity light sources and not from the custom flat lights. The custom shaders include a powerful gradient lighting (Global, Local) on any axis (X, Y, Z or free).
    - Support for the new Lightweight Render Pipeline (LWRP)
    - Ability to bake shader in order to reduce compilation time (especially useful on mobile devices where the memory is limited).
    -Animated low poly water shader nicely integrated into the lighting system that allows unprecedented speed. Also includes a tool to create the water mesh.
    - Custom UI for all the tools in order to make them more easy and intuitive to work with.
    - Material Blender component to create stunning blend animation between different materials.
    - 3 demo scenes, one of which is fairly complex and includes the majority of the tools and settings included in this asset (this demo scene is used during the development of the asset).
    - Detailed documentation of the tool.
    - Modular code which is very easy to extend and adapt.
    - Requests can be made for new features to be included in the next update.

    Please note that this package does not contain any characters or game play mechanics. Only graphic assets, shaders, scripts and tools.

    Link Asset Store


    Screen Shot 2016-10-05 at 9.57.53 AM.png
    Screen Shot 2016-10-08 at 12.44.42 PM.png
    screen_978x867_2016-07-27_15-59-28.png
     
    Last edited: Jul 31, 2019
    schmosef, nuverian and ikazrima like this.
  2. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    Looks neat!

    Can you make a video demoing this?
     
  3. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Sure, I will make a video demonstration of the asset and will include the shadow mapping too. Just give me a couple of days.

    Edit:
    Here is a small demonstration of the tool. At the end of the video you can see the custom shadow mapping. (It doesn't have any audio, as I was busy fixing the asset for the unity 5.4 version)


    Added a new video with audio


    Using Unity Baked Lightmaps with Flat Lighting
     
    Last edited: Nov 8, 2016
  4. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    nice asset, but why is this happening to real-time shadows?
     

    Attached Files:

  5. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    As much as it's an interesting effect, it shouldn't happen. Are you using Unity shadows with flat lighting surface shader or the custom shadow projector ?
    It will be better if you just send me the scene and I can look into it.
     
  6. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    I am actually seeing this effect with your demo scene already...
     

    Attached Files:

  7. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Pretty weird, I'm not getting those artefacts on my machine. Could you move/rotate just a little bit the shadow projector (so it can refresh some of its settings) or try activating the "Is Real Time" field on it.
    Is this only in play mode or also in scene view ? Which version of unity are you using ? Have you tried closing and opening the Unity Editor ?
    I will continue to try to reproduce the problem.
     
  8. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    Hi, it basically happens everywhere in Unity 5.3. Updating to 5.4 helped :D But you might want to check into 5.3, in case other buyers use that ;)
     
  9. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    I have two other questions / requests:

    1. How do I prevent the lights to shine through (without changing the height)?

    2. The shadow projector is a box, how can I change it to a cylinder or a cone?

    Thanks!
     

    Attached Files:

  10. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Thank you, I have tested it with 5.3.4 and it was working just fine (actually I uploaded two version of the asset just for that case). What version of Unity were you using exactly,maybe is older than the 5.3.4 that I tested with ? In any case, I will try to run it with 5.3.0 and try to reproduce it the issue.

    1. You can just use different materials for the two boxes ,and just set the material of the bottom box to not receive spot lights. Like in these example that I attached.

    2. The shadow projector uses a technique called shadow mapping, which uses a camera to render the shadows. In my asset, an orthographic camera is attached to the shadow projector in order to render the shadows of the objects that the camera sees. As you can see, the shadow projector is limited by the shape of the Unity camera frustum, and as for now it cannot be change to different shapes.
     

    Attached Files:

  11. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    Sorry for the delayed answer.

    It was Unity 5.3.5.

    1. this will not help when I have a moving object and both need to react to the light ;)

    2. Got it, that's a shame, since the shape does not align with the light (circle).
     
  12. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67

    1. No, you are right. But as of now that's the only way to achieve what you want (statically). In order for the custom lights to do what you want (dynamically) some changes need to be done, and the asset will become more complicated to use and not so optimized. If you still want to do it yourself, I can help you thought (I kinda experimented with that while was developing the asset at the beginning)

    2. Just curious, why do you need the shadow projector to be shaped like the lights (circle) ? The shadows that are displayed still are going to be of the shape of the objects that casted them, regardless of the shape of the shadow projector.

    Have a nice day,
    Bogdan
     
  13. hnstbndr

    hnstbndr

    Joined:
    Sep 8, 2016
    Posts:
    10
    1. Would be nice, if you could show me the path on how do do it :)

    2. the sphere in the attached screenshots should not have a shadow, since there is actually no light.
    Screen Shot 2016-09-13 at 05.32.57.png
    But, the shadow projector is either too big or too small. In the example it is too big.
    Screen Shot 2016-09-13 at 05.32.49.png

    If I make it smaller I have (naturally) this:
    Screen Shot 2016-09-13 at 05.39.57.png Screen Shot 2016-09-13 at 05.40.08.png


    BR,
    Korni
     
  14. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    1. Sure, no problem, just send me your email or contact me directly by email and let's continue there.
    2. I see what you mean. When I was doing the shadow projector I was only considering the case for it to be useful with a direct light, and more optimized than the direct light shadows of Unity. On the other hand, I could research a way to limit it's effect to other shapes in the shader though.
     
  15. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Guys, I have completed a new big updated (v1.1).
    The biggest new feature is that now you can choose a gradient instead of a flat color for the Axis Light. Also added support for multiple shadows with different colors each. The last but not least is a ton of bug fixes and stability improvements that have been made from real world testing of the tool.
     
  16. pieterdhondt

    pieterdhondt

    Joined:
    Oct 13, 2016
    Posts:
    2
    Does this work on WebGL?
     
  17. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    @pieterdhondt It does support WebGL but only for the surface shaders. What that means is that you won't be able to use the custom light sources and custom shadow mapping. For the rest of things should be fine.
    I added a little demo for you to check out (the water is animated in the shader so there is no CPU performance cost)

    http://bogdangochev.me/FLWebGL/index.html
     
  18. pieterdhondt

    pieterdhondt

    Joined:
    Oct 13, 2016
    Posts:
    2
    Thanks for the reply, it looks good :)
     
  19. Megalithic

    Megalithic

    Joined:
    Apr 21, 2014
    Posts:
    61
    Hi,

    I got your asset looking at the quality of shadow that you demonstrated in your tutorial video. But for some reason I can't seem to get the kind of shadows that I want. Have a look at the image that I have attached. The arrows points at sharp edges on shadows that look really ugly. Can you tell me how to get rid of it.

    I am using your package on mobile game development and on an android platform in the build settings.

    Looking forward to you assistance.

    Regards
    Imran
     

    Attached Files:

  20. Megalithic

    Megalithic

    Joined:
    Apr 21, 2014
    Posts:
    61
    Hey,

    Dude I am in a bit of a problem. Your asset is not working for me on my phone ( Galaxy s4). I created a simple scene with your flat lighting materials then built an apk to try it out. Once installing it on my phone the game doesn't even load. I tried swapping your materials with unity standard materials and they work fine.

    Can you please let me know how to solve this issue.

    Regards
    Imran
     
  21. Megalithic

    Megalithic

    Joined:
    Apr 21, 2014
    Posts:
    61
    Dude you have a great asset, it would be a shame if you stopped supporting it. I really need an answer from you.
     
  22. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Hi @Megalithic, i'm sorry for the late response. I was away during the holidays so i didn't check the forum.

    The artefact that your are getting on the shadows is called shadow bias and there is a setting for it in the shadow projector. But probably is something to do with your scene setup. Check if the shadow projector is not too far away from you object as the shadow projector uses shadow mapping to render the shadows.

    About your other issue and the asset not working on mobile, can you provide a bit more information about what is the error? I have tested and deployed games with this asset on both Android and iOS and it always has been working fine for me.

    Cheers.
     
    Last edited: Jan 16, 2017
  23. Megalithic

    Megalithic

    Joined:
    Apr 21, 2014
    Posts:
    61
    Well, when I tried installing and running it, I would only get the "Made with unity" scene and then it crashed.
    Apart from that I don't know whats wrong with it.
     
  24. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Ok, can you send me on my email the minimal scene that is causing the problem and I will test it and try to reproduce the crash.
     
  25. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    A new update is in the works. But before it's officially released, I just wanted to share with you guys the new Material Blend component. It lets you create nice smooth blend animation between different Flat Lighting materials.

     
  26. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    I simply can't import this asset and always stuck at
    upload_2017-2-4_11-35-13.png
    Both on Mac and windows.
    I'm using Unity 5.5.1
     
  27. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Hi dearamy,
    I just tested the asset in Unity 5.5.1f1 and it was working fine, but it took Unity 15-20 mins to import and compile the shaders. Here is a screenshot to demonstrate the asset running.
    Screen Shot 2017-02-04 at 1.58.34 PM.png
    How long did you wait on the import screen?
    I will upload a new version for Unity5.5.1 on the asset store but it will be available for download after a couple of days (not my fault but Asset Store approve period).
     
  28. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    I've waited about 5 minutes, then I killed the process.
    Did you mean it was supposed to be that long, you know, just import a 10M sized asset?
    And how long will the new version take?
     
  29. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Yeah, you should wait a bit longer. I was using a 2016 mac book pro and got a waiting time around 15-20 mins. It's not about the size of the asset, bit the complexity of the shaders. For example, one of them has around 205 000 variants!! I make use of some methods to reduce that number but it's still a lot of work on the first import. This many variants makes the shaders easier to use and perform faster on runtime, but at the expense of longer compile times. So even if the asset is small there is a lot of computation that Unity has to do in order to use it appropriately.
    I'm not sure how long the new version will take as it will depend on the hardware that you are using and also if Unity Asset Store does some optimization to speed up import time.
    For now I will suggest you to just import the asset and then grab a cup of coffee. Once the asset is imported, you will have the ability to bake shaders, and you can remove the full variants, to speed up future imports or to distribute your own variants. If you are interested in shader baking you can look at the documentation or just ask here.
     
  30. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Have these two issues been fixed? I'm considering purchasing this asset package as an in-game flashlight for my character, but these two issues will prevent me from achieving the desired effect.
     
  31. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Hi reinfeldx, thank you for the interest into my asset.
    Regarding your questions :
    1. I crated a new shader that can interact with Unity lights and you get this issue fixed with it.

    2. If you go with my custom shadow projector then you are always going to get the shape of a box because it was done to be used as a shadow caster from a global direct light (like sun).

    That being said, you can definitely use my asset as a flashlight. Just use the FlatLightingCelSurface which receives lightning and shadow information directly from Unity lights and transforms them to nice flat lights and shadows. After that, you just attach a normal Unity Spot Light to your flashlight and you have it.

    I'm not sure exactly what type flashlight effect you want to achieve, but if my asset doesn't supports it I will make a refund for you.
     
  32. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Hey thanks for the quick reply. This is probably a dumb question, but here it goes: can your lights selectively affect unlit materials?

    My game requires that I use unlit materials to get the flat color effect I need. An example here:



    I'm using two colors for everything—a light green and dark green. If a cube happened to be colored dark green, it would appear invisible against the dark green walls. In that scenario, I'd like to be able to use a flashlight with the light green color to project onto the dark green walls, but I would need that light to ignore a dark green cube (to make the otherwise invisible dark green cube stand out against the projected light green light).

    Does this make sense? Do you think it can be achieved with your tool?
     
    Last edited: Mar 20, 2017
  33. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    If I understand you correctly, you can achieve this effect with my asset. The only thing is that instead of unlit shaders you have to use my FlatLightingCelSurface shader. Also, to make the lights not affect some specific objects, you just need to activate the culling mask on the Unity Lights (remember that with the FlatLightingCelSurface you just use normal Unity Lights).
     
  34. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Here's a gif that better illustrates one of the effects I'm trying to achieve. I've got a primitive flashlight set up that can accept a mask and not affect certain objects. I think that's pretty straightforward, but my other concern is that I can still get a completely flat, unlit appearance from all the surfaces in my scene.



    So you think I'll be able to replicate the color effects here with your tool?
     
    Last edited: Mar 20, 2017
  35. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    First of all, I like very much what you have done here, and now I'm curious about your project ;)

    I'm not sure how you did your flashlight effect and the outlines on the walls. You will probably have to adapt those for my asset (I can help you with that). But for the rest you can definitely use my asset.

    Btw if you have already setup (flashlight, outlines, etc.) why do you need my asset at all, seems like you won't benefit that much from it ? Or maybe a better question will be, what part of my asset you want to use and I can tell you if they will be easy to integrate into your project.
     
  36. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Thanks for the kind words :)

    I've tried a couple different techniques for the wireframe outline on the walls and I'm still working that out—I'm not happy with the performance of what I have. Worst-case scenario is that I'll go back to Unity's legacy toon outline shader, but I don't quite like the look of that one either.

    The flashlight effect above is a decal attached to my camera and projected onto the surfaces that aren't masked. The problem is that I haven't worked out how to project the decal in a cone shape similar to a spotlight. Here's the issue:



    As the "light" (decal) moves closer to the doorway, one would expect it not to project onto the sides of the doorframe. Hence the need for a cone-shaped projection.

    I might be able to figure out my decal implementation here, but I've been wondering if your lighting system would be the way to go.
     
  37. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Ok, I think I understand better what you want to achieve with my asset.
    Currently FlatLighting it only supports circular shaped lights (you can see them in the screenshots). I'm considering putting other shapes as lights but I cannot promise when they are going to be put (I will make some experiments over the weekend)
    The good thing about my light system is that everything is done in a shader and I would assume that is more performant than the decal that you currently are using.
    In any case, you seem to have some really specific requirements and my asset will take you only that far. Most definitely you will have to tweak some things to make them the way you want, but at least you can start from something already build and I think will be much easier than starting from scratch.
     
  38. reinfeldx

    reinfeldx

    Joined:
    Nov 23, 2013
    Posts:
    164
    Thanks for the info. Actually I am not looking to reproduce my square-shaped light here, if that's what I implied. A circular-shaped light would be fine, I just need the projection to be cone-shaped (for the light to appear like a larger circle from far away, and smaller up close). I think that can be done with your system.
     
  39. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    If you are not searching to reproduce the same flashlight shape, then you can use my asset for the flashlight. The light will be always cone shaped for the spot light source.
    There is documentation in the asset and also a big test scene that shows a lot of the features, so just play with it to find out how everything is wired.
    If there is anything else, just write me an email or post it here.
     
    reinfeldx likes this.
  40. chiragchopra

    chiragchopra

    Joined:
    Sep 23, 2013
    Posts:
    4
    Hey, is it possible to achieve similar style with the help of your asset?
     

    Attached Files:

  41. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    That's not even flat, that's just unlit.
     
  42. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Hi,
    As macdude2 mentioned, the style that you show is just unlit with hard shadows. You can definitely achieve that look with my asset but it will be a bit overkill.
     
  43. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    On the terrain in the screenshot above, I still see the 3 intensity rings from the lights cutting across the polygons. Is it possible to hide these perfectly circular shapes and just show the appropriate intensity across the entire polygon it hits?
     
  44. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Hi eobet,
    I'm sorry but I don't understand what exactly you meant. Here is a image that you can achieved with the asset of different scenarios that I understood (but probably are wrong).
    If it's not what you asked, please can you elaborate more or event better show it with an image ?

    test.jpg
     
  45. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176


    In other words, I want the lights, spot, directional, omni, but only on the entire polygon. No gradients (like with default Unity shader), no halo cutting across it (like with the three rings). Just all or nothing.
     
  46. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67
    Ok, I understand it now. That is quite an interesting effect and I may add it in the future but currently it does not support such lighting. The shaders in the asset are open source so if you want you can edit them to support it (but it may not be trivial change)
     
  47. eobet

    eobet

    Joined:
    May 2, 2014
    Posts:
    176
    Ok, thank you for the information!

    I will continue searching, as I do not know how to write shaders.
     
  48. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hi @BogdanGochev,

    I bought your Flat Lighting asset during the recent mega sale.

    I've been playing with it today and I think it is very promising. The mobile performance is very good.

    I was just trying out the concepts in your intro video and ran into some odd behavior with the shadow projector. It seems to be projecting an inverse shadow; black where it should be clear and clear where it should be black.

    I've attached a screenshot. Is this a bug or am I doing something wrong? I can send you a link to download a copy of the project if you like.

    ShadowProblem.png

    Edit: I just did an iOS build with my test scene. The shadow is definitely not rendering correctly.

    IMG_0014.PNG
     
    Last edited: May 8, 2017
  49. BogdanGochev

    BogdanGochev

    Joined:
    Sep 17, 2015
    Posts:
    67

    Hi @schmosef,
    Thank you for buying Flat Lighting.
    I checked your scene but for me it opens fine.
    Screen Shot 2017-05-08 at 9.00.40 AM.png

    Before opening your scene I had to reimport the project so I have a feeling something in there is wrong. One thing that I noticed from your screenshots is that you use Unity Editor on Windows but you are exporting for iOS ? I have never tried that scenario and maybe Unity does something strange with the shader compilation in that case.
    Also what about when you open the demo scenes provided with the asset, are the shadows there also wrong ?
    I don't think is something with your scene but more with either the compilation of the shaders goes wrong or something else.
    Can you try changing the compilation target to Desktop (but native, like if you are running Unity on Windows set the target to be Windows) to force recompiling.
    On my end I will investigate more as well.
     
  50. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Hi @BogdanGochev,

    Thanks for the quick response.

    I did not include the Library folder in the project I sent to you. So when you opened it, it would have had to re-import the assets and re-compile the shaders. I'll include the Library folder next time to prevent this.

    I also notice that you are using Unity version 5.6.0f3 and I was using Unity 5.6.0p3. The difference in version would also cause the Library folder to be re-built.

    I use this asset for Building iOS projects on my (high end) PC. This saves me a lot of time because my iMac is fairly old/slow. I haven't had an issue with this before but anything is possible.

    A new Unity patch version was released today. I'll use the new version to create a new test project from scratch and build the iOS project with Unity Cloud Build and also my iMac to compare the results.

    I'll let you know how it goes.