Search Unity

Camera Inverse View Matrix

Discussion in 'Scripting' started by PhilipV, Jan 30, 2010.

  1. PhilipV

    PhilipV

    Joined:
    Aug 25, 2008
    Posts:
    103
    Today I woke up and wanted to try to implement a nice effect with unity: Post Processed Water...

    The point is that, I never really messed with shaders in Unity, and now I am wondering how i can access a Camera Inverse view matrix.

    The idea is to render the scene to a frame buffer( as in post process examples) and then apply a shader to this scene, but I need to know the Matrix for the camera that rendered.

    Any help?
     
  2. Theformand

    Theformand

    Joined:
    Jan 2, 2010
    Posts:
    271
    I have absotively no experience with shaders, and Im not even sure what an inverse view matrix would produce, but couldnt you just calculate it yourself? Or have an online matrix calc find the inverse for you?

    Sorry if im off base here, just trying to chip in :p
     
  3. PhilipV

    PhilipV

    Joined:
    Aug 25, 2008
    Posts:
    103
    Yes, but calculating a Camera View/InverseView/Frustrum.... Matrix is quite heavy on the CPU, as it involves calculating a 4X4 matrix...

    Since all those matrices are required for rendering calculations, Unity is surely calculating it ( unless they came out with a revolutionary rendering engine, of course ) and it would be wasted cpu cicles to calculate it again just because I don't know how to access it
     
  4. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    The list of all built-in state variables available in shaders is available here: SL-BuiltinStateInPrograms
    I advise you to also have a look into UnityCG.cginc and AutoLight.cginc.

    But more importantly - what do you want to achieve? :)