Jump to content
The Dark Mod Forums

Rendering Real Rooms without Building


NeonsStyle

Recommended Posts

3 hours ago, NeonsStyle said:

I would kill to be able to use this. My Venice map consists of 3 in 1 maps. Old quarter, a Discricto Commerciale ( merchants quarter) and
the wealthy part around an icon of the Grand Canal.  The merchants quarter, I wanted to include a few traditional old Venice
shops, that would look fleshed out inside, but couldn't build it out as it'd be a performance hit on a very detailed map. So
to be able to use this method would be awesome. All I need is a texture of the inside of a shop n bang, instant olde venice shop. :D

I know nothing of shaders, so not sure how to use these duzenko, outside a map. Could you make a test map?

The test map is attached above

The shader there works as POC but probably will fail in a real map due to some hardcoded constants

My shader version is WIP

Link to comment
Share on other sites

Thanks man. What do I do with .fs, .qs and .ve files? Don't recognise those extentions. The .mtr is clearly a material file. 

I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:

https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to comment
Share on other sites

I have simplified the original shader, and now it uses cubemap as in the material provided by Duzenko.

It has several issues for generic use right now:

  1. The size of rooms is hardcoded in shader.
  2. The rooms must be axis-aligned.
  3. The walls between rooms are at coordinates multiple of room size.

One approach would be to use texture coordinates of the quad to deduce room size from it. If they are used, points 2 and 3 can be removed too: the rooms should be made aligned with the actual rendered quad itself, and the walls happen where texcoords are integer. One problem is that we cannot determine depth of the room this way.

Another approach is to use some shaderparms. I believe it is possible to write numbers into material definition, so that they get passed to the shader. This is not a big issue, since mapper will have to duplicate this material many times anyway: he has to set different cubemap texture for each room (well... probably not for every room 😉).

My opinion would be: use texcoords and align rooms with the rendered quad. Compute depth as K * sqrt(W*H), where W and H are width and height of a room (deduced automatically from positions and texcoords), and K is some shaderparm (equals 1.0 by default, if it can have a default). In other words, mapper specifies depth/width ratio in material for a square room, or depth/mean(width, height) in a more general case of rectangular room.

P.S. Using size of the triangles in geometric shader is a messy approach. It is less versatile than with texture coords, and also dmap is known for splitting brushes/patches sometimes.

interior_map.vs interior_map.fs

  • Like 2
Link to comment
Share on other sites

My adaptation attached

The main problem that I see is axis-alignment. I tried to come up with a rotation matrix to move into cube space but my linear algebra sucks :(

I agree that we should use texture coords to map a window on the wall

As for room depth, that could be offloaded to material shaderparms

interior.zip

Link to comment
Share on other sites

Can't get this to work. Put those files into the glprogs folder, mtr into materials, map into maps of course n installed, textures into textures,

and it doesn't work. It's just opaque glass. I"m guessing this is a 2.08 thing. I can't use that atm while I'm working on a level. :(

Edited by NeonsStyle

I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:

https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to comment
Share on other sites

I reworked the shader.
Here is the full example: https://drive.google.com/open?id=1n64WLLmaa07Dxe0VxoFK7YcoSEPIoUKW

Now it uses texture coordinates to deduce room size, and also vertexParm0 as multipliers for width, height, and depth (X, Y, and Z components respectively).
To demonstrate how it works, I have added a rotated brush on the test map.

Unfortunately, the cubemap had some weird orientation now, I hope it is fixable.
With new code, the convention for axes are: X goes along U texcoord, Y goes along V texcoord, Z goes "into" the solid.

There is a big chunk of math in fragment shader which computes the "room coordinate system", which should be constant across the whole polygon.
Maybe it could be moved to geometry shader? I recall @cabalistic told geometry shaders are expensive, but I guess it is only when they emit varying number of primitives? Should it be fast to use it compute per-triangle values and always emit same triangle?

Link to comment
Share on other sites

Meanwhile, I have a question to everyone who wants to use interior mapping: Why can't you just make a real cubicle for every room?

The thing is, interior mapping is usually used for huge modern cities, where every skyscraper has hundreds of windows, and there are many skyscrapers in the view. In this case people render 5 quads per skyscraper with every quad hosting hundreds of rooms.
In TDM, we have steampunk setting. We don't have skyscrapers, and typical houses have at most 10 windows. Wouldn't it be cheap enough to add 5 quads per every window and texture them normally without any shader? You can even put a real 3D model into such rooms (e.g. a big table) to make it look even more three-dimensional.
 

Speaking of further work, here are some possible directions:

  1. Add diversity to rooms. When you have hundreds of rooms on a skyscraper, it looks a bit too regular when all of them are the same. So it is possible to support setting several cubemaps, so that a random cubemap is used on every room. I guess this does not make much sense for TDM (just as the whole interior mapping probably does not) for the reasons described above.
  2. Support additional layers inside rooms. Basically, that would allow mapper to add alpha-textured planes inside the room, parallel to the back wall. Such planes can contain various objects like tables or cupboards. They will be flat of course, but will look closer than the back wall when player moves.

 

Link to comment
Share on other sites

59 minutes ago, stgatilov said:

There is a big chunk of math in fragment shader which computes the "room coordinate system", which should be constant across the whole polygon.

Maybe it could be moved to geometry shader? I recall @cabalistic told geometry shaders are expensive, but I guess it is only when they emit varying number of primitives? Should it be fast to use it compute per-triangle values and always emit same triangle?

I believe it's only expensive on high-poly geometry which is not the case here

Link to comment
Share on other sites

25 minutes ago, stgatilov said:

Meanwhile, I have a question to everyone who wants to use interior mapping: Why can't you just make a real cubicle for every room?

 

That was my first thought but I assumed it's even easier to slap a texture on a wall than build all the rooms

  • Like 1
Link to comment
Share on other sites

The reason we want to use this method is for performance. I want to have a few shops, and to build each
each of them out, would be a big hit to frame rate. So better to just have a texture where it looks like there's
a shop. This is where you want to convince the player something is there, but don't need them to go in there. 

Is there a reason why you all seem to be able to view this, and I cannot on 2.07?

I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:

https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to comment
Share on other sites

9 hours ago, duzenko said:

That was my first thought but I assumed it's even easier to slap a texture on a wall than build all the rooms

I think the hardest is to create the texture with everything properly aligned and oriented.

I have very little DR experience, but I think cubicles can be done this way:

  1. Create a brush.
  2. Set texture coords "to-fit" (in surface inspector?).
  3. Set texture lock (in brush menu?).
  4. Select sides one-by-one and apply interior textures to them.
  5. Move the brush along solid house and use CSG subtract to create a new cubicle.

Not too hard, it seems.

43 minutes ago, NeonsStyle said:

The reason we want to use this method is for performance. I want to have a few shops, and to build each
each of them out, would be a big hit to frame rate. So better to just have a texture where it looks like there's
a shop. This is where you want to convince the player something is there, but don't need them to go in there.

The approach with cubicles described above is also "interior mapping" in some sense. Because you still have to bake textures and apply them to the cubicle walls. The difference is that you physically create all the walls, instead of faking them with custom shader. So you have 12 triangles per room instead of 2 triangles, but you don't need custom shader. The only performance hit here would probably be shadow volumes casted by outside lights from internal walls.

The benefit of cubicles are: it is simple, it works in any TDM version, and you can even add some simple models of big furniture into the room, so that it looks more believable.

Link to comment
Share on other sites

Well, I guess I should chime in...

An interior map will save performance on depth fill.

One of the strange things about this engine is that you can pack huge amounts of geometry up close but a "long view"

will kill performance even if it is barren. This is largely due to the depth pre-pass for every light.

If there is a way to create empty rooms without this depth fill penalty then that would be great.

Please visit TDM's IndieDB site and help promote the mod:

 

http://www.indiedb.com/mods/the-dark-mod

 

(Yeah, shameless promotion... but traffic is traffic folks...)

Link to comment
Share on other sites

2 hours ago, nbohr1more said:

One of the strange things about this engine is that you can pack huge amounts of geometry up close but a "long view" will kill performance even if it is barren. This is largely due to the depth pre-pass for every light.

I believe depth pre-pass is done once per frame, and does not depend on number of lights. Also, I bet there is a material flag which disables all light interactions with the surface, so that only ambient rendering is left. Hence, we are reduced merely to initial depth fill, which is pretty cheap, as far as I remember (we have a line for it in r_glProfiling). By the way, there is no depth fill overhead when player looks directly into the room, it only kicks in if he looks from the side.

Link to comment
Share on other sites

5 hours ago, nbohr1more said:

Well, I guess I should chime in...

An interior map will save performance on depth fill.

One of the strange things about this engine is that you can pack huge amounts of geometry up close but a "long view"

will kill performance even if it is barren. This is largely due to the depth pre-pass for every light.

If there is a way to create empty rooms without this depth fill penalty then that would be great.

I agree with the previous post

From the C++/GLSL point of view, empty cubicle + cubemap is the path of least resistance, including the performance cost.

But, from the mapper's POV it feels good to be able to just slap a material on a wall (even if you still need to prepare a special cubemap texture)

It also looks good on a PR feature list

I also feel kinda responsible to support mappers' interest in custom shaders, rather then redirect them to workarounds. I just wish I had a better linear algebra skill.

Link to comment
Share on other sites

20 hours ago, stgatilov said:

Meanwhile, I have a question to everyone who wants to use interior mapping: Why can't you just make a real cubicle for every room?

  1. Because I'm a programmer and I'll go to any length working on cool things that help me avoid tedious/repetitive work! 😀
  2. A case could be made that once you've built up a handful of cubemaps, placing prefab windows with this material becomes a piece of cake.
  3. Relative to a plane with an interior map, a physical cubicle clutters up the map and is a lot harder to move around once you make it.  Although, realistically this is something you'd do as a final detail pass after your map's layout and major details are all totally done.
  4. There was some interest in trying this in conjunction with a visportal that you close from a distance and display an interior map impostor at the same location.  This might be hard to get lined up correctly.

Honestly though, you're probably right.  The real work is in making the cubemap and having to make actual room geometry as well shouldn't be a deal-breaker in terms of mapper effort or performance.

That said...

20 hours ago, stgatilov said:

Support additional layers inside rooms. Basically, that would allow mapper to add alpha-textured planes inside the room, parallel to the back wall. Such planes can contain various objects like tables or cupboards. They will be flat of course, but will look closer than the back wall when player moves.

Maybe you could repurpose the side of the cubemap that you never see as the alpha plane and use the 4th value of the vertexParm to choose its depth within the room.  Also, I tried your example and the room is currently tipped on its side... nice work though!

 

And maybe a better compromise on mapper effort and complexity would be to use a single parallax plane instead of the whole cubemapped room.  It won't look as believable when you get up close, but you could also have it fade to the window texture or something else to simulate fresnel at a sharp viewing angle where the effect breaks down.

 

 

  • Like 1
Link to comment
Share on other sites

12 hours ago, NeonsStyle said:

Is there a reason why you all seem to be able to view this, and I cannot on 2.07?

There is a major shader overhaul in 2.08, so shaders written for one won't be compatible with the other.

 

22 hours ago, NeonsStyle said:

I"m guessing this is a 2.08 thing. I can't use that atm while I'm working on a level.

You could copy out a segment of your existing map into a new one for trying this out in 2.08 without messing up the work you've done.  And once this feature gets settled and 2.08 is out you could update your full map accordingly.

Link to comment
Share on other sites

1 hour ago, HeresJonny said:

Maybe you could repurpose the side of the cubemap that you never see as the alpha plane and use the 4th value of the vertexParm to choose its depth within the room.  Also, I tried your example and the room is currently tipped on its side... nice work though!

It's probably better to add layer textures as separate maps. This way we can have e.g. 4 layers, with possibility of enabling/disabling them, and one shader which supports all the cases.
On the other hand, the front side is unused. Perhaps it should serve as hardcoded front layer on plane depth = 0. Then the outside look can be imbued into the cubemap, along with the shape of the window.

Link to comment
Share on other sites

I'm I right to assume this could be used to do portals has well? Current TDM cubemaps move with the player and that looks bad for portals but those should behave just like normal windows, so based on the discussion this type of cubemaps seem perfect to do portal effects.  Of course you need more than a cubemap to do a portal but is a steep. 

Edited by HMart
Link to comment
Share on other sites

On 4/14/2020 at 12:54 AM, HeresJonny said:

There is a major shader overhaul in 2.08, so shaders written for one won't be compatible with the other.

Right. Thanks Jonny. I'll wait for 2.08 to be released. I don't like using a beta while I'm working on a map. The effect

looks awesome though. I really hope you guys can thrash it out, cause this would be a big plus for us all. :)

I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:

https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to comment
Share on other sites

Here's an alternative approach:

https://drive.google.com/open?id=1wHJGv1txRJrpcYnqR94BL3_kBRsVAn1n

The difference here is that instead of generating a cubemap, you have a single texture with the front wall in the center and the sides/ceiling/floor in perspective:

flatroom_corrected.png.79777e5d6084ba312e4e55e90a8b12db.png

I feel like this will be easier for a mapper to make, either in-game or from an external source.  For this one I took a 1024x1024 envshot from roughly where the window would sit (I didn't try to be too precise), and kept only the _forward texture.  I brought that into Gimp and scaled it so that the front wall was a centered 256x256 square in the middle of the 512x512 texture (use the same ratio at any size).  It doesn't matter if you end up with overhang on the edges of the image that get cropped off, but conversely you don't want to end up with empty space. 

The new shader will follow the same pattern of perspective and slide around the UVs according to your position.  My problem at the moment is that it only works if you're facing one direction.  I'm not sure what coordinate space all the incoming parameters are in and how to transform them into a space relative to each face.  Can someone help out here?  I think the fragment shader is correct and the vertex shader is wrong.  Once that works, I think we could add back in the room scaling parameters too.

For reference, I tried to follow the approach here: https://github.com/OBKF/Fake-Interior-Shader-for-GodotEngine. I took out the reflect() in the vertex shader because it was messing things up and that's where I think there's a clash in coordinate spaces or I was failing to normalize things properly.

For those casually curious what this looks like, the github link has a sample video of this in Godot, you can see his input textures and the ability to scale the depth.

 

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...

I have 2.08 now, and have tried all the versions. The first one looks promising, except when you look left and right
the room tilts. The others look like nice cubemap effects. Did anyone make one that creates a proper parallax
effect in the room?

I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:

https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 2 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...