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

Project skybox on object

Discussion in 'Shaders' started by Edisyo, Oct 29, 2019.

  1. Edisyo

    Edisyo

    Joined:
    Dec 11, 2017
    Posts:
    9
    Hey, I cant seem to figure a way to render skybox onto object.
    Im currently using reflection shader and it looks like this, but.. upload_2019-10-29_10-28-34.png

    but it doesnt look that great. I want it to be seamless - cant see cubes edges.

    Does someone has any idea how to do it? :)
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    What exactly do you want to see? Do you want the box to appear to be a window to the skybox? Going by the above image this is for AR. You might want to look into stencils, or a depth writing shader. If you have some control over the shader used to render the AR background you could make sure your "cube" renders first using a Stencil writing shader, and then the AR background is masked by that stencil letting the skybox show through.

    Otherwise the next easiest solution is indeed a cubemap of the skybox, but you need a fairly high resolution cubemap for it to work well. You can generate those from script with the RenderToCube() function. A reflection probe is always going to be a little bit blurred since they exist to mimic pbr reflections on rough materials, so it isn't a great option, though they might still work if you use a shader that explicitly only samples from the top mip of the cubemap using the world view direction rather than "reflection shader" ... especially since the one you're using looks like it's using a fairly high roughness value or you're using a very low resolution reflection probe.

    The other option is to have an extra camera that renders only the skybox for the current view to a render texture that you then displace on a box using a screen space UV.