Hello everyone. I'm new here, and always try to make everything by my own, but shaders is my problem. Searching in internet, dont make any results. I make a custom shader, from few others. I make a 2D game without any light sources in scene, and my shader using diffuse, but I need effect like in self illum shaders. This is my code: Code (csharp): Shader "Example/Slices" { Properties { _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0) } SubShader { Tags { "RenderType" = "Opaque" } Cull Off CGPROGRAM #pragma surface surf Lambert struct Input { float2 uv_MainTex; float3 worldPos; }; fixed4 _Color; void surf (Input IN, inout SurfaceOutput o) { clip (frac((IN.worldPos.y+IN.worldPos.z*0.1) * 5) - 0.5); o.Albedo = _Color.rgb; } ENDCG } Fallback "Diffuse" } P.S. sorry for my English. I'm from Ukraine.
You can download the shader source here: https://unity3d.com/unity/download/archive In there you can check out how they did their illumination shader and apply it yourself. They're all surface shaders I think, so that shouldn't be a problem. Do note that surface shaders generally always apply a lighting function, but considering you have no lights in your scene, this shouldn't really matter.
Thank you. If you interested in result, check this out: Code (csharp): Shader "Custom/Slices" { Properties { _Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0) _Fade ("Alpha cutoff", Range(0,1)) = 1 } SubShader { Tags { "RenderType" = "Opaque" } Cull Off CGPROGRAM #pragma surface surf Lambert struct Input { float2 uv_MainTex; float3 worldPos; float2 uv_Illum; }; fixed4 _Color; half _Fade; void surf (Input IN, inout SurfaceOutput o) { clip (frac((IN.worldPos.y*+IN.worldPos.z*0.1) * 5) - 0.5); o.Albedo = _Color.rgb * (_Color.a - _Fade); o.Emission = _Color.rgb * 1; } ENDCG } Fallback "Self-Illumin/VertexLit" }