SetReplacementShader not rendering
I've been staring at this and looking at example code for an hour, and I can't figure out what I'm doing wrong. I have this code running on the camera:
Shader overdrawShader = Resources.Load ("Shaders/Overdraw") as Shader;
GetComponent<Camera> ().SetReplacementShader (overdrawShader, "RenderType");
This is the shader it's calling:
Shader "Overdraw" {
Properties {
_MainTex ("Base", 2D) = "white" {}
}
SubShader {
Fog { Mode Off }
ZWrite Off
ZTest Always
Blend One One // additive blending
Tags { "RenderType"="Opaque" }
Pass {
SetTexture[_MainTex] {
constantColor(0.1, 0.04, 0.02, 0)
combine constant, texture
}
}
}
}
The objects in my scene all use the Standard shader, so I know they have a "RenderType"="Opaque" tag.
When the code gets called, the camera doesn't render anything. What am I missing?
Answer by KillHour · Nov 02, 2015 at 07:36 AM
Got it working. Had some things missing from the shader. Here's the full shader code:
Shader "Overdraw" {
Properties {
}
SubShader {
Tags { "RenderType" = "Opaque" "Queue" = "Transparent" }
Blend OneMinusDstColor One
ZTest Always
Cull Off
LOD 200
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo.rgb = (0.1);
o.Emission.b = (0.1);
o.Alpha = 1;
}
ENDCG
}
FallBack "Diffuse"
}
Your answer
Follow this Question
Related Questions
,How to rerender background with different texture without affecting already rendered character? 0 Answers
How to show transparent PNG on a plane - without backfaces? 0 Answers
Optimizing Shader Compiler for HDRP 0 Answers
how to remove whitedot moving on characters 0 Answers
How to pass a RInt RenderTexture to a ComputeShader? 0 Answers