Search Unity

Question How exactly can I get the position of every pixel so I can modify its color based on its transform?

Discussion in 'General Graphics' started by Privvet, May 31, 2023.

  1. Privvet

    Privvet

    Joined:
    Feb 16, 2021
    Posts:
    4
    I've written a script that changes the color of an entire object based on the player's closing velocity to it. But, what I need to do now is change the colors of the individual pixels of each object the script is attached to according to the player's closing velocity to each of the individual the pixels. I was told this can be achieved through using shader graphs, but I'm a little lost.

    How am I supposed to reference each pixel and its world transform through a C# script? I'm already changing the color of the entire object by modifying its
    _BaseColor
    .
     
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    765
    Hi, I think you need to create a custom shader (or shader graph) and apply its material to these objects.

    You can access the position of each pixel in the fragment (pixel) stage of a shader. The velocity can be passed to the shader as a global variable (or material as a property) by the C# script attached to these objects.