Search Unity

How to set width/height of projector

Discussion in 'Scripting' started by willemsenzo, Jul 31, 2014.

  1. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    No matter what I try, I just can't set the size of a projected texture the way I have in mind. Changing the aspect ratio seems to change the width of the projection, the orthographic size changes the overall scale of the projection. I'm using a texture with a solid color and want to project a cursor on the terrain with arbitrarily size. It could be a 1x1 tile, 8x8, or even 3x11 or 100x100.

    Maybe I'm going the wrong way about this, maybe projectors aren't intended to be used the way I'm trying and it's absolutely ridiculous I even mentioned it.... Any ideas?
     
  2. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    I think I figured out how to use it correctly. If I want it to project a 4x6 area, I need to figure out the aspect ratio of the projection. If I divide 4 by 6 I get 0.66. I then set the aspect ratio to 0.66 and the orthographic size to 12 and everything looks ok. Notice how I double the orthographic size (12 instead of 6) because otherwise projection is half the size that it needs to be.

    After poking around and studying the behaviour for a while I finally get it. I could bump myself in the head because it sounds logical to me now why it works like this, but I wish there was at least a scripting example that demonstrates this. I hope this might help others who have the same problem and get stuck in the documentation
     
    RendCycle likes this.
  3. RendCycle

    RendCycle

    Joined:
    Apr 24, 2016
    Posts:
    330
    I know this thread is old but I couldn't find a solution anywhere I've looked. :p

    Maybe you would know how to limit the Y position where the Projector begins projecting? Planning to use it on a Terrain that is underwater. So projected caustics should only be displayed on the part of the Terrain that is considered underwater. Using two active Cameras by the way and one is above water where there should be no caustics displayed and one under water which has the full underwater effects displayed.