Screen Space texture projection with ortho camera

Hello,

I recently bought a Cloud Shadow shader from the Asset Store which basically projects a fake cloud shadow texture onto all objects on screen. It works fine with Perspective camera, but not with the Orthographic one. The author isn’t answering my emails so now I’m trying to fix the shader myself.

I’m a shader newbie and two things have gotten me stumped so far:

  1. How do I ensure the cloud texture is projected from top-down instead of camera view?

  2. How do I have the cloud texture stay in place when the camera is rotated?
    This is perspective camera. Projected texture sticks nicely on the surfaces
    5083982--500375--rotateok.gif

This is orthographic camera. Projected texture “slides” around when camera rotates
5083982--500357--rotatebug.gif

Thank you!

I’m not entirely sure why what you have doesn’t work, but here’s an alternative option that should:
https://github.com/keijiro/DepthInverseProjection/tree/6406ad48902d463f07007266ff3d1fb36c8c16ce
Note that’s an older version of that project that doesn’t require you have the new post processing stack installed.

Thanks bgolus!
I’ve just checked out Keijiro’s project but I’m having trouble getting it to project a texture instead of the default grid.

I’ve tried adding this line in InverseProjector.cs’s OnRenderImage() method so I could pass in a texture to the shader, but strangely nothing happens after I assigned one? The shader itself seems to have built-in support for a texture.

_material.SetTexture ("_MainTex", texture);

Any idea what I’m doing wrong?
Cheers

Well, you’ll probably want to make a whole new shader that’s an amalgam of both, or at least modify the existing cloud shader implementing the orthographic method used in Keijiro’s shader. Mainly don’t use the “Visualize” function in Keijiro’s shader, just use the position it calculates transformed into world space.

Yeah that’s what I’m trying to do, but I have to figure out how the projected texture UVs work in Keijiro’s before I can combine them properly. I’ll dig more into it tonight, thanks