[Guide] Seamless 3D Skyboxes

Discussion in 'Tutorials & Resources' started by Freyja, Jun 16, 2015.

  1. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,884
    Positive Ratings:
    5,128
    Hey all, recently I've had a lot of requests to write a tutorial on how I do my seamless 3D skyboxes. A lot of the older tutorials are outdated or teach a method that makes making the skybox seamless with your map incredibly difficult.

    Let's start with your map. Here I've created a small scene to demonstrate making a seamless skybox. You can do this with any shaped map, but I used a simple square here to demonstrate the technique easier.

    [​IMG]

    The key to the seamless skybox technique is to build your skybox around your map in real scale. Sew your displacements and align your textures here, the technique we use to create the skybox will keep these texture scale and alignments from this portion.

    Don't place props in this portion, just create a simple base for your skybox out of displacement and brushes only.

    Here I've created an area outside my "map" that will become the 3D skybox. As you can see here, the displacements sew with the map and the water and textures are aligned perfectly with what will say as the "map"

    [​IMG]

    As you can see, I can select everything that will become part of the skybox seperately without selecting anything as part of the map.

    [​IMG]

    The next step is to find your map origin, the 0,0,0 coordinate position. It is indicated by the three lines, one red, blue and green. You then need to create a point entity, change it's class to sky_camera and move it so it is sitting directly on the 0,0,0 point like this.

    We do this because the sky camera is an entity that projects the 3D sky around your map from the origin point. By placing the camera at the origin now, we make sure that it is in perfect position to project our 3D sky exactly as it is represented in full size, seamless with your map right now.

    [​IMG]

    The next step is to select your sky_camera and everything that makes up your skybox as shown earlier. It is an absolute imperative that you have the sky_camera select during this step along with everything else as it will not be able to be placed properly later.

    Next, make sure you have both the texture lock and texture scale lock buttons turned on:

    [​IMG]


    This will ensure that when we scale down our 3D skybox to 1/16th size, the textures will not become misaligned.

    Next, hit Control-M on your keyboard, select the scale radio button and type 0.0625 (ie. 1/16th) into both the X, Y and Z boxes.

    [​IMG]

    After hitting okay, this will leave you with a still currently selected, 3d skybox version of everything you had selected before. It will have scaled down everything, including the textures (because we had texture scale lock on) and kept everything in perfect relation to the sky_camera we had placed at the origin.

    You'll want to drag all this stuff (Make sure texture lock is still turned on!!) somewhere off to the side of your map, it doesn't matter where, just don't put it inside your main map.

    [​IMG]

    [​IMG]

    Create a skybox box around your 3D skybox, making sure nothing inside it leaks. You'll want to make sure this is textured with skybox too, as it needs to cast light on your 3D skybox in order to appear seamless.

    [​IMG]

    You can now place skybox props here. As props do not scale with the transform tool (control-M) we cannot place them any earlier. Here I have placed some simple decoration props from the props_skybox/ section, such as phallic looking rocks and trees.

    [​IMG]

    We also need to worry about the seamlessness between lighting and fog of our skybox and main map.

    Your light_environment will produce the same light to both the skybox and main map, so as long as you don't have anything casting obvious shadows in the main map over the transition between normal map and 3D sky (the 3D sky will cast shadows over the main map, but not the other way around), source will take care of this for you.

    The main concern is the fog. Find your env_fog_controller entity and your sky_camera (now positioned in the 3D sky area you made somewhere olff to the side of your map).

    These are the settings that need to be identical in order for fog to be seamless. Often times you can play around withh these settings a bit and have them still appear seamless, but that's up for you to try. Making them identical will guarentee seamlessness.

    [​IMG]

    The last thing you need to worry about is if you have water crossing the border between map and skybox like I have here. Even though the water texture is perfectly aligned, due to the seperate physical positions in your VMF of the skybox water and real map water, their reflections will appear different and show a seam.

    In order to fix this, create a cubemap entity above the water face inside your map. In the cubemap properties, you can select brush faces for the cubemap to affect. Select both the water face in your map, and the water face in your skybox. Once you hit apply, the cubemap entity will draw lines to the faces it is tied to, so make sure it's pointing to both.

    [​IMG]

    And that's all there is to it, really. If we add a spawn point (because I forgot that) and compile the map, we can see that the skybox appears perfectly seamless with the main map. You can see where I have added fences to mark the transition between the real map and 3D sky from earlier. (Ignore the floating rock...)

    [​IMG]

    However, there are a few issues you need to be aware of.

    Firstly, here is an example of where a prop is casting a shadow onto the world that doesn't translate across to the 3D sky.

    [​IMG]

    In this case, I would simply extend the real map to capture the shadow and start the skybox transition later, however often times you can get away with it.
    Another issue you may run into is how water is handled across the transition.

    [​IMG]

    As you can see here, the refracive properties of the water doesn't work properly in the skybox, even though the texture is aligned perfectly. This effect is mostly evident from high angles, and you can allieviate it by increasing the depth of the ground under the water around where it transitions so the change is less evident.

    The last issue you may run into is that of the fact that from certain angles, the 3D sky can be rendered behind props inside of your map.

    [​IMG]

    You can't really avoid this as that's just how 3D skies work, so I would suggest, as earlier, extending the real map and starting the skybox transition later.

    I hoped this helped you make better 3D skyboxes. If you have any questions or issues, let me know below and I'll try to help.
     
    • Thanks Thanks x 47
    • Like Like x 3
    • Useful Useful x 1
    Last edited: Jun 16, 2015
  2. Moonrat

    aa Moonrat The end of an era

    Messages:
    898
    Positive Ratings:
    533
    Nioce
     
  3. wareya

    wareya L7: Fancy Member

    Messages:
    493
    Positive Ratings:
    191
    I did the cubemap thing in flashwind and it didn't work for me
     
  4. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,884
    Positive Ratings:
    5,128
    Was the plane of water in the 3D sky and in your map on the same level? I think having them on different vertical levels can offset the reflection a bit.
     
  5. Anreol

    Anreol L6: Sharp Member

    Messages:
    262
    Positive Ratings:
    273
    Wow.
    I suck making 3D Skyboxes... but with this now... will be a lot, LOT better.
    Thanks!
     
  6. tyler

    aa tyler snail prince, master of a ruined tower

    Messages:
    5,035
    Positive Ratings:
    4,499
    A lot simpler and easier to understand than the old skybox tutorials. I bet this will help lots of people.
     
  7. Idolon

    aa Idolon the worst admin

    Messages:
    1,592
    Positive Ratings:
    4,715
    It might be worth noting that you can place props before scaling your map down, provided that you make sure that a 1/16 scale version is available (and that you change the models yourself). This is really handy for lining up power lines and train tracks that extend into the 3d sky.
     
    • Thanks Thanks x 5
  8. EArkham

    aa EArkham Necromancer

    Messages:
    1,585
    Positive Ratings:
    2,318
    Oh, so that's how it's done. Years mapping and I still learn new tricks.
     
  9. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,377
    And if you have actual lines on your telephone poles, don't forget to reduce the thicknesses of the keyframe_ropes to 1/16 of what you're normally using.

    As far as casting shadows onto skybox props from things in the regular map, have you experimented with putting either nodraw or blocklight brushes in the skybox that match the scaled-down dimensions of the thing in question? Does it present any issues, or would it work perfectly?
     
    • Thanks Thanks x 2
  10. Freyja

    aa Freyja ¯\_(ツ)_/¯

    Messages:
    2,884
    Positive Ratings:
    5,128
    It wouldn't be perfect unless you scaled the lightmap in thhe skybox down to match the 1/16th scale, however other than that it should work. Usually I just avoid the problem by avoiding it all together or casting shadows that are not noticeable by the player.
     
  11. wareya

    wareya L7: Fancy Member

    Messages:
    493
    Positive Ratings:
    191
    yes the brush geometry and texture scale/alignment were seamless
     
  12. iiboharz

    aa iiboharz Meme Queen

    Messages:
    734
    Positive Ratings:
    1,071
    It might be worth noting that while building your skybox geometry at full scale, you should take care to not create any brushes or smaller than 16u because when scaled down it will become a microbrush and that would cause a mess of problems.
     
    • Thanks Thanks x 5
  13. Pocket

    aa Pocket func_croc

    Messages:
    4,489
    Positive Ratings:
    2,377
    I didn't mean stuff that's meant to be lined up with the stuff inside the map, like that example you showed; I just meant any structures that ought to have shadows on them, like the silos in Foundry. Good to know there wouldn't be side effects.
     
  14. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,115
    Positive Ratings:
    6,437
    I've been using this for crusoe, but i've been having the issue where water further away reflects differently to water nearby - and even with the cubemap set up correctly, this creates a very visible seam, as seen below:

    Near:
    [​IMG]

    Far:
    [​IMG]

    Any suggestions on what I can be doing?
     
  15. ibex

    aa ibex

    Messages:
    259
    Positive Ratings:
    396
    I think Fubar or someone had said that you need a brush on the edges of your water that is the same color as your fog. Could be remembering wrong, but hopefully someone else has a more exact idea.
     
  16. phi

    aa phi Let Pain Be Your Guide

    Messages:
    806
    Positive Ratings:
    1,660
    Definitely don't need a weird brush like that for your water to work. I don't have anything like that in Sunshine. You sure your cubemaps are working properly? That looks suspiciously like a reflection of the skybox.
     
  17. LeSwordfish

    aa LeSwordfish semi-trained quasi-professional

    Messages:
    4,115
    Positive Ratings:
    6,437
    @Egan very helpfully provided the answer in chat - this distance is where the water fades from cheap to expensive as part of the water_lod_control's function - I extended that distance and now it works perfectly. Incidentally the same applies for when the water fades to a darker color or to more strongly purple checked, since the cheap water's appearance is controlled by reflection.

    Thanks for the tutorial!
     
    • Thanks Thanks x 1