I was using an Unlit Shader on a grass.
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
Shader "Unlit/GrassUnlitShader"
{
Properties
{
_TopColor("Top Color", Color) = (1,1,1,1)
_BottomColor("Color", Color) = (0,0,0,0)
_SSSColor("SSS Color", Color) = (0,0,0,0)
_SSSValue("SSS", float) = 0
//_LightDir("Light Direction", float3)
}
SubShader
{
LOD 100
Cull Off
Pass
{
Tags
{
"RenderType" = "Opaque"
"LightMode" = "ForwardBase"
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
#include "AutoLight.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
SHADOW_COORDS(1)
float4 pos : SV_POSITION;
};
fixed4 _TopColor;
fixed4 _BottomColor;
fixed4 _SSSColor;
float _SSSValue;
// float3 _LightDir;
v2f vert (appdata v)
{
v2f o;
//o.pos = v.vertex.pos;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
UNITY_TRANSFER_FOG(o,o.pos);
TRANSFER_SHADOW(o);
//float time = _Time.y;
//if(o.uv.y > 1){
//o.pos.x = sin(time*o.pos.y);
//}
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed shadow = SHADOW_ATTENUATION(i);
fixed4 col = lerp(_BottomColor, _TopColor, i.uv.y*_SSSValue);// * .7 + shadow * .3;// + lerp(_SSSColor, _BottomColor, i.uv.x);
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}
}
I tried to move to a Surface Shader but the material was all black and now the triangles are also visible.
Shader "Custom/SurfaceShader"
{
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
_TopColor("Top Color", Color) = (1,1,1,1)
_BottomColor("Color", Color) = (0,0,0,0)
_SSSColor("SSS Color", Color) = (0,0,0,0)
_SSSValue("SSS", float) = 0
}
SubShader
{
Tags
{
"RenderType" = "Opaque"
"LightMode" = "ForwardBase"
}
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
#pragma multi_compile_fog
#include "UnityCG.cginc"
#include "Lighting.cginc"
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap novertexlight
#include "AutoLight.cginc"
sampler2D _MainTex;
struct Input
{
float2 uv_MainTex;
};
half _Glossiness;
half _Metallic;
fixed4 _TopColor;
fixed4 _BottomColor;
fixed4 _SSSColor;
float _SSSValue;
fixed4 _Color;
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// #pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
c *= lerp(_BottomColor, _TopColor, IN.uv_MainTex.y*_SSSValue);// * .7 + shadow * .3;// + lerp(_SSSColor, _BottomColor, i.uv.x);
//o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Can someone help me solve this