You, James Smith (served in SWAT for a decade with no failed ops), on vacation and driving your car to some nice place, to take a break from your usual work routines. Driving on a deserted road somewhere in Utah, the car breaks down. With miles of nothing behind, J. decides to go forward and stumbles upon an abandoned rock/sand processing factory with just one yawning guard sitting there. Pointed by the guard, J. walks behind the factory to find the phone. When he comes back, he only sees two army trucks and the dead guard… J.'s curiosity leads him inside the factory only to find that this place is absolutely not what it seems to be…

Report RSS Parallax interior mapping

An implementation of parallax interior mapping feature in mod Diffusion.

Posted by on

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:

interior


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:

hammer1


hammer2


hammer3


Looks nice and cozy enough. Then I compiled the map:

hammer4


hammer5


hammer6


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:

x1RfU52q0IY


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:

texture


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:

 h lAg8Rs 0


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:

fin1


fin2


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:

paral2


The model of this building is quite simple!

mdl


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

Post comment Comments
cambreaKer
cambreaKer - - 997 comments

that's amazing! parallax mapping is great and i'm shocked to see it in a half life mod lol
great work!

Reply Good karma Bad karma+10 votes
Aynekko Author
Aynekko - - 657 comments

Thanks mate :)

Reply Good karma+7 votes
LadyJaneThrace
LadyJaneThrace - - 865 comments

This is absolutely brilliant & gorgeous. You're pulling off actual miracles with this engine & its awe inspiring. Amazing work! <3

Reply Good karma Bad karma+7 votes
Aynekko Author
Aynekko - - 657 comments

Xash4life innit :D

Reply Good karma+7 votes
Guest
Guest - - 689,230 comments

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

Reply Good karma Bad karma+1 vote
Aynekko Author
Aynekko - - 657 comments

Yes, after release. You can also make mods on Diffusion as a base I guess ^^

Reply Good karma+6 votes
Magic_Nipples
Magic_Nipples - - 1,325 comments

Fantastic stuff!

Reply Good karma Bad karma+6 votes
Musie_(MyCbEH)
Musie_(MyCbEH) - - 231 comments

A lot of quality work and time,
and then, incredibly great result!

Reply Good karma Bad karma+5 votes
BrussTrigger
BrussTrigger - - 404 comments

Lord Jesus in Crist this looks unbelievable

Reply Good karma Bad karma+6 votes
Qwertyus
Qwertyus - - 2,505 comments

Another little miracle, magnificent!

Reply Good karma Bad karma+5 votes
Sandii
Sandii - - 66 comments

Jesus, It's unbelievable for me to see that this is even possible. This is amazing!

Reply Good karma Bad karma+4 votes
StevenKal
StevenKal - - 72 comments

Impressive, simple 2D images rendering like 3D visually!
The main gain of such is probably about performance for sure.

Reply Good karma Bad karma+4 votes
monster_urby
monster_urby - - 3,023 comments

This is mind-bendingly impressive. Bravo.

Reply Good karma Bad karma+5 votes
Mr.Maris
Mr.Maris - - 308 comments

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!

Reply Good karma Bad karma+3 votes
SweetRamona
SweetRamona - - 5,114 comments

Amazing! 😻

Reply Good karma Bad karma+3 votes
fresco
fresco - - 139 comments

Really impressive. 👍

Reply Good karma Bad karma+3 votes
Bloodvayne
Bloodvayne - - 536 comments

That's freaking bonkers. Great Work!

Reply Good karma Bad karma+3 votes
ehow
ehow - - 23 comments

🤯

Reply Good karma Bad karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: