Announcement

Collapse
No announcement yet.

How to implement a standard cubemapped skybox?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    How to implement a standard cubemapped skybox?

    I'm trying to replace the default sky with a space texture that I have in the form of 6 separate texture .png files (top, bottom, left, right, front, back). I feel like I'm close but that maybe there's something obvious I'm missing.

    I created a cubemapped .dds following the guide in the docs (https://docs.unrealengine.com/latest...aps/index.html). Once I have the cubemap, though, I'm not sure what to do with it in order to replace the sky. The docs only seem to cover using the cubemap for ambient lighting, but I'd like to actually see the entire thing. The doc mentions "Two popular uses are via ambient cubemaps and cubemaps within materials" but then they only go into details for the ambient cubemaps.

    Directly creating a material from the cubemap doesn't seem to work correctly (I can't actually see the texture on the material, it doesn't seem to realize that this is a cubemap?), or else I'd just make a material from the texture and apply it to a really large sphere. I've tried looking at the default skybox for guidance but it appears to me that the default skybox isn't actually using any cubemaps, or possibly is too complex for me to see where they are being used.

    Can anyone offer some guidance? I feel like this should be much more simple than it's turning out to be.

    #2
    Hi, we don't use the 6 faces style cubemaps any longer. Now they have to be long-lat like HDR maps. The camera vector input automatically works with these formats without you needing to do anything.

    I also found a free photoshop plugin that converts between cube based cubemaps and longlat maps. It is called flexify2, check it out. I have used it many times to make an image from 6 static screenshots of a level.
    Last edited by RyanB; 04-10-2014, 10:30 AM.
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #3
      you can download flexify2 here and some other great Photoshop plugins
      UE4 high res character modelling, rigging for facial and full body animation - HERE
      Dave Saxon/AKA Lex Luthor Channel
      Seek And Destroy Games Channel
      Our Website here.
      Download free animations here

      Comment


        #4
        This still works in U4: https://www.youtube.com/watch?v=uWYpyNkF26o
        That setup is for reflection, but has many common things with what you want. It shows how to use cubemaps in materials.

        Now creating skybox may be fun. First you need static mesh that displays your skybox (make material unlit). Mesh can be box, or sphere.
        You can also make your material use mesh UVs or create some uv math nodes inside materials so it uses world coordinates.

        Then there is also "ancient" way of skyboxes that was done in ut2004, you make "tiny" box put your actors and effects there, then you create cubemap capture camera there and project on your actual huge sky.
        It eliminates movement from player pawn, and adds that feeling of huge sky. Rest is just like making sky on big mesh (see above).

        But it think best would be if you disassembled current blueprint for sky and modified it to your liking.

        ps. did not noticed those screen capture renders are no more cubemaps.

        Comment


          #5
          Originally posted by RyanB View Post
          Hi, we don't use the 6 faces style cubemaps any longer. Now they have to be long-lat like HDR maps. The camera vector input automatically works with these formats without you needing to do anything.

          I also found a free photoshop plugin that converts between cube based cubemaps and longlat maps. It is called flexify2, check it out. I have used it many times to make an image from 6 static screenshots of a level.
          Thanks so much I'll give this a try! I wonder if you could elaborate a bit on what I should be doing with the HDR map once I've made it? Should it be easy to then turn it into a texture and just apply that texture to.. I'm assuming to the sky sphere static mesh?

          And thanks for the suggestions everyone else, I'll give everything a try and report back.

          Comment


            #6
            Alright I'm almost there! I've made the latlong equirectangular map from a horizontal cross cubemap, made a material out of it and applied that material to the sky sphere mesh. The only problem I have left is that the texture seems to be mirrored on the top and bottom of the inside of the sphere instead of wrapping the one texture all the way around:

            Click image for larger version

Name:	Capture.jpg
Views:	1
Size:	8.5 KB
ID:	1050027

            Thumbnail of texture: Click image for larger version

Name:	Capture2.jpg
Views:	1
Size:	2.5 KB
ID:	1050028

            I've tried applying a TextureCoordinate node to the UV input of the texture but giving it .5 for V, which seems like it should fix the problem, just stretches the texture but leaves it mirrored. "Un-mirroring" either axis just throws everything out of whack. Can anyone help get me the last of the way there?

            Comment


              #7
              Alright I've got something close enough to work, though there's a bit of aberration at the top and bottom of the sphere where the texture comes together, but not very noticeable unless you're looking for it. To anyone who stumbles across this thread here's what I got to work:

              1. Download the flexify2 plugin for Photoshop from the link posted by LexLuthor1.

              2. Arrange the 6 faces of the cube into the "horizontal cross" arrangement as per the flexify manual.

              3. Apply flexify to that image with the input as "horizontal cross" and the output as "equirectangular" (this is the latlong/HDR format referred to by Ryan B) and save as a png.

              4. Import this png into Unreal as a texture.

              5. Get Blender if you don't have it.

              6. In blender make a primitive sphere, then invert the normals and export as .fbx

              7. Import the fbx into Unreal as a static mesh.

              8. Make a material out of the equirectangular texture and reroute the output from the texture node into the "emissive" input instead of the "base color" input. Set the lighting on this material to "unlit".

              9. Drag the inverted sphere into the scene, scale it until it's enormous, and apply the texture.

              Should be good enough to work with. Also it'll give you an error about UV wrapping when you build lighting . Still works for me so at the moment I'm just ignoring the error.

              Comment


                #8
                That UV mapping error is coming from one of the static meshes in your scene and has nothing to do with how the cubemap is set up. It just means one of the meshes has the light map UVs overlapping. Or it could be any mesh that has the wrong light map coordinate indx etc...

                As far as mapping, I am pretty sure you need to set the UVs to CameraVector and make sure you import the texture as an HDR image. It should only with with a vector3 input in the UVs. It should be a texture cube not a regular texture sample.
                Ryan Brucks
                Principal Technical Artist, Epic Games

                Comment


                  #9
                  Ryan, can you walk through this in a bit more detail? Your last paragraph isn't making sense to me. The only 'texture cube' node I could find is TextureSampleParameterCube. I couldn't hook the output (ParamCube) to Emissive Color.

                  I'm in a similar situation to GitRHero. I have an equirectangular panoramic I rendered in Blender of the inside of an icosphere. Can be viewed below:
                  http://i.imgur.com/0GpwHMS.png

                  What is the intended way to get this texture into my skybox? Can you show us what the material graph would look like? Does it matter what kind of mesh we use? I had been using SM_SkySphere but it had the UV strangeness that GitRHero described above.

                  Comment


                    #10
                    Sorry the exact name in the material editor is "TextureSampleParameterCube"

                    Click image for larger version

Name:	sky.jpg
Views:	1
Size:	12.4 KB
ID:	1050036

                    Just CameraVector into Cubemap into Emissive. The compression type for cubemaps is TC_HDR.

                    The mesh just needs to be an inverted sphere that encapsulates the whole possible view space. The UV's should not matter since we are projecting the camera vector for each pixel.
                    Ryan Brucks
                    Principal Technical Artist, Epic Games

                    Comment


                      #11
                      There is also already a mesh you guys can use in the engine content folders.

                      1) Open the content browser.
                      2) In the lower right "View Options" select "Show Engine Content"
                      3) Find the folder "EditorMeshes"
                      4) There should be a mesh called EditorSkySphere that will work for skies.
                      Ryan Brucks
                      Principal Technical Artist, Epic Games

                      Comment


                        #12
                        Thanks for the help RyanB! My problem is that I was importing the texture as a .png which comes in as a Texture2D, while TextureSampleParameterCube wants a TextureCube. I was able to export as a .hdr file through Blender and it imported and displays (somewhat) correctly.

                        I'm having a different problem now. I can't figure out why the texture seems to import with a max in-game size of 512x512. The source is 2048x1024 which Unreal Engine seems to identify.
                        Screenshot: http://i.imgur.com/vTBAJrW.png

                        The HDR image in question: equi.hdr

                        I don't understand why I'm being limited to 512x512. It definitely makes the image and resulting skybox fuzzy. I'll do some source diving tomorrow to see if it is some oddity in the Radiance HDR import code. Have you run into anything like this before?

                        To clarify, my goal here is to have a high resolution skybox (current image is 2048x1024). I'm doing so by exporting an equirectangular Radiance HDR image from Blender. The texture seems to import fine but is capped at 512x512. It's worth noting that the engine assets at \Engine\MapTemplates\Sky including SunsetAmbientCubemap, Desert_Outer_HDR, and DaylightAmbientCubemap all exhibit this behavior of having greater than 512x512 dimensions but being capped.

                        Comment


                          #13
                          Hmmm must be something about the compression settings or something. My wife is reading manga on my computer at the moment. In a few hours I will take a look at your HDR file. There's also a way to save them out of photoshop ill try and figure that out too. Thanks for including the file that will make it easier.
                          Last edited by RyanB; 04-13-2014, 10:47 AM.
                          Ryan Brucks
                          Principal Technical Artist, Epic Games

                          Comment


                            #14
                            This is caused due to some ini settings that limit the size of hdr Files to 512. I found this out just today. There is some code you need to change which I can post as soon as I am at home
                            Check out UNREAL 4 Lighting Academy
                            https://forums.unrealengine.com/show...ng-like-that-)

                            Comment


                              #15
                              Daedalus is right. This is because code now assumes a cubemap is going to be used for AmbientCubemap lighting, not as an actual skybox.

                              If you find a workaround for the .hdr format I am very curious to know what it is also. The coder I spoke to said the engine is clamping these to 512 during the import process. Either way, this is a code issue and I have entered a ticket into our bug tracking database.

                              You can also import a cubemap through DDS format by laying out the 6-cubemap faces in a straight line. So the aspect ratio would be 6x1. I am not certain of the layout the dds exporter expects. I was able to get a 6144x1024 cubemap imported that way and it seemed a bit sharper. I also tried a 12288x2048 but gave up after waiting 15 minutes for it to import.

                              Sorry this is probably not the ideal solution. Hopefully we find another workaround soon and get this fixed properly.
                              Ryan Brucks
                              Principal Technical Artist, Epic Games

                              Comment

                              Working...
                              X