Search Unity

Question Replace cubemap in standard surface shader

Discussion in 'Shaders' started by Kaito8, May 23, 2023.

  1. Kaito8

    Kaito8

    Joined:
    Nov 19, 2017
    Posts:
    2
    Is it possible to replace cubemap in standard surface shader? For the case when there is already a custom cubemap in the Lighting Environment settings, and using light probe not suitable
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    There's no easy way to override the specular reflection cubemap being used by a shader in a Surface Shader, but it can be done outside of the shader.

    You can add a reflection probe game object to the scene, use a custom cubemap, and then on the mesh renderer you can override the anchor to be that reflection probe. The location of the reflection probe doesn't matter, so it can be moved far out of the way to prevent it from interacting with other objects.

    This only works if you're using forward rendering though, as in deferred the reflection probes are applied as a deferred pass.

    Alternatively, you can use a surface shader set to use specular color and set that specular color to black. Then you can sample an alternative cubemap manually in the shader and output it as the emissive color, but you'd either have to skip or also calculate the specular lighting manually.