Search Unity

carpaint shader

Discussion in 'Shaders' started by snaker, Apr 24, 2012.

  1. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    could anyone give me some advice about how to make a carpaint shader that have realtime reflection?
    thank you!
     
  2. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
  3. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    hi,martin
    thank you for your answer,
    the built-in shader named reflective specular that you mentioned needs a cubemap for reflection and just reflect the environment I give it,but if there are other dynamic gameobjects in the scene,my shader should have a reflection both of the environment and those dynamic gameobjects just like the car surface material in the real world,does reflection of dynamic objects that you mentioned helps?If it will do some help ,could you tell me where can I get some information about how to make it or would you give me some advice about it?
     
    Last edited: Apr 25, 2012
  4. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    The usual approach (in rasterization graphics) for small objects is to render the scene (without the reflecting object) into a cubemap as seen from the center of the reflecting object. See: http://unity3d.com/support/documentation/ScriptReference/Camera.RenderToCubemap.html
    For a car with objects close to the car, this might not work particularly well. Also, there won't be any "self-reflections". (As far as I remember Pixar started to include ray tracing into their REYES engine for the movie "Cars" in particular for reflections of the "eyes" of the cars.)
     
  5. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    thank you for your help.
    So I can only use the "reflection specular" shader and use a cubemap to reflect the static environment?
     
  6. Martin-Kraus

    Martin-Kraus

    Joined:
    Feb 18, 2011
    Posts:
    617
    For best performance, using cubemaps is probably the best approach.

    In theory you also have the option to encode your whole scene in uniforms and textures and then program a ray tracer in the fragment shader, which computes the reflections. (And I think this idea is not as crazy as it sounds but it depends very much on your scene.)

    There are even more theoretical options but I cannot see how they could be implemented with reasonable performance in Unity.
     
  7. snaker

    snaker

    Joined:
    Feb 25, 2012
    Posts:
    11
    Thank you very much for your useful answers and patient help!