Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Light shaft system

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

  1. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    It is not an image effect, but a generator that uses planes with a custom shader. The shader is based on Unity's additive shader. It is not a image effect such as Unity's sun shafts and thus does not use depth maps or other objects for the lightshafts.

    So in short, no the system will not hook up to a dynamic alphatest material in order to emit lightshafts from visible parts of a mesh (it does not even do that for default meshes).

    The system works like this. You place a generator in the scene, follow the setup in the inspector and done. The generator will cast shafts based on its settings and multiple generators can be placed in a scene.

    You can however, you the vertices of a mesh to cast a "different" shape. For instance if you have a forest with multiple clearings. It is way more performance efficient to cast shafts in one generator, rather than place a generator in each clearing. So the user can create a mesh representing the clearings of that forest, place the as much vertices as one wants to cast shafts and feed that in to the generator as positional data for the generator to place shafts (this can be seen in the demo scene's underwater level).

    But as I said before, the system does not take any depth map or alpha test into account.

    The system is tested on Linux Ubuntu but not on Mac. But should work without a problem.
    You can download the demo and see it for yourself, it has a Windows, Linux and Mac build. (you need 7-zip or winrar to unpack)
    https://www.dropbox.com/s/nsz3n1wn2gjn559/Alzheimer LightShafts 2_6.7z?dl=0

    I hope this information was of any help

    cheers
    Mark
     
    yuvsv47 likes this.
  2. noakapla

    noakapla

    Joined:
    Mar 28, 2017
    Posts:
    1
    Hi! I am enjoying the generator, but I can't seem to get the Sample Color option to work. Is there a tutorial that goes over the set up? Many thanks!
     
  3. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi there,

    First of all, in order to use color sampling, multiple materials will be created to accommodate the color variance among shafts. This will significantly impact performance. However, if you already used the generator without mobile/sharedmaterial support "off", the difference will not be that noticeable, as this approach also creates multiple materials for the generator.

    Raycasting (physics) is used to detect hit and sample points of textures "behind" your generator's shaft normal direction. For example a stained glass window's colors behind the generator will be sample by the shafts directly in front of its pixel.

    In order to use color sampling you must first turn off (Phase 3) mobile/sharedmaterial so that multiple materials can be created.

    Then you must prep your texture to support read/write: -Select the texture you want to sample in your asset folder, -Make this texture read/writable with advanced settings.



    upload_2017-3-30_13-53-39.png

    Lastly make sure that there are no colliders (except the collider on the object containing the texture) in front of the object, so that the ray can properly hit the object containing the texture which needs to be sampled.

    In the example folder you will find a pre-prepped texture (as seen in the image above). You can always look at that texture and at its object in the scene (projector lens) to get an idea of the setup.

    I hope this helped.

    greetings


    ps.: Some older (but still relevant) tutorials can be found here http://markduisters.com/project/alzheimer-lightshafts-tutorials/
     
  4. STARFLEETJUNKY

    STARFLEETJUNKY

    Joined:
    Feb 18, 2013
    Posts:
    7
    Hi. we have recently updated to the latest version,we now have these issues... when you press the eye to update the shafts in scene, they change regardless of any changes made. Sometimes they are visible and sometimes they are not. And Light shafts that are clearly visible in the scene window are invisible in the game window.
     
  5. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    Sometimes the scene view has indeed a wrong representation of the game view (I am still researching this issue).
    The reason the shafts are not visible is probably due to the shaft falloff being at a wrong value. For some reason this is different during run-time (although all values are the same). For the time being a fix would be to ga into game view, tweak the shaft falloff until your liking and after that use those values in the sceneview.

    Let me know how it goes.

    greetings
    Mark
     
  6. STARFLEETJUNKY

    STARFLEETJUNKY

    Joined:
    Feb 18, 2013
    Posts:
    7
    Hi just tried the above work around, it still wasn't visible when pressing play...We are currently on version 5.2.3 of unity due to the material issues we can't upgrade. would this cause problems? if so is it possible to download older versions of light shafts...
     
  7. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    This should not cause problems, as the shader used should be compatible.

    If you e-mail me your invoice number, I will make a build specifically for Unity 5.2.3.
    http://markduisters.com/contact/
     
  8. LuckyPatrick

    LuckyPatrick

    Joined:
    Oct 11, 2017
    Posts:
    5
    Hi I'm wondering if you can help me with setting up multiple lightshafts in my project. The instructions in your documentation and website don't seem to work. I have 2 different lighshafts set up and I've added a different material to each one under the material slot in the inspector. But when I hit generate on either of the lightshafts after setting them up how I want, the other one is changed to those settings too. Am I doing something wrong here?
     
  9. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    The tutorials on the website are for the previous version of LightShafts, updated ones are in the works.

    In the meantime, could you share a screenshot of your inspector?
    Make sure the shader in the material is set to the lightshaft shader.
     
  10. LuckyPatrick

    LuckyPatrick

    Joined:
    Oct 11, 2017
    Posts:
    5
    Thanks for the reply, I've attached two screenshots of the inspectors for each lightshaft object. Notice they both have different materials but when I hit generate on either one, the other one is changed too. But also, when I go to play mode both are changed back to the original lightshaft I had set up.

    Also, I'm pretty sre I have the correct shader applied to each material
     

    Attached Files:

  11. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    That seems all to be correct,

    How did you place the generator? GameObject-Light-LightShafts.
    If you placed the prefab directly from the folder, then you are changing its default settings. Thus every generator that you have placed with said prefab directly from the asset folder is a linked clone. Placing it through GameObject-Light-LightShafts will create a standalone instance of that prefab, giving you the ability to tweak.

    If not, send me a detailed email to http://markduisters.com/contact/
    So that I can help you quicker, I check my mail a more often than I do the forums.

    Greetings,
    Mark
     
  12. LuckyPatrick

    LuckyPatrick

    Joined:
    Oct 11, 2017
    Posts:
    5
    Ok, no joy. I've emailed you a more detail description of what's going on
     
  13. hatto

    hatto

    Joined:
    Nov 9, 2008
    Posts:
    31
    HI Mark, I have the previous great version and have saved the shafts settings that I have created for my projects. The trouble is that your new version shows this setting file ghosted when i tried to import it. Do I have to remake all my shafts in the new version?
    Thanks in advance.
    Hatto
     
  14. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,
    The preset files have some new additional information that will be saved with them, however the system should be backwards compatible with older versions. It will simply read in the old data and ignore the new (missing) data.

    Normally you should be able to load your old files. However if the file is still ghosted, then you will have to remake them for the new version. (some handlings in the system have changed, so even if you load old files, it is best to still tweak those and re-save them, lots of settings are now handled by an editor tool instead of putting them in manually).

    If you keep having this issue, feel free to send an email: http://markduisters.com/contact/
    Through mail you can send more info/files, so that I can replicate the issue.

    Sincerely,
    Mark
     
  15. hatto

    hatto

    Joined:
    Nov 9, 2008
    Posts:
    31
    HI Mark, I guess as the saved set-up files show as ghosted in the new version I'm stuck with remaking all the shafts. Not something I relish at this stage, as it was time rather time consuming to get the look I wanted. I thought I might be able to replicate what I had by entering the same settings from the old version but most of those settings are not user settable from what I can see in the updated version so it looks I I will have to start from scratch. I do wish I hadn't updated the plugin without looking deeper. But there you go......
     
  16. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,727
    Using LightShftas2 1.03 I've added a generator to the scene. I crated a material in asset folder, and assigned this to the "Material" field of the generator. When I click "Generate", the system generates LightShats using the defualt "LightShaftMat".
    Shouldn't the shafts be using the material I specified in the Generator material field?
    ddd.png
     
  17. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    That should indeed not happen, on generation that material should normally be used as a batched material for that system/systems using that material.

    Could you send me a mail with some more details. I have a suspicion where the bug originates from, however you are the first to report it, So i would like to have some more detailed information about your setup.

    Sincerely,

    Mark

    Edit:

    I repeated some steps I could observe from your screen shots, but was unable to replicate the problem. Simply created a new generator, new material (set with the correct LightShaft shader) and it was correctly added to the generated shafts as normal.
    Inspector.JPG

    2.JPG
     
    Last edited: Jul 30, 2018
  18. joncoughlingames

    joncoughlingames

    Joined:
    Nov 10, 2018
    Posts:
    5
    Hi! I purchased your asset hoping to use it for long-distance spotlights as in the image below. Do you have this functionality built-in? Some observations and questions:

    1. When I set my shafts down to 1x1 they appear with a boresight angular offset - is this expected?
    2. Does the asset have a way to scale the shafts radially over long distance? Or will I have to provide a mesh to represent the gradually widening light beam?

    Thanks, the asset looks very powerful :)

    upload_2020-1-24_8-18-56.png
     
  19. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,
    First of all, thank you for showing interest!


    On your questions:

    1:
    The shaft placement has a slight randomization offset on their Z axis, however this should not have any influence to the angular offset itself.

    Could you tell me a bit more about your setup (or email me a preset file of your setup, simply save it through the generator).

    2:
    - In case of shaft distribution:
    All placement different than a regular gird should be done through a custom mesh. The mesh itself is not used, rather the vertex positional information. So topology does not matter.

    -In case of scaling the outer ends of the shafts over a distance. You need a custom mesh. You can use the default plane as a reference, keep in mind that the UV layout of your shaft should be a 1-1 UV square.

    If you need more info, feel free to contact me through mail.

    Sincerely,
    Mark
     
  20. ludum_mubul

    ludum_mubul

    Joined:
    Dec 9, 2016
    Posts:
    27
    Is it support VR with single and multipass rendering with or without stereo rendering?
    @MarkD
     
  21. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,
    VR is untested at the moment, so there is no official support for it yet.
    However users have reported single pass VR to be working.
     
  22. ludum_mubul

    ludum_mubul

    Joined:
    Dec 9, 2016
    Posts:
    27
    Is there any way to get demo version of this for test purposes?
     
  23. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I can make a demo build for each VR mode so you can test them out.
    https://markduisters.com/contact/
    send me a contact email with a reminder. I will mail the download links directly to you.
     
  24. ludum_mubul

    ludum_mubul

    Joined:
    Dec 9, 2016
    Posts:
    27
    Dropped you an email through your contact from
     
  25. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,475
    Hi there, is there a way to stop the shafts from animating with the brightness/transparency? I can't see this option, I just want a static shaft. Thanks.
     
  26. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    The animation originates from the "movement" of the caustic noise calculation that is used for the dynamic effect.
    The movement is based on the gpu time. I could expose a few variables to give you control over this (You can already control the panning direction along the UV's).


    I will update the Non-Commercial and Licensed AssetStore versions with the exposed time value.
    Thanks for pointing this out.

    In the mean time if you want to do a dirty fix yourself (and you own Amplify shader editor) you can open the base shader node network to lock the time speed to 0. If you open the Shader through a regular code editor try to find the line with "Time" or "TimeScale" and set the multiplication to 0.

    Update should be live somewhere in the upcoming week.

    Mark
     
    khos likes this.
  27. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,475
    Many thanks MarkD, I do not have Amplify shader so will look forward to an update via asset store.
     
  28. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi

    The update is finished and should be live this week.

    The non commercial version is already updated if you want to check it out early.
    https://markduisters.com/project/alzheimer-lightshafts/

    The new parameter is called Noise update speed. When set to 0 the animation will freeze and the shafts will be completely static. Keep in mind that the Noise direction axis are multipliers that rely on the update speed value. So when the update speed is 0, the direction will also be 0.(which is what should happen, otherwise the animation would continue in a single direction.
     
    yuvsv47 and khos like this.
  29. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,475
    Great stuff, thanks Mark!
     
  30. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,475
    Hi Mark,

    Not sure if the update is come through yet for the paid version (I have that), in meantime I got the updated non commercial version, the noise update speed parameter work nice! Now I have another question if that is ok: How do I make the light shafts fan out? Currently they all point in one direction, i.e straight down, e.g.:
    upload_2020-5-21_22-41-58.png
    I want to be able set a spot light angle. Is that possible as lights tend to have that effect?

    Minor thing, also I see an error if I am in scene (Unity 2019) mode and have gizmos enabled:
    FileNotFoundException: ../Assets/LightShafts/Source/Resources/UI/LightShaftGizmo.tif does not exist
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <437ba245d8404784b9fbab9b439ac908>:0)
    System.IO.File.Copy (System.String sourceFileName, System.String destFileName) (at <437ba245d8404784b9fbab9b439ac908>:0)
    Generator.OnDrawGizmos () (at Assets/LightShafts/Source/code/Generator.cs:323)
    Not sure if you have seen this before?
     
  31. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    I think you are receiving the package for Unity 2018.4.14 which is the previous build.
    Unity 2018.4.22 has the new feature. I always release updates on the latest LTS version of Unity.
    However if you have a paid license, you can simply merge the non-commercial version as the non-Commercial license does not apply on paid license owners (you can read this in the non-commercial license file).

    upload_2020-5-22_11-48-17.png

    The error you showed occurs when the Gizmo folder is not included/deleted. Normally the system should detect this and create the proper folder and files by itself (it is used to draw the gizmo in the editor). So you can check if A Gizmo folder exists, if so then the system has fixed the issue by itself and the error should not happen again.


    Edit: I forgot about your spread/fanning question. There are 2 options:
    -Move the ShafDirection pointer closer to your system. This will spread out the shafts.
    -For a very specific shape and orientation you can combine the above and the use of the MeshCast mode for this, input a mesh and the vertex positions will be used as origin points for the shafts. So you can use your 3D editor of choice to create meshes for this.
    Example: https://i.gyazo.com/5c19b3b36ed45de99df7deebb62fd91a.gif
     
    Last edited: Jun 17, 2020
    yuvsv47 and khos like this.
  32. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Hi! I was checking your plugin but the tech demo 64bit versions are missing the UnityPlayer.dll and can't run.
    Can you reupload them with the missing DLL?
    Thanks :)
     
  33. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi, thanks for reporting. I will take a look at the files, which platform showed the issue.
    Meanwhile if you want to test out the asset in Unity you can always download the Non commercial version:
    Non-Commercial download
     
    yuvsv47 and atomicjoe like this.
  34. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    128
    Hi I'm trying out the non-commercial version in 2020.3.36 of Unity before buying the real thing and after filling out everything in the Generator script I get an error when I try to generate:
    Code (CSharp):
    1. UnassignedReferenceException: The variable lightShaftPrefab of Generator has not been assigned.
    2. You probably need to assign the lightShaftPrefab variable of the Generator script in the inspector.
    There is no such 'lightShaftPrefab' object in the generator inspector. Anything I could be missing?

    The example works until I reset the object and populate it with the same data, then I get the same error. Seems that whatever system that generates that prefab isn't working in this version of Unity...
     
    Last edited: Jul 18, 2022
  35. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Are you working on a lower version of Unity? Prefabs can break as they are not always backwards compatible.

    I have tested it in the latest version of Unity without a problem. However I will have a look in earlier builds.
    (LTS builds that is.)
     
  36. HunterAhlquist

    HunterAhlquist

    Joined:
    Oct 6, 2013
    Posts:
    128
    I'm using 2020.3 LTS.
    sorry, I should have said that
     
  37. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Ok, thx for the info. Will check it out soon.
     
    HunterAhlquist likes this.
  38. yuvsv47

    yuvsv47

    Joined:
    Nov 2, 2022
    Posts:
    16
    Hi!
    What means this ver?
     
  39. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    It means that version is a trial version that you are not allowed to use for commercial work, so you can't sell anything made with it. It's meant for testing it and, if you like it, just buy it HERE.
     
    yuvsv47 likes this.
  40. yuvsv47

    yuvsv47

    Joined:
    Nov 2, 2022
    Posts:
    16
    Roger that!
    I need to try this; because it works with the 2018 version!
    and since it is the 2017 and 2018 versions that are optimal for me, I will try this package now! Stars!!!
     
  41. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    I have problem! - With trial-package I so that picture:

    AS in Un2018-4.jpg

    There is no such material - LightShaft_RP - anywhere!
    What should I do with it now? :D:D:D:D:D:D:D:D
    (UNITY-2018 !!!)
     
  42. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    To be even more specific, the problem is that this shader is unsupported!!!
    What to do?
    AS in Un2018-4 - shader-not-support.jpg

    And this in unity2018.4 !!!
     
  43. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    Please explain how to solve this problem. How to replace this shader, which is not supported by my GPU ?
    I do not understand anything. I don't feel like playing puzzles at all. What shader can I use to replace this one, so that the rays will display properly?
    GPU-Trouble.jpg
     
  44. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    Hi,

    It if there is no material by default. You can create one and assign the shader. Drag the material in the slot and everything should work.

    If the gpu does not support the shader (which is weird because it is compiled with shadermodel 4). Then there is not much you can do.

    If you send me some information here of your system, i can have more insight in the problem.

    The gpu had to be very old to not support that model.
     
    Nocilli likes this.
  45. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    Thank u Mark!
    Hmm...
    The GPU is really old - NVIDIA GeForce 8600 GT .
    But then question number 1:
    - So I can just choose any other material with any shader for the light planes?

    Question number 2:
    - until I imported Amplify Shader Editor into my project, your Generator wouldn't even create the light planes themselves!!!
    And this is what's really freaking me out.
    Can't your package work without Amplify Editor ?

    When I added the "Amplify Shader Editor" package to the project, and used it to switch the shadermodel version to 4, the shader became visible. But it became completely transparent. And as a result, the light beams in the scene are still not visible.
    (And the very unpleasant fact that it required installing the Amplify Shader Editor. Is there any way to do without it?)

    And a probable third question, as a result of the first two previous ones, is it then possible to try an earlier version of this generator?
    (which was written for Unity5)
    (does that make sense?)
    Thanks for your help!
     
  46. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    MarkD, I will add a little something new to the previous one:
    - your demo scene finally opened normally, and I saw this effect.
    And the settings work as they should.

    But in my new empty scene the planes of light beams of the generator remain invisible!

    AS in Un2018-4 Ttouble.jpg

    That's why I want to understand - just this generator will not work?
    Need some additional manipulation with the settings of other properties of the scene and project?

    So far I see constant reference errors:
    AS in Un2018-4 reference error.jpg
     
  47. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193

    Hi, I think there is some confusion.

    1: No you can't just use any "shader", as the system talks to specific properties of the shader that belongs with the system.

    2: No you do not need amplify at all in normal cases. As stated on the product page the latest LTS versions should always work and versions below that are deprecated. The reason why it works with amplify is because the shader is compatible with Amplify and people using Unity versions that are out-dated/no longer supported can indeed re-compile them again with amplify for their older versions of Unity. The other-way to compile without amplify is to do it the classical way and write a shader yourself utilizing the same properties, or create a shadergraph shader in modern unity version (which again, is not needed as the package works on modern LTS versions of the engine).
    The reason your shader became visible again when opening it in amplify is simply because it got recompiled for that version.

    3: As stated above only the latest LTS versions are officially supported which at this moment are 2020LTS and 2021LTS. I only support official LTS versions of Unity, since Unity themselves no longer supports outdated deprecated versions of the engine. As mentioned above if you want the shader to work on older versions, you have to compile it yourself.

    I am quite confused as to why one would use Unity 5 as it was released in October 3, 2017. Which would not make much sense to support as practically no one is using that version anymore neither is it supported by Unity anymore.
    Lastly you are claiming to use an Nvidia GT 8600 GT, which is a gpu from 2007. You can't expect current shaders and assets to work out of the box with such an old card.

    I hope this answers your questions
    Sincerely
    Mark
     
    Nocilli likes this.
  48. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    How did you create the asset in your scene? Reference errors should not be happening if you spawned it in properly through the menu.

    If you give me the Unity version you are trying run. I will download it and see for myself. Then I can answer more correctly on your issues.
     
  49. Nocilli

    Nocilli

    Joined:
    Nov 12, 2022
    Posts:
    12
    Hi MarkD !
    Thank you for the explanation!
    I use Unity 2018-4-36.
    I chose a different shader in the inspector, and at least somehow saw your effect.
    AS in Un2018-4 - altershade.jpg
    I'm really bummed that I have such an old computer and that I have to give up this beautiful effect.
     
  50. MarkD

    MarkD

    Joined:
    Sep 18, 2013
    Posts:
    193
    No worries.

    I have some time tomorrow to check the system in your particular unity version. And I will see if I can compile a custom shader for your older gpu, I think I might be able to get it to work for you. However it will take some time and I have non free today. Expect a test sample somewhere in the upcoming week
     
    Nocilli likes this.