Search Unity

Shaders (How do I apply them and their role)

Discussion in 'VR' started by hitoruna, Sep 21, 2017.

  1. hitoruna

    hitoruna

    Joined:
    Jul 11, 2017
    Posts:
    19
    I have watched the excellent video posted in https://forum.unity.com/threads/holographic-photo-blending-with-photocapture.416023/ and read some about shaders.

    Now I am facing a situation in which I have a project in which there is something called a "Video Panel" in the Main Camera. In this there is a Canvas and in the Canvas an Image. The Image I get is inverted so someone propose to apply a Shader.

    My first question is how do I apply a shader? I understand (correct me if I am wrong) that I have to create a Material first, is that right? When i see the Image in the Inspector I see "Image(Script) with Texture and Material (both are None) so I suppose that I should apply the material with the shader there?

    My second question is what is the role of shaders? I read and understand that they can run operations and modify the way images or textures are seen by the user, but is that only for the show? I am planning to do Image processing with the captured images and i am planning to do with C# scripts but seeing that some shader can for example transform all to grey (which is a operation I do in C#) can I take this result from the shader or is it just for visualization purposes only?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,406
    yes, assign the material with correct shader to the objects.
    (if its none, they use some default material/shader, you can see what they are using from Window/Frame Debugger)

    you could take rendertexture of the shader image results, and access that result image (and save it etc)
    https://docs.unity3d.com/ScriptReference/Texture2D.ReadPixels.html
     
    hitoruna likes this.