Hello, guys. I am working on some nature environment and i need a decent grass.
I will try to explain the problem, sorry for my english. I need unlit cutout shader which recieves shadows and works with deferred lighting.
First i tried to use modified standard cutout shader, added some bending and fake glare. It did not work well, even with using light probe(check screenshot). It is all about lighting, direct light does not works well with simple cross quad grass. Then i added some emissive and it became half decent , btw standard emission does not recieve shadows(ofc).
So i tried to use ForwardBase light mode. It looks good but it only works with forward rendering path.
It also has some wierd artifacts if i bend it with vertex shader.
Shader below.
So what should i do? I am newbie with hlsl. I hope my english skills is enough to explain this case.
May be there is some simple solution to make decent deferred grass?
Thx!
Shader "Unlit Cutout Bending" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_Emission ("Emission", Range(0,1)) = 0.5
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
_WindSpeed("WindSpeed", Range (0, 10)) = 1.0
_ShakeBending ("Bending", Range (0, 25)) = 1.0
_CosScale ("CosScaleFactor", Range(1,25)) = 0.5
}
SubShader {
Tags {"Queue" = "AlphaTest" "RenderType" = "TransparentCutout" "IgnoreProjector" = "True" }
Pass {
Tags {"LightMode" = "ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#pragma alphatest:_Cutoff
#include "UnityCG.cginc"
#include "AutoLight.cginc"
sampler2D _MainTex;
float _WindSpeed;
float _ShakeBending;
float _CosScale;
float _Cutoff;
fixed4 _Color;
float _Emission;
struct v2f
{
fixed4 color : COLOR;
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
LIGHTING_COORDS(1,2)
};
v2f vert (appdata_full v)
{
v2f o;
float3 WorldPosCos = mul(unity_ObjectToWorld, v.vertex);
float waveCos = cos(((WorldPosCos.x+WorldPosCos.y+WorldPosCos.z*2)+(cos((_Time[1]*_WindSpeed)/7)*_CosScale*5))/_CosScale);
float waveAmount = abs(waveCos*v.color.r*_ShakeBending);
o.pos = UnityObjectToClipPos(float4(((v.vertex.x)+waveAmount), ((v.vertex.y)+waveAmount),((v.vertex.z)+waveAmount), 0));
o.uv = v.texcoord.xy;
o.color = v.color.r*abs(waveCos)/8;
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 color = tex2D(_MainTex, i.uv);
clip(color.a - _Cutoff);
fixed atten = LIGHT_ATTENUATION(i);
return color * atten * _Color + (color*_Emission)+i.color;
}
ENDCG
}
}
Fallback "Transparent/Cutout/VertexLit"
}
