Hey, i have this triplanar shader that keep working the scaling and rotation of the object but it is unlit and i was wondering if someone knew how to have the same with the standard shader to have some light / shadows as its hard to see the blockout shape with the unlit. I tried to copy some pieces of this shader in a new standard shader without success... Code (CSharp): Shader "Unlit/ObjectSpaceTriplanar" { Properties { _MainTex ("Texture", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" "DisableBatching"="True" } LOD 100 Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float3 normal : NORMAL; }; struct v2f { float4 pos : SV_POSITION; float3 uvPos : TEXCOORD0; float3 uvBlend : TEXCOORD1; UNITY_FOG_COORDS(2) }; sampler2D _MainTex; float4 _MainTex_ST; v2f vert (appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); float3 scale = float3( length(unity_ObjectToWorld._m00_m10_m20), length(unity_ObjectToWorld._m01_m11_m21), length(unity_ObjectToWorld._m02_m12_m22) ); o.uvPos = v.vertex.xyz * scale; o.uvBlend = v.normal.xyz / scale; o.uvBlend /= dot(abs(o.uvBlend), float3(1,1,1)); UNITY_TRANSFER_FOG(o,o.pos); return o; } fixed4 frag (v2f i) : SV_Target { float3 blend = abs(i.uvBlend); float2 uv; if (blend.x > max(blend.y, blend.z)) { uv = i.uvPos.yz; } else if (blend.z > blend.y) { uv = i.uvPos.xy; } else { uv = i.uvPos.xz; } fixed4 col = tex2D(_MainTex, TRANSFORM_TEX(uv, _MainTex)); UNITY_APPLY_FOG(i.fogCoord, col); return col; } ENDCG } } Fallback "VertexLit" } Thanks !
You'll want to use a Surface Shader. See the examples page in the Unity documentation for adding custom data to the Input struct. "Custom data computed per-vertex" https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html Create a surface shader from the project window and modify that.