Scale screen space texture according to distance of object
Posted: Fri Nov 30, 2018 8:43 am
Hi everyone.
I'm trying to achieve an effect where characters are masked by a texture, mapped in screen space. So they look flat.
This is what it currently looks like:
All good, but I want to achieve two more things with this shader:
1. When I walk away from the character (or zoom out) I want the texture to scale down. So that size of the texture looks consistent according to the distance. I kind of achieved this effect already but the problem was that it scaled from the left bottom corner. So it looked like it was panning at the same time. Is there a way to do this?
2. After that, maybe a little trickier, I'd like to minimise the same effect when panning the camera. So according to where the object is on the screen, the texture should pan (I guess?).
The main thing I want to achieve with this shader is, I want the flatness of a screen space shader, but want to eliminate the fact that the texture is 'stuck' to the screen.
I hope it's clear. Any help/tips are much appreciated.
I'm trying to achieve an effect where characters are masked by a texture, mapped in screen space. So they look flat.
This is what it currently looks like:
All good, but I want to achieve two more things with this shader:
1. When I walk away from the character (or zoom out) I want the texture to scale down. So that size of the texture looks consistent according to the distance. I kind of achieved this effect already but the problem was that it scaled from the left bottom corner. So it looked like it was panning at the same time. Is there a way to do this?
2. After that, maybe a little trickier, I'd like to minimise the same effect when panning the camera. So according to where the object is on the screen, the texture should pan (I guess?).
The main thing I want to achieve with this shader is, I want the flatness of a screen space shader, but want to eliminate the fact that the texture is 'stuck' to the screen.
I hope it's clear. Any help/tips are much appreciated.