- Home /
vertex displacement shader and ssao
hi
we are using a bunch of vertex shaders in our game that applies sinus curves to vert positions so that all kinds of foliage can sway in the wind.
when i turn on the build in screen space ambient occlusion too the "darkend" areas remain static where the grass originally was before it started displacing.
what do i need to change on the shader (or ssao image effect) to make these 2 effects play along together nicely ?
... the ssao grabs what exactly from the frame buffer to perform its magic ? the normals ? also the depth right ? could it be that my displacement/wobble/shader doesnt update one of them in the framebuffer and needs some extra code to do it:
Shader "ese_wobble_masked_pixellit"
{
Properties
{
_MainTex("_MainTex", 2D) = "white" {}
_frequency("_frequency", Float) = 1
_speed("_speed", Float) = 1
_scale_x("_scale_x", Float) = 0.1
_scale_y("_scale_y", Float) = 0.1
_scale_z("_scale_z", Float) = 1
_alpha_threshold("_alpha_threshold", Range(0.01,0.99) ) = 0.5
}
SubShader
{
Tags
{
"Queue"="Geometry"
"IgnoreProjector"="True"
"RenderType"="TransparentCutout"
}
Cull Off
ZWrite On
ZTest LEqual
ColorMask RGBA
Fog{
}
CGPROGRAM
#pragma surface surf Lambert addshadow vertex:vert nolightmap noforwardadd
#pragma target 2.0
sampler2D _MainTex;
float _frequency;
float _speed;
float _scale_x;
float _scale_y;
float _scale_z;
float _alpha_threshold;
struct Input {
float2 uv_MainTex;
float4 color : COLOR;
};
void vert (inout appdata_full v, out Input o) {
float4 Splat2=v.texcoord1.y;
float4 Splat1=v.texcoord1.x;
float4 Multiply4=_Time * _speed.xxxx;
float4 Add2=v.vertex + Multiply4;
float4 Splat3=Add2.z;
float4 Multiply3=Splat3 * _frequency.xxxx;
float4 Add4=Splat1 + Multiply3;
float4 Sin1=sin(Add4);
float4 Multiply0=_scale_x.xxxx * Sin1;
float4 Multiply2=_scale_y.xxxx * Sin1;
float4 Multiply5=_scale_z.xxxx * Sin1;
float4 Assemble0=float4(Multiply0.x, Multiply2.y, Multiply5.z, 0);
float4 Multiply7=Splat2 * Assemble0;
float4 Add1=Multiply7 + v.vertex;
float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
v.vertex = Add1;
}
void surf (Input IN, inout SurfaceOutput o) {
o.Normal = float3(0.0,0.0,1.0);
o.Alpha = 1.0;
o.Albedo = 0.0;
o.Emission = 0.0;
o.Gloss = 0.0;
o.Specular = 0.0;
float4 Tex2D0=tex2D(_MainTex,(IN.uv_MainTex.xyxy).xy);
float4 Multiply0=Tex2D0 * IN.color;
float4 Subtract0=Tex2D0.aaaa - _alpha_threshold.xxxx;
clip( Subtract0 );
o.Albedo = Multiply0;
}
ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}
Your answer
Follow this Question
Related Questions
Displace and show normals in fragment shader 1 Answer
Setting depth buffer per-fragment 2 Answers
What is the meaning of a vertex shader for a post-processing shader? 1 Answer
HLSL Post Process Shader Fixing UV/Texcoord 1 Answer
Why doesn't this shader work when using it with as a custom effect on the post processing stack 1 Answer