Search Unity

Light shaft system

Discussion in 'Assets and Asset Store' started by MarkD, Dec 3, 2013.

  1. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    LightShafts 2 is finally here!



    Rewritten from the ground up in C#. Designed with the focus on intuitive and flexible usability.

    LightShafts is back and stronger than ever. The cleaner interface will please old and new users alike!

    Highly optimized, using as much shared meshes and materials as possible!

    Create dynamic light shafts that collide realtime during run-time or “Bake” them to gain an even greater performance boost!

    A lot of users requested a less confusing interface. So the clutter of settings in previous versions has been replaced in favor of a simple transform tool that handles every aspect automatically.

    Users can simply place a generator, drag the direction and distance to adjust angle/spread, and forget about all the struggles in the world.

    You can choose between 2 casting modes: the good old “Square cast” which uses rows along the X and Y axis to determine the amount of shafts spawned. Or “Mesh mode” in which each vertex position represents a shaft spawn location. Creating the possibility of beautiful complex shaft placements(for example light breaking through a forest).

    LightShafts 2 gives that extra ambient boost of light presence in any scene.



    FAQ:

    How do I get started?
    Simply go to GameObject->Light->LightShafts_2. This will place one generator in your scene.

    What is the performance?
    LightShafts 2 has been optimized to use as much sharedmaterials/meshes as possible. This makes it possible to use hundreds of shaft per generator. However even more performance can be squeezed out by baking the shafts into a single mesh (sacrifising dynamic features such as realtime collision). The latter is highly recommended for mobile/web platforms.

    I have two generators, but both use the settings of the first one. Can I use multiple generators using different colors/textures?
    The system uses sharedmaterials. Meaning if two generators use the same materials, they will get batched based on the first generator using said material.
    In order for a generator to use a different color/texture, simply create a new material, assign the lightshaft shader and place this material in the material slot (see inspector overview).


    Where is that cool LightShaft demo using the Adam movie interior?
    The demo itself is not included in the asset package because it is a full project. Which means it will adjust all your engine settings.
    There only exist a Windows 64bit build of this scene, because the project folder got corrupted during build. The 64bit was the first only only build to succeed. I might redo this scene in the future for other platform builds. But for now, the school room will have to do.


    Can I order a pizza? No, but you are always free to contact me for help or other asset related questions! http://markduisters.com/contact/








     
    Last edited: Nov 16, 2017
    hatto and Gozdek like this.
  2. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    Very cool. How well does it run on mobile? are the sun shafts some sort of additive shader variant? or a transparency thing. I find that additive or multiply shaders run great on mobile but regular transparency hurts frame rate like hell.
     
  3. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    I haven't had the chance yet to run it on mobile, it uses an upgraded version of the alpha blend shader, I am testing out if i can indeed achieve the same effect with an additive blend mode, because as you say it runs smoother. The shafts itself are objects, a 4 vertex plane applied with a shader. I am also working on a static casting so that the user can choose whether the shaders are dynamic or not, if they are not dynamic a lot more of them will be batched by unity. While being dynamic less portions of them will be batched (it depends on how they interact and how they change color).
     
  4. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    Static option is good to have, but if it in anyway uses a transparency variant... it will run TERRIBLY... even with 1 plane. I find that alpha or multiply works awesome even when there are like 10 layers over the screen.
     
  5. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    There is transparency possible in the case of the texture (can be customized by the user), yet this is not needed as black will automatically become transparent (Automatic alpha channel). Also the blending mode is alpha based from the blending colors alpha value/Channel. I am able to get a 20x20 (H,W) grid of rays, so about 400 rays and still run happy at 75-80 fps in a level. of course this will be more of a challenge on mobile devices. But that is also the reason the cast number is tweak-able and also the ray thickness. This way you can reduce the amount of ray's but occupy the same space, of course objects colliding in front will look less smooth, but it is a quality vs quantity scenario. You have to tweak around to find what is best fit for your project.

    version 1.1 will be on the asset store around 12-11-2013 (internet is not doing well enough to upload at the moment).
    The update will have the new static function in it, a cleaned up shader code (runs slightly faster) and a few minor fixes (not noticeable on the user side).


    Edit: above shader is no longer correct, the new shader uses addative blending and does not use alpha channels or alpha transparancy in anyway anymore. This increased performance drasticly and opened up more user friendly interface solutions.
     
    Last edited: Dec 15, 2013
  6. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    I meant to say additive and multiply not alpha and multiply.. typical alpha transparency wether it be cutout or regular.. runs like crap. Even if its one plane.. it depends on on the size it is covering the screen, but the more that overlap each other... the more multiplicative as a negative result on framerate it is.... Same parts of screen get rendered over and over... over draw. Unless of course you did something with additive shaders... which like I said runs awesome. You should try to figure a way of making it look good with that. Perhaps give it a max value to which it can add too so that it doesn't turn bright white with enough layers. If that is possible.

    Until then im pretty confident it wont be useful on mobile.
     
    Last edited: Dec 5, 2013
  7. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Maybe I will make a shader for mobile based on additive, only drawback is then that you can't control the light shafts brightness, because this is controlled by the alpha value. It will only have 1 type of brightness then, but i'l see if I can find a way around it then (do note that it was not designed for mobile devices in the first place, but I will work on a mobile compatible version as soon I have time).


    edit: I could try and create a workaround, using the saturation of the used color. This should automatically create more transparency in the additive type shader. If this works, I will merge both shaders, so both pc and mobile have the same workflow.
     
    Last edited: Dec 8, 2013
  8. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    I finished the new system updates sooner than expected.

    The new system is Windows,Linux,OS X and mobile compatible.
    It took me a while to figure out a good shader setup, but I decided to write a new one from scratch, which could be used on all systems. This certenly pay's off in performance as it has faster computations and less code to go trough.
     
  9. normalmaps

    normalmaps

    Joined:
    Feb 15, 2011
    Posts:
    48
    just bought it, just what I was looking for, thanks!
     
  10. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,121
    very interesting, cant check it out just yet, but definently will eventually. Glad you took my suggestions to heart.
     
  11. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    They where good suggestion, I must thank you for that, I did not think at mobile performance at all and since i was already re-writing most part of the system to be more user friendly, less performance intensive and efficient, it was a good moment to develop and implement them as well.
    The greates part is that with the new update and upgrade to the shader the systems performance is greatly boosted on pc machines and still keeps the same look, with enhanced color results.
     
  12. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    I hope you like i t:). An update to 1.2 will be on the asset store in a few day's, it is still pending.
    It has increased performance, requires less performance of the CPU and GPU to draw the shafts and the inspector variables are changed to a more logical order. The shader will then also be OS X, Linux and mobile compatible.

    If you have any questions you can always mail me (mail should be visible on the asset store).
    If you can't find the mail pm me then i will send it to you.

    Be sure to check your light shaft settings when updating, because you need to put all alpha values back at 255 as transparency is now handled differently, but everything will be found at the Update log in the light shafts folder.

    Also the manual is updated with new information (as soon the update is online at the store).

    A new video tutorial explaining the new inspector and variables will be online somewhere next week (with hopefully better English (sorry for that!) than the previous video (was pretty nervous). The link will be posted in the top as an edit.
     
  13. normalmaps

    normalmaps

    Joined:
    Feb 15, 2011
    Posts:
    48
    Hi, is there any way to get a cylinder kind of light shaft?

    EDIT: Using an object with a hole that's shaped as a circle is an option, but next to that?
     
    Last edited: Dec 10, 2013
  14. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Could you explain some more? Do you want the light-shafts to form a cylinder or do you want the shaft to look like a cylinder, if that is the case, simply create a texture (black and white) that mimics the shape. If you mean casting a cylinder, casting in other shapes are planned in the future, as for now they are casted by several loops, so only squares are possible (or cubes), until then you can use an object (invisible or not) to block the current rays, the system is still in its baby feet, but will be updated in the future to support either shapes, or to cast in a cylinder format.

    The system was generally created for square windows, so that is what it does best on the moment. Sorry if the current state gives you any inconvenience. I start designing update 1.3 as soon as possible and it will support your needs.

    EDIT: maybe send me a screenshot? It will give me a better insight in what you try to create.
     
    Last edited: Dec 10, 2013
  15. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    715
    great job man. Can it's work in android or ios?
     
  16. normalmaps

    normalmaps

    Joined:
    Feb 15, 2011
    Posts:
    48
    Yes the second one, casting in other shapes was what I meant. Anyway, after tweaking some variables I got the look and performance I was looking for!

    It really creates alot more atmosphere to the environment. great asset
     
  17. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158

    Thank you very much, it feels great that you enjoy it so much, I have made an update that makes it possible to cast cylinder shapes, they cast around the gizmo, so they are easier to place, I improved the interface, and added functionality for convenient previeiwing, deleting the shafts is now done with one single click, auto initialization of the settings while in editor mode and improved refreshing when going into play mode. I hope you enjoy.
     
  18. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Yes, the shader is written so that it will compile without a problem to OpenGL, so it should run on mobile devices. Keep note tough that mobile devices have less processing power and that you might want to take advantage of the static functions of the system to disable dynamic functions that cost some cpu power. Update 1.3 will be released in the upcoming days, finishing up some auto saving of the systems editor.
     
  19. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,620
    Could this perhaps be adapted to be a replacement for environment-wide shadows?
     
  20. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    @ imaginaryhuman

    Please explain yourself, I do not know what you mean by environment-wide shadows, as the system has nothing to do with real-time light mapping.
     
    Last edited: Mar 14, 2014
  21. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,620
    Well you have this volumetric effect which supports various colorations across the volume and that also means lighter/darker areas, so if you have a round window you have a round volume of light coming through, so in other words in a way you are creating shadows.... but I guess if you're not casting the shadows onto surfaces where the light hits it then its a mute point.
     
  22. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Wel simply said, the 'plane' that has the texture with the shader on it gets scaled, on hit it will change its scale. So you do have light canceling, but no shadow casting, if you follow my point. It is a system that 'mimics' volumetric light and not actually casts any light. It is even light source independent.
    So you can have an object moving in front of the shafts and thus occluding them from moving any further.

    you can try the tech demo, hold a chair infront of the projector, you will see what I am talking about.
    Tech demo

    Edit: Also for your round window part, yes indeed, you can cast trough a round window to get the shape, but the system supports a special cylinder cast for round objects, also the projector in the demo is using cone casting, with a inner and outer radius to be set.

    Of course if parts of only 50% are occluded you will get a volumetric shading effect of parts being brighter or darker than the other parts of the casts.

    I hope this answer helps you a little bit.

    greetings

    Mark Duisters
    Alzheimer Studio
     
    Last edited: Feb 14, 2014
  23. 3d_Artist1987

    3d_Artist1987

    Joined:
    Jul 9, 2012
    Posts:
    693
    useful asset:)
     
  24. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Thanks for your reply.

    Did you use it in a particular situation?
     
  25. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,562
    Added to my wish list. ;) Busy creating building models but as soon as I start working on interiors I'll pick this one up and give it a try.
     
  26. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Great to see you have interest in the system. If you have any problems (once picked up) or questions just mail me trough the support button on the store.

    Good luck with your buildings

    greetings.
     
  27. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Current users of the system read this!


    Alzheimer Lightshafts 1.5.3.1(hotfix):

    -Fixed system crashing bug that prevented shaft meshes from loading.

    It is important to download the lastest 1.5.3.1 version as version 1.5.3 had a system killing bug (only affects the light shaft system not unity) that prevented the LightShaft system from working.
     
  28. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,218
    Moved to Asset store forum :)
     
  29. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158

    Thank you very much for your quick response!
     
  30. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    sorry to bump this forum, but I couldn't find any newer forum.
    I purchased your version 2.0 lightshafts and I am unable to get the light shafts to nicely "fade out" like you show in your picture:
    fadeout.jpg
    Instead I get shafts that stop abruptly:

    nofade.png
    Can you explain the settings to get the shafts to nicely fade out like the picture you posted?
    Thanks.
     
  31. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    Here are my current shaft settings:
    shaftsettings.png
     
  32. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Hi there, first of all, thank you for purchasing. And don't worry about bumping, this is the main thread!

    What you wan't to do is increase your shaft width and change your falloff value, the falloff will slide/stretch the UV's to create a fade. Also for a basic window, I recommend using the default square cast (by deselecting all cast types).
    This will create better visuals.

    You can also always create your own black and white texture to place in the material, to customize your shaft's look.

    Below are the settings used in the screenshot.
    http://i.gyazo.com/7cde26f000157d15017dfea96654a742.png

    Notice that Mobile/SharedMaterial is checked, when using one or more generators that will be utilizing the same color, this option will create one material to batch with all shafts (every generator with this option checked will share this material). Thus saving allot of performance, especially for mobile devices. It will automatically override the color sampler.


    I hope this is of any help, be sure to check out this tutorial:


    greetings
    Mark
     
    ArachnidAnimal likes this.
  33. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    Ok thanks, I was able to make changes to the lightshafts by following your help and now it looks much better:
    afterLSchanges.png
    i was also able to half the number of shafts from 1000 to 500.
    Thanks.
     
  34. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    Hello,
    I am having another issue with the light shafts. I am trying to use cone casts but for some reason the shafts are only visible from one side. Then I move to the other side to view the shafts at a different angle and the shafts "disappear".


    When viewed from one side:
    upload_2015-6-4_2-44-51.png


    Now, looking at it from the opposite side:

    upload_2015-6-4_2-45-22.png
    The shafts are gone.

    Here are my settings:
    upload_2015-6-4_2-47-50.png
    upload_2015-6-4_2-48-6.png
    upload_2015-6-4_2-48-26.png

    Is there any way to prevent this?
    Thanks.
     
  35. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    What render pipeline are you using? Also check if no collider on your player is moving through them, this kind of clipping usually appears when distant colliders (which are on the same collision layer) touch the shafts (if collision is on). Otherwise try placing a new generator and see the results.

    You are always free to email me with screenshots/video footage, you will have a faster response time that way.
     
  36. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,218
    That really makes no sense from what I know about shader programming, none at all. Much more likely, your problem was you were using an expensive shader that did much more than just transparency, or for that shader you were doing strange things, because changing regular alpha blend to add blend shouldn't have any measurable difference.

    Were you by chance using alpha test or cutout? Cos thats far from being the same thing as alpha blending.
     
    MarkD likes this.
  37. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    I tried different combos of rendering path and color space:

    Forward, Linear = The same issue
    Forward, Gamma = no shafts at all
    Deferred, Linear = The same issue
    Deferred, Gamma = no shafts at all

    I also removed all colliders and meshes in the scene, and the same issue happens.

    for now, i set the global rotation of the shaft generator in such a way that when this happens, it is not noticed by the player.
    So this is not a huge concern for me. I am using linear color/
    I am not going to worry about it, i just thought maybe my settings were wrong/
     
  38. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    It is not a normal behavior from the generator. I will most definitively look into it.

    ps. are you using the plane delivered with the system? (Unity's plane do not have a back-face and are invisible from certain angles).
     
  39. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    I am using the plane delivered with the system. (pPlane1)

    upload_2015-6-27_6-19-15.png
     
  40. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Could you perhaps e-mail me a detailed explanation of your scene setup/settings, so that I can replicate the conditions.
     
  41. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    Yes. lll send you the project settings.
     
  42. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Does this work with Unity 5.2?

    Thank You
     
  43. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Yes, everything should work out of the box.
    Keep in mind that this system is not a post processing effect. But utilizes clones of it's generate mesh (included).
    You could place planes manually, but it would take a long time, where this system does it in a few seconds and includes features such as collision and real-time color changing.

    greetings
     
  44. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Well I have something like this:


    I would like to simulate an effect like this:


    This last image is a rendered image.

    Can I create some rays to make the "real game" look like the second, or at least close to it? I'm trying to add more effect into the first screenshot.

    Thanks
     
  45. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    That should be entirely possible, you can set the desnity (how many shafts) to be used.

    How about this, send me a small example project (scene) and I will create an example with it. So you can see wether or not this is what you want.

    Send it to the support email of the assetstore page.

    Link.
     
  46. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Well we just got the plugin. Let me see what I can do with it :D
     
  47. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    158
    Be sure to watch the setup tutorials.

    If you have any troubles/requests feel free to contact the supoprt email.
     
  48. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    I have send you an email
     
  49. Gozdek

    Gozdek

    Joined:
    Jun 21, 2015
    Posts:
    356
    Cool.
     
  50. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,625
    Hello,
    I've just upgraded the LightShafts from 2.0 to 2.1. I have two questions regarding the upgrade:

    1. The update log ("Update Log.txt") does not have info on the 2.1 change. Is this to be expected or could this indicate the update was not successful?

    2. For the rotation bug fix, do existing lightshaft generators created need to be replaced, or does existing lightShafts created from v2.0 automatically "pick up" the bug fix?

    Thank You.
     

    Attached Files: