Is there a way to set mesh to display both sides? i know i can model it to have both sides but is this the only way?
Just set CULL OFF in the shader.
I have a Script here. I don’t know if it’s going to work, but you could give it a try. Create a new script in java and then insert the code below. Then you just need to attach the script to the object that you want to have double sides.
Javascript:
#pragma strict
function Start () {
var mesh = GetComponent(MeshFilter).mesh;
var vertices = mesh.vertices;
var uv = mesh.uv;
var normals = mesh.normals;
var szV = vertices.length;
var newVerts = new Vector3[szV*2];
var newUv = new Vector2[szV*2];
var newNorms = new Vector3[szV*2];
for (var j=0; j< szV; j++){
// duplicate vertices and uvs:
newVerts[j] = newVerts[j+szV] = vertices[j];
newUv[j] = newUv[j+szV] = uv[j];
// copy the original normals...
newNorms[j] = normals[j];
// and revert the new ones
newNorms[j+szV] = -normals[j];
}
var triangles = mesh.triangles;
var szT = triangles.length;
var newTris = new int[szT*2]; // double the triangles
for (var i=0; i< szT; i+=3){
// copy the original triangle
newTris _= triangles*;*_
newTris[i+1] = triangles[i+1];
newTris[i+2] = triangles[i+2];
// save the new reversed triangle
j = i+szT;
newTris[j] = triangles*+szV;*
newTris[j+2] = triangles[i+1]+szV;
newTris[j+1] = triangles[i+2]+szV;
}
mesh.vertices = newVerts;
mesh.uv = newUv;
mesh.normals = newNorms;
mesh.triangles = newTris; // assign triangles last!
}
Just add the "Cull off " property in the subshader.
Like this:
Shader "Custom/Double-Sided" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
Cull off
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}