Skybox Texture Scaling

BigfootBeto

Party Time 2.0!
aa
Jun 8, 2016
496
847
Sort of an unusual problem, but I'm needing to be able to swap out the skybox texture for a map. My plan is to make a fake skybox brush in the 3d skybox that I can enable and disable depending on the skybox i need.

So I made the box. and when I applied the texture I ran into a problem, I was easily able to fit a texture onto the top, but then I couldn't fit a texture properly to the sides.

hammer_2017-09-24_16-03-23.jpg


You can see that the texture scale is 5.625 x 5.625, so there's no apparent reason why the texture is stretched weirdly. The top texture has the same scale and it's fine. The brushes are both 5760 x 5760. I tried making them smaller, but it made no difference. The scaling issue applies to all 4 sides, and not just this one.

If this ends up being a hammer issue and it ends up being fine in-game I'll update here when I compile.
 
Mar 23, 2013
1,013
347
The brushes are both 5760 x 5760

What are you trying to do? Because if that is going to be a skybox, you are doing it wrong.
Go to map>properties and enter the sky_alpinestorm_01 as skybox texture and keep using tools/skybox as your skybox texture.
 

BigfootBeto

Party Time 2.0!
aa
Jun 8, 2016
496
847
What are you trying to do? Because if that is going to be a skybox, you are doing it wrong.
Go to map>properties and enter the sky_alpinestorm_01 as skybox texture and keep using tools/skybox as your skybox texture.
I'd love to do that, but I need multiple skyboxes
 
Mar 23, 2013
1,013
347
A giant box you turn on/off might look very artifical.

Perhaps try to make it a cubemap reflection instead? Make a box in the skybox that only shows the cubemap reflection, and make a 128x128 box with the skybox texture and put a cubemap (with high res setting) in it. Buildcubemaps and you may have a better looking secondary skybox.
 

Diva Dan

hello!
aa
Mar 20, 2016
1,024
1,951
It would have to be a really high definition cubemap, and I don't think the box would look very bad considering that's what the textures are built to be shaped around, if you get what I'm saying. Although the ambient lighting would be a bit weird, unless you specifically compiled each zone with their own environment light entity (which is possible to do)
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
A giant box you turn on/off might look very artifical.

Perhaps try to make it a cubemap reflection instead? Make a box in the skybox that only shows the cubemap reflection, and make a 128x128 box with the skybox texture and put a cubemap (with high res setting) in it. Buildcubemaps and you may have a better looking secondary skybox.
We need a vote button for "holy crap that's a brilliant idea that I din't think anyone's ever thought of before."

EDIT: Well maybe. The idea is that this exploit would deal with the parallaxing issue, right? Since 2D skyboxes are supposed to be locked in place and only rotate with the camera. The more I think about it, it doesn't sound like that would quite work, unless I'm misunderstanding what you intend to build. I suggest you try making a proof-of-concept and demonstrate it for us.
 
Mar 23, 2013
1,013
347
Since 2D skyboxes are supposed to be locked in place and only rotate with the camera

But aren't cubemaps "locked in place" (can't describe it better) as well? I mean, go to a window where you can see the cubemap pretty clearly (mannworks spawn window is a good one) now move around and you will see that the cubemap reflection keeps the position relative to your screen. So basicly what skyboxes do, right?
I can try turning the concept it into a map later today.
 
Mar 23, 2013
1,013
347
Okay boys.
So first thing I tried was just puting a box with the material metal/metalchrome01 around the skybox, hower the cubemap reflection didn't connect between the faces at all and looked super weird. So what I did instead is making a single, very wide brush in the 3d skybox. It looks like this:

pIM2yrv.png


That means if you fly to high in the real map, you will see this brush ending at some point. I wonder if I could just do a curved displacement instead... anyway, the real map is surrounded by high cliffs and trees so it was hardly noticeable even when rocket jumping!

The grey box below the 3d skybox, is the box I put the skybox texture in. As I had the same problem like OP, the texture looking weird I had to make a custom one. the reflection is supposed to use the sky_gravel_01 skybox, so I copied the vtfs and vmts of the gravel skybox to materials/fakesky.
I changed the VMTs so that they are using the LightmappedGeneric shader and only have a basetexture specified and in the VTFs I unchecked the Clamp S, Clamp T, SRGT flags.
in game view:
vXRTxR9.jpg


as you can see, the skyboxtexture-box has the texture upside-down, because the reflection is mirrored after all.

The giant, reflective chrome texture brush is a func_brush, by toggeling we get the following results:

DISABLED

ENABLED


As you can see, the cubemap reflection looks a bit worse than the skybox in cp_gravelpit, but it does a pretty good job. If you don't give it a closer look you might not notice its a cubemap as it behaves like the 2D skybox. Look around, move around, the texture keeps it's position like a skybox texture does. Only issue is that you can clearly see the seams
So this method can be a great solution to have two skyboxes, however, since the cubemap reflection does not look as good, it is probably better to design the area with the cubemap-sky with many tall buildings or indoors or simply in some way where players don't see the sky so much to notice the flaws.

Okay, here is a download including the BSP, VMF and textures:
https://puu.sh/xIo7m/ccea4b7e5d.rar

The map is HDR only.
Also mind that if you use this method, you do not need to pack the fakeskybox textures, as the cubemap will keep working even if the textures are missing for players, they will never see the missing textures after all unless they noclip in spectrator mode.

That's it! Hope this helps
D



PS:
Just some thoughts I had, if you make two areas, with different skyboxes and the cubemap-sky area will be a dark night ala ctf-doublecross or plr-pipelone.
In this case it might be better to not use any light_env and make the sky out of reflective chrome texture! The point is that no real skybox texture is drawn behind the chrome texture at all, increasing performance. Well, this would be a very special situation, and you probably can't pass on the light_env lighting, but I just wanted to say it just in case someone can use this.
 
Last edited:

BigfootBeto

Party Time 2.0!
aa
Jun 8, 2016
496
847
The grey box below the 3d skybox, is the box I put the skybox texture in. As I had the same problem like OP, the texture looking weird I had to make a custom one.

The alternate method is neat and all, but this is really the answer to the original question. Is there any reason why not to just use the texture without the cubemaps?
 
Mar 23, 2013
1,013
347
Oh I actually forgot to mention something! Edited my previous post.

I changed the VMTs so that they are using the LightmappedGeneric shader and only have a basetexture specified and in the VTFs I unchecked the Clamp S, Clamp T, SRGT flags.

So yeah, that's the point of making a copy of the VTFs, because the flags need to be disabled. And that's how you can use the texture on brshes.
 
Last edited:

BigfootBeto

Party Time 2.0!
aa
Jun 8, 2016
496
847
Only issue is that you can clearly see the seams

I was able to fix the visible seams by using an UnlitGeneric instead of a LightmappedGeneric, and also by slightly increasing the texture scale after fitting it to a brush face (to hide the ever so slightly visible looping texture at the top).
hl2_2017-09-25_17-09-53.jpg
In the picture I'm staring at a corner, but you can barely tell there's a seam (it's pretty much the texture's fault at this point)

Also, for my purposes I found that just making a giant fake skybox in my 3d skybox works just fine (as I originally intended). The sky box is too far away to notice any parallax issues. I didn't need an (imo) overly complicated cubemap setup.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
Sorry to hijack this thread, but Lampenpam's idea has so intrigued me that I've decided to test it out for myself. First, I extracted all the sky_hydro_01 textures and converted them to Targa, and added a white bottom half to everything because that skybox only goes halfway down. Then I followed this technique to try to convert them into a cubemap. Aside from automatically compressing them and adding an unnecessary alpha channel, it worked fine (and I just needed a proof-of-concept for now; I can use the more involved technique later). Then I made a material called sky_hydro_01 that has no base texture, just a color of black and an envmap matching the cubemap I made.

fakeskybox.jpg


As you can see, it didn't exactly work out. If you get closer to any given wall, you can see that the sides are accurately sewn together, but no two adjacent walls reflect the same set of sides. And the ceiling reflects the floor and vice versa, but that actually makes sense—these are reflective surfaces, supposedly mirroring what they see opposite them. So really, everything ought to be converted into a mirror image of itself, and the names of opposite faces should be switched, right?

fakeskybox2.jpg


Crap, that's even worse. If you stand perfectly dead center, you can get the reflections on adjacent walls to line up, but no one wall reflects any two adjacent faces. This is more or less what I was concerned about earlier. What did you do to get a proper cubemap, @Lampenpam?
 
Mar 23, 2013
1,013
347
What did you do to get a proper cubemap

Good idea using an custom cubemap texture. It seems to hide the seams compleetly.
Anyway, I also had those weird reflection when I use a cube made of brushes with reflective textures, as it looked like that every face of the brushes used a unuque rendered cubemap.
This is why, instead of an box, I made a large single brush that even is a lot wider than the skybox-box, just so it's wide enough that you can't see the end from within the map. So this will be an issue if you are using the "fake-2D-skybox" method on a more open map where you can't have a single brush covering the entire sky. I didn't find a workaround for that.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
The reason becomes clear when you try placing a block in the middle of the room that uses this texture. Each side reflects differently because they're reflecting what they "think" is on the wall opposite them, and of course that's not going to be consistent when you go around the corner. That doesn't change when you turn it inside-out, as I've done.

I had another thought, though. What if I made three separate cubemaps, one for each pair of cardinal directions, and assigned them to the appropriate surfaces? The answer is "it takes a lot of trial and error to get all the orientations correct", for starters, but it does in fact work. The obvious downside: I am now resorting to packing in three times as much texture data, a whopping 21 megs in total. And that's without HDR; the skybox I used happens to have an HDR variant as well. Luckily repacking does an excellent job cutting that down, as you can see from the size of the sample file. Probably because literally half of the texture data is just empty white space I had to add to keep all the faces equal in resolution.
 

Attachments

  • test_fakeskybox.bsp
    1.7 MB · Views: 176
Mar 23, 2013
1,013
347
I would like to see how this would look like without the black brushes, since it looks like you don't need them.

However appearently you can have a ball-model with a cubemap reflecting textures too. Someone sent me this: https://gamebanana.com/prefabs/5660
Click on the videos to see it in action, it appears to work quite well.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
The black brushes were so I could get a good idea where the edges and corners were, because it was literally impossible without them. I did another version where the fake-skybox only occupied the middle of each surface and was surrounded by toolsskybox, and there was a slight edge where the two meet. Not a seam, more like a tiny wrinkle in fabric, and only noticeable when you're moving.

Oh yeah, and you can probably use this for a skybox that literally changes too, thanks for reminding me. Just add a MaterialModify proxy to each of the material files, toss a material_modify_control into your map, make sure your faces are all func_brushes (sealed with nodraw from behind) and something something output commands.