Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Making an objects texture face the camera regardless of orientation?

Discussion in 'Image Effects' started by grassy756_unity, Aug 19, 2023.

  1. grassy756_unity

    grassy756_unity

    Joined:
    Dec 26, 2020
    Posts:
    12
    A character in my game is entirely made up of tv static, however is there a way so no matter what angle you look at him from, the static texture is always lined up with the camera? Almost as if its been green screened over if that makes any sense. (The texture doesn't bend/map around the mesh)
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,002
    Look up screen space uvs.
     
  3. grassy756_unity

    grassy756_unity

    Joined:
    Dec 26, 2020
    Posts:
    12
    Ah thank you very much, I've just done some research and managed to make roughly what I want with a shader graph. However the image texture is stretched/distorted depending on the screen size, is there any way to fix this? (My apologies I've barely ever done shaders before)
     
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,869
    Simplest would be to pass in a parameter for the screen aspect ratio, and set that on such materials (with an exposed global parameter) when the game starts on someone's actual device. Then just multiply the screen Y by that aspect ratio in the shader.

    Edit: Oh, there's a "Screen Info" node with the X and Y resolutions, you can figure the screen aspect ratio from that (assuming square pixels, which is overwhelmingly the most common). URP only at the moment.