- Home /
Custom checkerboard transparency shader - can't get it to work
I'm trying to achieve oldschool looking, checkerboard-style transparency. However I'm a complete noob when it comes to writing shaders and all I've achieved is to make object not render at all.
Here's mockup made in blender of what I'm trying to achieve (put a sphere in the background to show that those darker areas are transparent):
I've started from Unity's legacy diffuse transparent shader, trying to enhance it to do this, but failed miserably. Here's the shader code:
[code]Shader "Custom/Transparent/Checkers" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} }
SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 200
CGPROGRAM #pragma surface surf Lambert alpha:blend
sampler2D _MainTex; fixed4 _Color;
struct Input { float2 uv_MainTex; };
void surf (Input IN, inout SurfaceOutput o) { fixed4 alcol = _Color; alcol.a=0; fixed4 c; if ((fmod(IN.uv_MainTex.x,0.1f)!=0)&&(fmod(IN.uv_MainTex.y,0.1f)!=1)){ c = tex2D(_MainTex, IN.uv_MainTex) _Color; } else { c = tex2D(_MainTex, IN.uv_MainTex) alcol; } o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG }
Fallback "Legacy Shaders/Transparent/VertexLit" }[/code]
Also it should be independent from model's UV, so squares would be always of the same size and scale won't affect them (it'll just show more squares).
Any help on that?
Your answer
![](https://koobas.hobune.stream/wayback/20220613200428im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Possible for a shader to have two decal slots? 2 Answers
Foliage shader advices ? 0 Answers
Stretching when using world coordinates 2 Answers
Help with the final step of an "Unmoving Plaid" UI shader 0 Answers
Sprites-Diffuse shader explained 1 Answer