Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Overlaying two cubemap texture, not blending

Discussion in 'Shaders' started by Duney, Sep 3, 2013.

  1. Duney

    Duney

    Joined:
    Aug 19, 2013
    Posts:
    170
    Hi guys,

    I currently have my game rendering one static and one dynamic cubemap (for efficency reasons) and have access to these in my shader.

    The problem I am having though is that the dynamic cubemap needs to be on top of the static one (as the static one holds the whole room) but I can't seem to find a way to get this to work. Currently I do some blending between the two maps, which in some way works but you can still see the static cubemap through the dynamic cubemap.

    $question.png

    I'm not sure whether the is a way to do this in the shader or whether there is a way to combine both textures in a script as the program runs.
     
  2. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    How would you want to determine where the static cubemap displays in front of the dynamic cubemap? You need to create some kind of mask and then lerp between the two.
     
  3. Duney

    Duney

    Joined:
    Aug 19, 2013
    Posts:
    170
    My initial thought was hoping there was a method that would allow one texture to be written/overlayed on top of another (sort of like a blending technique).

    Currently I:

    Code (csharp):
    1.  
    2. // Combine the cubemaps together (NOTE: This does give some problems with how the balls are sorted
    3. // with the background
    4. fixed3 mixedMaps = lerp( dynamicCube.rgb, staticCube.rgb, staticCube.a );
    5. mixedMaps *= _ReflectColor;
    6.  
    Then use the mixedMaps in o.Emission.