9
2011
Black light shader (fake shadow)
My first shader test. I know there is already blob shadow, using “projector”, but wanted to try editing some shader examples. You set this shader to the object you want to receive black light from the spotlight.
Instructions:
Get the original code for the shader: Simple Specular
http://unity3d.com/support/documentation/Components/SL-SurfaceShaderLightingExamples.html
Then modify just 1 line,
find:
c.rgb = (s.Albedo * _LightColor0.rgb * diff + _LightColor0.rgb * spec) * (atten * 2);
Replace (or edit the line) with this:
c.rgb = (s.Albedo * _LightColor0.rgb) * ((1-atten*(_LightColor0.a*2)*1.5));
What it does: Attenuation is reversed “1-atten” and the black color strength is taken from “_LightColor0.a”, ie. spotlight Alpha setting.
Related Posts
1 Comment + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
I think a lot of people have been looking for something like this. I’m going to try it out. I hope it works with cookies and only darkens on side of an object unlike the projector.