Search Unity

Blit cubemap rendertexture

Discussion in 'Shaders' started by Chaiker, Aug 14, 2019.

  1. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    63
    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:
    3,014
  3. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    63
    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:
    63
    aleksandrk likes this.
  5. Chaiker

    Chaiker

    Joined:
    Apr 14, 2014
    Posts:
    63
    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:
    3,014
    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:
    63
    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:
    3,014
    Right, but you can use a 2D blit to the needed resolution first, and then use CopyTexture with matching dimensions.