Last active
October 1, 2021 18:10
-
-
Save aobond2/0cc8e78d2c913deb4c1dea33694c7c2e to your computer and use it in GitHub Desktop.
Cube shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/ObjectDiffuseStencil" { | |
Properties { | |
_Color("Color", Color) = (1,1,1,1) | |
_myDiffuse ("Diffuse Texture", 2D) = "white" {} | |
_myBump ("Bump Texture", 2D) = "bump" {} | |
_mySlider ("Bump Amount", Range(0,10)) = 1 | |
_SRef("Stencil Ref", Float) = 1 | |
[Enum(UnityEngine.Rendering.CompareFunction)] _SComp("Stencil Comp", Float) = 8 | |
[Enum(UnityEngine.Rendering.StencilOp)] _SOp("Stencil Op", Float) = 2 | |
} | |
SubShader { | |
Stencil { | |
Ref [_SRef] | |
Comp [_SComp] | |
Pass [SOp] | |
} | |
CGPROGRAM | |
#pragma surface surf Lambert | |
sampler2D _myDiffuse; | |
sampler2D _myBump; | |
half _mySlider; | |
float4 _Color; | |
struct Input { | |
float2 uv_myDiffuse; | |
float2 uv_myBump; | |
}; | |
void surf (Input IN, inout SurfaceOutput o) { | |
o.Albedo = tex2D(_myDiffuse, IN.uv_myDiffuse).rgb * _Color.rgb; | |
o.Normal = UnpackNormal(tex2D(_myBump, IN.uv_myBump)); | |
o.Normal *= float3(_mySlider, _mySlider, 1); | |
} | |
ENDCG | |
} | |
Fallback "Diffuse" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/StencilQuad"{ | |
Properties { | |
_Color ("Main Color", Color) = (1,1,1,1) | |
_SRef("Stencil Ref", Float) = 1 | |
[Enum(UnityEngine.Rendering.CompareFunction)] _SComp("Stencil Comp", Float) = 8 | |
[Enum(UnityEngine.Rendering.StencilOp)] _SOp("Stencil Op", Float) = 2 | |
} | |
SubShader { | |
Tags {"Queue" = "Geometry-1"} | |
ZWrite off | |
ColorMask 0 | |
Stencil { | |
Ref [_SRef] | |
Comp [_SComp] | |
Pass [_SOp] | |
} | |
CGPROGRAM | |
#pragma surface surf Lambert | |
sampler2D _myDiffuse; | |
struct Input { | |
float2 uv_myDiffuse; | |
}; | |
void surf(Input IN, inout SurfaceOutput o) { | |
o.Albedo = tex2D(_myDiffuse, IN.uv_myDiffuse).rgb; | |
} | |
ENDCG | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment