Light shaft system

LightShafts 2 is finally here!

Buy
Non-Commercial download
Tech demo
Website
Tutorials

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! Contact | Mark Duisters








2 Likes

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.

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).

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.

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.

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.

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.

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.

just bought it, just what I was looking for, thanks!

very interesting, cant check it out just yet, but definently will eventually. Glad you took my suggestions to heart.

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.

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.

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?

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.

great job man. Can it’s work in android or ios?

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

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.

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.

Could this perhaps be adapted to be a replacement for environment-wide shadows?

@ 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.