- Home /
How do I make a model 2 sided?
How do I make so the inside of the hair isn't..transparent? I'd like to add that I know almost nothing about Unity - I'm just using Unity to port custom models into a game, exporting it as a unity3d file and adding it through commands to a game. I've tried using a double sided shader, but it only supports the Standard shader, and not the Lit shader. Lit shader works best for the game. I have Unity ver 2017.2.0f3, I can't go to newer versions due to imports/exports not working correctly. Thanks!
Is it transparent in the 3D modelling program you use? (Blender, $$anonymous$$aya, etc).
By the way, your screenshot is not showing on my computer.
do you need to see the outside too? I'm confused on why you would need to go in and out of an object
Answer by MichaI · Jan 06, 2019 at 02:55 PM
If you have some custom shader you can just turn off back face culling by adding Cull Off, for example:
Shader "Lit/Diffuse With Shadows"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
[NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
Tags {"LightMode" = "ForwardBase"}
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
// compile shader into multiple variants, with and without shadows
// (we don't care about any lightmaps yet, so skip these variants)
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
// shadow helper functions and macros
#include "AutoLight.cginc"
struct v2f
{
float2 uv : TEXCOORD0;
SHADOW_COORDS(1) // put shadows data into TEXCOORD1
fixed3 diff : COLOR0;
fixed3 ambient : COLOR1;
float4 pos : SV_POSITION;
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
o.diff = nl * _LightColor0.rgb;
o.ambient = ShadeSH9(half4(worldNormal,1));
// compute shadows data
TRANSFER_SHADOW(o)
return o;
}
fixed4 _Color;
sampler2D _MainTex;
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
// compute shadow attenuation (1.0 = fully lit, 0.0 = fully shadowed)
fixed shadow = SHADOW_ATTENUATION(i);
// darken light's illumination with shadow, keep ambient intact
fixed3 lighting = i.diff * shadow + i.ambient;
col.rgb *= lighting;
return (col * _Color);
}
ENDCG
}
// shadow casting support
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
}
}
Your answer
Follow this Question
Related Questions
Water flow effect in a water tube Model 1 Answer
Shader.CreateGPUProgram - Performance Issue 0 Answers
Simple Color Shader for 3D Models 0 Answers
how to hide a model behind invisible plane? 0 Answers
Purple lines appearing on models 0 Answers