- Home /
Getting projector shader to conform to UVs
I've been trying to figure out how to generate an effect where a constantly increasing region of a level, centered on the player, changes to a different texture. I eventually concluded that using a projector would be a good way of getting that effect. I have very, very little experience with shaders, and after several hours of taking a built-in shader and hacking away at it, I managed to get something that almost does exactly what I want:
Shader "Projector/Test" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" { TexGen ObjectLinear }
_FalloffTex ("FallOff", 2D) = "" { TexGen ObjectLinear }
_Mask ("Mask", 2D) = "" { TexGen ObjectLinear }
}
Subshader {
Pass {
ZWrite off
Fog { Color (0, 0, 0) }
Color [_Color]
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
Offset -1, -1
SetTexture [_Mask] {
combine texture * primary, ONE - texture
Matrix [_Projector]
}
SetTexture [_ShadowTex] {
constantColor (0,0,0,0)
combine texture lerp (previous) constant
}
SetTexture [_FalloffTex] {
constantColor (0,0,0,0)
combine previous lerp (texture) constant
Matrix [_ProjectorClip]
}
}
}
}
The problem is that this doesn't take UVs into account; it simply plasters a texture onto the side of a level. Does anyone here know any good way to make it so the applied texture conforms to UVs? I'm sorry if I'm not being descriptive enough; I'm really out of my element here. Thanks in advance.
Your answer
Follow this Question
Related Questions
How to render projector in front of walls but behind player? 1 Answer
how to create 2d and pseudo 2d lines and shapes in 3d space? 3 Answers
Can a simple viewshed analysis be done with a projector? 1 Answer
What's the Unity shader equivalent of gl_FragCoord? 0 Answers
I want to create Google Earth style Image Overlays (projections) 0 Answers