- Home /
CutOut diffuse shader visible from both sides on a plane?
Hi! I am using cut out diffuse shader to make people and trees. For this I imported a plane as an FBX model and used the PSD textures with alpha channels.
However, the people/trees are visible only from one side on the plane,, which I believe is the direction in the which the normal is pointing. I want it to be visible from front and back both.
How can I do that? Can I do that? Or I'll have to keep two planes close to each other an facing in opposite directions so that they look like a single surface and together are visible from front and back?
Thanks for reading!
Answer by Kryptos · Jan 23, 2012 at 03:51 PM
You need to make your own shader based on Transparent/Cutout/Diffuse with culling set to off. You can get the source of the built-in shaders here.
EDIT: Original Transparent/Cutout/Diffuse is:
Shader "Transparent/Cutout/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Modified version with culling off:
Shader "Transparent/Cutout/Diffuse" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Lambert alphatest:_Cutoff
sampler2D _MainTex;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Thanks a lot! I will have a look into making custom shaders and see if I can get the desired result.
have no experience with shaders. I created a new shader with this code and am using the shader on my material, but it still just shows up as normal. Any help?
@jakejolli I have been using the second one that $$anonymous$$ryptos wrote. It works all fine
Is there a way to only use the alpha for the cutoff and not for the hole material? I would like to have the non cutoff part of the texture to be diffuse...
Your answer
Follow this Question
Related Questions
World Relative UVs with normalmaps 1 Answer
Normals for Displacement Shader 0 Answers
An Outline like the Editor does in game, with transparency 1 Answer
What are normals? 1 Answer
Cutout texture 2d 1 Answer