Hello!
I was just playing around with Amplify Occlusion in my game and it looks very good. However, I use a lot of vertex animation (surface shaders for now) for things and was just wondering if there's an easy way to get them to work together? To avoid results like this:
as you can see the AO is applied to how the geometry looked before the vertices are modified.
marten wrote:Hello!
I was just playing around with Amplify Occlusion in my game and it looks very good. However, I use a lot of vertex animation (surface shaders for now) for things and was just wondering if there's an easy way to get them to work together? To avoid results like this:
as you can see the AO is applied to how the geometry looked before the vertices are modified.
Hello Marten,
Thank you for reporting the problem, we really appreciate it. It shouldn't be an issue, what shader are you currently using? In the Amplify Occlusion camera component, what value do you use for Per-Pixel Normals? Deferred or Forward rendering?
Shader "City/Vertex colored animated" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Smoothness ("Smoothness", Range(0,1)) = 0.5
_Stretch ("Stretch", Range(-0.5,0.5)) = 0
_Bend ("Bend", Range(-0.5,0.5)) = 0
_SubmeshOffset ("Submesh Offset", Vector) = (0,0,0,0)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard vertex:vert addshadow
#pragma target 3.0
struct Input {
float2 uv_MainTex;
float3 vertexColor; // Vertex color stored here by vert() method
};
float _Stretch;
float _Bend;
float3 _SubmeshOffset;
void vert (inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input,o);
// Save the Vertex Color in the Input for the surf() method
o.vertexColor = v.color;
//vertex displacing
float y = v.vertex.y + _SubmeshOffset.y;
float x = v.vertex.x + _SubmeshOffset.x;
v.vertex.y += y * _Stretch - (x * y) * _Bend;
v.vertex.x += (v.vertex.x + _SubmeshOffset.x) * -_Stretch + y * y * _Bend;
v.vertex.z += (v.vertex.z + _SubmeshOffset.z) * -_Stretch;
}
sampler2D _MainTex;
half _Smoothness;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutputStandard o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
// Combine normal color with the vertex color
o.Albedo = c.rgb * IN.vertexColor;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
}
ENDCG
}
}
And here are my current settings for the effect. I have tried to fiddle with the settings but nothing seems to help with the problem.
Hello,
There's a Unity issue that prevents it from working under certain combinations. In this case, it works with all settings, using your shader, except with Forward Rendering when using Camera Per-Pixel Normals. Altering the Normals value in the Amplify Occlusion component should resolve the problem.
Let us know if that is not the case, we would be happy to help if that is not the case. Our apologies for the inconvenience.
I realized I seem to have another problem, which probably isn't related to the AO at all which was what confused me. The part that affects light in the displaced model seems to be updated incorrectly.
I realized I seem to have another problem, which probably isn't related to the AO at all which was what confused me. The part that affects light in the displaced model seems to be updated incorrectly.
Hi,
Awesome, happy to hear it. Do you see the same issue with other depth based effects such as DoF?
If possible, please send a download link for the asset used in your screenshot to [email protected], we would be happy to test it on our side as soon as possible.