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

BlinnPhong with Environment Lighting Reflection

Discussion in 'Shaders' started by daprato, Jan 18, 2019.

  1. daprato

    daprato

    Joined:
    Sep 25, 2013
    Posts:
    31
    Hi shaderer :)

    I'd like to start writing more CG shader, but not a phong from scratch.
    I'd like to start with the BlinnPhong that cover the flexibility that I want (Tesselation + Specular).
    https://docs.unity3d.com/2018.3/Documentation/Manual/SL-SurfaceShaderTessellation.html

    How I can "enable" the environment reading for the reflection ?
    The default sky, or the HDRI map that we link here:
    Windows / Lighting / Settings ...

    Thx
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,238
    Either by not using the BlinnPhong lighting function, which doesn't use the reflection probe, or by sampling it as part of your surface function.

    float4 envSample = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, IN.worldRefl);
    float4 reflections = DecodeHDR(envSample, unity_SpecCube0_HDR);

    You can get the worldRefl by adding it to your Input struct.
    https://docs.unity3d.com/Manual/SL-SurfaceShaders.html

    If you're using normal maps there's a bit more work that's needed, but check the documentation above.
     
    daprato likes this.
  3. daprato

    daprato

    Joined:
    Sep 25, 2013
    Posts:
    31
    Thx @bgolus you're a beast answering everything :)