Shader normals modification different in build
I'm using a render texture for a glow effect around contact between characters and floor. Works great in the editor, but when I build the texture isn't displaying properly, the mapping is shifted, and I think the clipping planes are different. Any ideas?
Here's the desired effect in the editor on the left, problematic build on the right:
Here I modified the texture to show the problem better... notice it's shifted down (the fact that it's solid color and maybe the fact that it's smaller is the clipping planes not being the same as the editor)
EDIT: I narrowed it down. I'm using SetReplacementShader for the render texture camera, and in the replacement shader I'm inflating the meshes along their normals in vert with: "v.vertex.xyz += (v.normal * _Bloat) ;" this works in the editor, but in the build it just pushes them to one side... here's my shader code... does anyone know why this would be?
Shader "Custom/Disco Floor Mask" {
Properties {
_Bloat("Bloat Geo", Range(0, 1)) = 0.025
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass {
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
half4 pos : POSITION;
};
float _Bloat;
v2f vert(appdata_base v) {
v2f o;
v.vertex.xyz += (v.normal * _Bloat) ; // bump the normals out a bit
o.pos = mul(UNITY_MATRIX_MVP, v.vertex) ;
return o;
}
float4 frag(v2f IN) : COLOR {
return half4(1,1,1,1);
}
ENDCG
}
}
}
Answer by SuppleTeets · Jan 20, 2016 at 06:31 PM
Okay I found someone with a normals problem in another thread, it turns out unchecking "Optimize Mesh Data" in the player settings fixes it. I'd like to optimize everything but these meshes... is that possible?
Also should "Optimize Mesh Data" really do that?
Your answer
Follow this Question
Related Questions
Camera depth causing RenderTexture issue 0 Answers
Picture frame around minimap 0 Answers
Single Pass rendering into a double-wide RenderTexture from a script? 0 Answers
(HDRP) Camera.Render() renders black, but only if Scene View is not visible 0 Answers
Why setting RenderTextureFormat to Depth freezes unity dead, if i try to preview it in inspector? 0 Answers