Hello guys! Some time no see. The works are going well, although not much in the mapping department, but I've been busy with other things. Today I wanted to present a new feature called "parallax interior mapping" which I wanted to implement for a very long time, but it remained a distant dream until today (thanks to a few patient people who helped me along the way).
For those who don't know, interior mapping is about making fake-3D rooms - a 2D image is applied to a surface and it bends according to player's position, creating an illusion of a 3D space. Maybe you've seen it in such games like recent Spider-Man game, the GTA trilogy and even The Matrix Demo on UE 5 just to name a few. It also creates an illusion of a lot of geometry on the screen, while costing close to nothing in performance, adding a lot of depth to the scene. I wanted to spare the technical details, but for those interested I will leave a link here. I actually wanted to talk about the process of creating my own room images in Diffusion. So let's get started.
First, here's a video from the test of initial implementation, where I got everything to finally work properly.
All surfaces are completely flat, and the room image is 2D cubemap. The image of the room looks like this:
The downside of using such image is that it's a bit frustrating to work with, and it can only be as a cube.
One of my fellow modders ncuxonaT noticed my initial start and proposed a better technique (it's being used in the link I mentioned earlier) - using just a single image with a few rooms on it. He helped me to implement it and, when everything worked properly, I decided to create my own rooms and implement them as parallax interiors. This article is about this process.
First, I crafted the rooms themselves in the Hammer editor:
Looks nice and cozy enough. Then I compiled the map:
The only purpose of those rooms is to make screenshots of them and create a 2D atlas. Quite a bit of work but it will be worth it. So, I screenshoted all the rooms from the front position and assembled a single texture with all the rooms on it. The resulting image is this:
Neat! Now, how do one assign such image to a world texture? For some time now, Diffusion has material description support which is basically a txt-file with a texture name. So we need to simply specify the interior image to a texture by writing it into the description file. This is the texture I will be using in the hammer editor:
The white color is actually transparency, the texture itself is in the DDS format. This way we will be able to see the rooms. I covered a brush with this texture and this is what I'm currently seeing in game:
Let's enable the interior shader by making a material description file for this texture:
"interiormap" "textures/interior_atlas_office"
"interiorgridx" "4"
"interiorgridy" "9"
"interiorlightstate" "40"
"InteriorMap" is simply a path to the room atlas image created earlier. Grid X and Y is the division grid for this particular texture - 4x9. We could make grid X as 8 so it would be 2 rooms per 1 window. It all depends on the texture of course. And lastly, "InteriorLightState" is a percentage value from 0 to 100, which specifies in how many rooms you want to turn the lights on.
The shader is now doing its work:
Works quite well, don't you think? Of course the illusion will likely break if viewed up close, for any other distance it holds up well. This is the limitation of this technique. All windows are being assigned randomly from the atlas image, and their lighting too. Random seed is being used, so the windows and lighting won't rearrange after save/load.
Here's an example of the technique used on a model of a building:
The model of this building is quite simple!
I tnink it's quite a nice addition for the chapter 4 (night city) and I'll see if I can utilize it in earlier chapters too. Hope you like the new feature! :)
Special thanks:
- kylebakerio: initial shader code
- SNMetamorph: grid and randomization setup
- ncuxonaT: implementing atlas image technique instead of cubemaps
- Lev: a lot of general help with graphical features (specular, bump-mapping etc.)
- Aynekko
that's amazing! parallax mapping is great and i'm shocked to see it in a half life mod lol
great work!
Thanks mate :)
This is absolutely brilliant & gorgeous. You're pulling off actual miracles with this engine & its awe inspiring. Amazing work! <3
Xash4life innit :D
do you think there's any chance the source shadercode and what not couldade available for this would be awesome for this to exist in the community for people to use
Yes, after release. You can also make mods on Diffusion as a base I guess ^^
Fantastic stuff!
A lot of quality work and time,
and then, incredibly great result!
Lord Jesus in Crist this looks unbelievable
Another little miracle, magnificent!
Jesus, It's unbelievable for me to see that this is even possible. This is amazing!
Impressive, simple 2D images rendering like 3D visually!
The main gain of such is probably about performance for sure.
This is mind-bendingly impressive. Bravo.
This mod is the best advertisement Xash3d....!
But joking aside, this is a very nice feature that makes the world deeper and more believable without wasting resources, You are great for being able to implement this function in this modification!
Amazing! 😻
Really impressive. 👍
That's freaking bonkers. Great Work!
🤯