Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Blit cubemap rendertexture

Discussion in 'Shaders' started by Chaiker, Aug 14, 2019 at 1:44 PM.

  1. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    Hello. How can I blit cubemap rendertexture to another cubemap rendertexture?
    I need copy point light shadowmap, and when I try blit, my rendertexture is red at one face.
    My rendertexture is RFloat and dimension is Cube.
    For spotlight it works properly, just I use 2D RFloat texture.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    851
  3. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    Thank you. Yes it works when I create rendertexture with shadowmap format and 1024 size. But I have problem.
    I use command buffer to copy baked shadowmap to light shadowmap before shadows are rendered, and copy of baked shadowmap works properly, but dynamic objects have not affect when rendering into point light shadowmap.
    I try do something similar to cached shadows feature.
     
  4. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    aleksandrk likes this.
  5. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    I have new problem. Shadowmap resolution depends on:
    1. Quality Settings or Light shadow resolution setting
    2. Camera rendering resolution
    So i can't use ONE baked (or prerendered) cubemap for cameras with diferrent resolution, also i can't use this in game view and scene view when resolution of shadowmaps are different.
    I can't use because CopyTexture requires equal texture resolution.
    Is there any other solution to blit 2 cubemaps render textures by faces?
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    851
    Hmmm...
    Blit to 6 2D textures and then use CopyTexture to fill a cubemap? :)
     
    Chaiker likes this.
  7. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    50
    If i use CopyTexture and textures with different resolutions i got error about that sizes is not equals.
    Cubemap resolution is depend on camera resolution, so for different cameras i would need different copies just in different resolutions of my textures.
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    851
    Right, but you can use a 2D blit to the needed resolution first, and then use CopyTexture with matching dimensions.