I'm making a CanvasShader.
Normally for doing something in world-space I'd just set up a varying in vertex()
like
varying vec2 WorldSpace;
void vertex() {
WorldSpace = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}
and it gets interpolated and everything is happy.
Problem is, LIGHT_POSITION
is just wherever the light is in screen coordinates, completely unrelated to LIGHT_VERTEX
. No access to LIGHT_POSITION
in vertex()
, and obviously passing down a matrix with a flat varying and doing those multiplications in light()
is a terrible idea.
I guess I don't even need the world position exactly. I just need x&y pixel differences between LIGHT_POSITION
and LIGHT_VERTEX
, and I need that calculation to remain consistent with camera scaling.
Any ideas? For easy reference I'll put the light-pass built-ins below here: