- Home /
How to make projector shaders override each other?
Hi again.
I asked a question previously here, where @Fattie directed me to trying out lights to solve my problem. I didn't figure out how to do it, but I got really close to what I want using Projectors.
Basically I want to project a color in the shape of a circle, which will grow until it tints the entire environment.
This is what I have so far:
The problem is that I want them to override each other (in this case blue should override red) instead of blending their alpha channels.
Here is the shader I'm using for the projectors:
Shader "Custom/MyProjectorShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
_FalloffTex ("FallOff", 2D) = "white" { TexGen ObjectLinear }
}
Subshader {
Tags { "Queue" = "Overlay" }
Pass {
ZWrite Off
AlphaTest Greater 0
Offset -1, -1
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
// Color [_Color]
SetTexture [_ShadowTex] {
constantColor [_Color]
combine texture*constant
Matrix [_Projector]
}
SetTexture [_FalloffTex] {
constantColor (0,0,0,0)
combine previous lerp (texture) constant
Matrix [_ProjectorClip]
}
}
}
}
Their materials' Alpha is set to 200. If I set them to 255 this is the result:
I tried tinkering with the shader, but to no avail. I'm quite new to Shader programming. If someone could give me a hint, would me much appreciated. =)
Thanks.
dude I'm confused:
"in this case blue should override red, ins$$anonymous$$d of blending their alpha channels"
in your second image:
YOU HAVE BEAUTIFULLY ACHIEVED THAT ... (nice work!)
So I'm not sure what it is you want, pls explain ?
The problem is that on the second image I lost the sphere's shadow and the light on the ground (notice how on the first image both are kept). $$anonymous$$aybe the projector's shader should be calculated before lighting ?
ahh! you want a shadow on the projector area. And the light on the shelf.
I'm afraid I have utterly no clue about that! :)
Wild unknowedgeable guess, could adjusting your QualitySettings change things?
Your answer
Follow this Question
Related Questions
How to make projector/light shader "alpha enabled"? 2 Answers
Problem with simple projection shader 1 Answer
Accessing a projectors renderer 2 Answers