Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kelvin |
How do you displace a 3d point by a fixed pixel offset in screen space?
In GLSL you could do for example
vec4 clip_space = projection * view * model * position3d
// manual perspective division
vec2 screen_space = clip_space.xy / clip_space.w
// perform displacement in screen space, in units of pixels
vec2 displaced = (screen_space * viewport_resolution + pixel_displacement) / viewport_resolution
// set z to 0 and w to 1 to disable hardware perspective divide
glPosition = vec4(displaced.xy, 0, 1)
but the godot shader system doesn’t seem to let you modify the perspective and projection order like this.