- Home /
shaders question,shaders question !
I have a half sphere that i want to make the inside visible only when someone is gonna be in it. Like from the outside, it looks like there is nothing, but inside we can see the textures. i hav find one that is working, but only with colors. I want to be able to choose my textures for the insidee
Shader "Custom/InsideShader" {
Properties {
_InsideColor ("Inside Color", Color) = (1,0,0,1)
_OutsideColor ("Outside Color", Color) = (0,0,1,0.2)
_MainTex ("MainTex", 2D) = "white" {}
_Tint ("Tint", Range(0, 1)) = 0
_OutlineWidth ("Outline Width", Range(0, 0.001)) = 0
_ShadowTint ("Shadow Tint", Color) = (0.5,0.5,0.5,1)
_RotateSpeed ("Rotate Speed", Float ) = 1
_OverlayTexture ("Overlay Texture", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Pass {
Cull Back
Stencil {
Ref 2
Comp always
Pass replace
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _OutsideColor;
float4 vert(float4 v:POSITION) : SV_POSITION {
return UnityObjectToClipPos (v);
}
fixed4 frag() : COLOR {
return _OutsideColor;
}
ENDCG
}
Pass {
Cull Front
Stencil {
Ref 2
Comp NotEqual
Pass Zero
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _InsideColor;
float4 vert(float4 v:POSITION) : SV_POSITION {
return UnityObjectToClipPos (v);
}
fixed4 frag() : COLOR {
return _InsideColor;
}
ENDCG
}
}
FallBack "Diffuse"
}
,I have a half sphere that i want to put a shaders tahts gonna make the inside visible but the outside not visible. I've find one code to be able to get the result, but i want to put a textures in the inside of the sphere. Any help ?
Shader "Custom/InsideShader" {
Properties {
_InsideColor ("Inside Color", Color) = (1,0,0,1)
_OutsideColor ("Outside Color", Color) = (0,0,1,0.2)
_MainTex ("MainTex", 2D) = "white" {}
_Tint ("Tint", Range(0, 1)) = 0
_OutlineWidth ("Outline Width", Range(0, 0.001)) = 0
_ShadowTint ("Shadow Tint", Color) = (0.5,0.5,0.5,1)
_RotateSpeed ("Rotate Speed", Float ) = 1
_OverlayTexture ("Overlay Texture", 2D) = "white" {}
}
SubShader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Pass {
Cull Back
Stencil {
Ref 2
Comp always
Pass replace
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _OutsideColor;
float4 vert(float4 v:POSITION) : SV_POSITION {
return UnityObjectToClipPos (v);
}
fixed4 frag() : COLOR {
return _OutsideColor;
}
ENDCG
}
Pass {
Cull Front
Stencil {
Ref 2
Comp NotEqual
Pass Zero
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 _InsideColor;
float4 vert(float4 v:POSITION) : SV_POSITION {
return UnityObjectToClipPos (v);
}
fixed4 frag() : COLOR {
return _InsideColor;
}
ENDCG
}
}
FallBack "Diffuse"
}
Your answer
Follow this Question
Related Questions
viewDir changes with o.Normal 1 Answer
How to set shader vertex normals to face up 1 Answer
shader Transparency 1 Answer
Standard Shader Still Visible through Stencil Shader 0 Answers
EnableKeyword("_EMISSION") not working 2019.3.13f1 0 Answers