Search Unity

Question Screen position fixed texture, centered on object.

Discussion in 'Shader Graph' started by TheFloatingSheep, Mar 19, 2021.

  1. TheFloatingSheep

    TheFloatingSheep

    Joined:
    Sep 27, 2014
    Posts:
    9
    I've managed to make a texture be rendered onto the screen independent of the geometry of the object, which also stays consistent in size relative to the object rather than the screen, but I would also like it to be offset by just the right amount each frame for it to remain centered on the object and not move around as you turn or move the camera.

    I would appreciate any ideas, thanks in advance.

    upload_2021-3-19_17-56-19.png upload_2021-3-19_18-0-3.png
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    I would rather use distance to camera, to change scale of the texture / rays and keep reference per object space, rather than screen space.
     
  3. TheFloatingSheep

    TheFloatingSheep

    Joined:
    Sep 27, 2014
    Posts:
    9
    I've been trying to but I can't rly figure it out
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    You can pass value of camera distance, to the shader input on the game object.

    Then in shader you use that value, to scale it accordingly.