PDA

View Full Version : How to use detailtextures in a professional manner



TrEmPlEr
17-06-2015, 06:51 PM
Hello everyone and welcome to my first tutorial.

Let me start with the basics:

If you don't know what a detail texture is, I shall explain.
Basically you have a normal texture on a brush, like a wall texture or ground tiles. A detail texture is an additional layer for a defined texture.

You could add dirt and small stones to a ground texture by using a detail texture or use scratches on a metal floor.

But this is nothing I really need because I can draw/edit textures with such details. So why am I writing this tutorial then? Because there is another technique to use them!

So welcome to my real detail technique.

You can use 512x512 textures in your map with this unique technique!

Uhh... But can't you do that already? You are right, but:
- 512x512 textures have to be downscaled in Hammer a lot to be usefull.
- 512x512 textures have big load times if you create a wad with like 100 of them.
- 512x512 textures when downscaled in Hammer will fill up your allocblock limit pretty fast!
- 512x512 textures scaled down also increase the wpolys a lot!

So time to show you some magic:

http://i.imgur.com/PajIPFPl.jpg (http://imgur.com/PajIPFP)
This is a 512x512 normal texture, downloaded from cgtextures and edited by myself.

As you can see, it looks pretty sharp for halflife 1.
The texture is downscaled to 0.125 x 0.125 on the brush to look like that.
So we already have 112 wpolys only for this room.

http://i.imgur.com/4lD3hR4l.jpg (http://imgur.com/4lD3hR4)
This is a 64x64 normal texture scaled 1x1 ( I resized the 512x512 texture down to 64x64 )
Look, only 34 wpolys, but an awful texture...

So what we want is the best quality and also low wpolys.
You think thats not possible? It is!

Now we start to use detail textures.
We need a 512x512 texture saved as 24 bit in .tga format.
In my example I named it: cg_textures_example_trempler.tga
Also we need a 64x64 texture in your .wad that looks the same as your 512x512 ( A resized version of it )
And we also need a 64x64 texture that is filled with grey color.

http://i.imgur.com/9ZRkKjJl.jpg (http://imgur.com/9ZRkKjJ)
Here I used a 64x64 grey only texture. Also 34 wpolys :)

So the next step is, create a mapname_detail.txt (yourmapname than _detail)
Now it should look like this:

cgtextex_tr_sma detail/example/cg_textures_example_trempler 1.0 1.0

The first information is the texture in my wad.
The second information is the path where my detailtexture is stored and named.
The last information is the size of it, 1.0 x 1.0 you also can use -1.0 x 1.0 if you want to flip it.

If you did everything and start your map again, check if r_detailtextures is set to 1 and also supported.

If so, we have this fantastic result:
http://i.imgur.com/crf4Qvjl.jpg (http://imgur.com/crf4Qvj)
http://i.imgur.com/DSrbfV2l.jpg (http://imgur.com/DSrbfV2)

I think you understand now, why I love this technique.
Someone asked me to share it, and here it is :)

Also you can do a lot of stuff, make the detailtexture smaller like 0.1 0.1 to have super high detailed floor tiles as example.

Oh. One last hint, all these grey textures could make you mad in Hammer. Create 2 wad files, one with the downsized 64x64 textures or what you need ( size doesnt matter much ) and one wad with the same textures but just all in blank-grey ! ( dont change names of them ) than you can swap before compiling the map to not work with grey textures :)

Here is the download:

https://drive.google.com/file/d/0B1mPtNQgG1rUZm10S0JFcHUwUlE/view?usp=sharing
Or use
http://www.filedropper.com/tremplersdetailtexturesguide

Thanks a lot :)
Comments, Feedback, Questions are welcome !


-Trempler

wolf-3d
17-06-2015, 07:05 PM
+1 Trempler, Excellent method and a well explained/clear tutorial.

GeckonCZ
17-06-2015, 10:44 PM
Good tut and result is really nice.

Keep it coming.

Kachitos
18-06-2015, 02:48 PM
I remember using 0.5 scaled 512px detail textures on brushes with the 256px version of the detail tex. It looked really good, sharper than most source games but the fps hit was there so i gave up. Definitely going to try your method out someday, thanks!

GiGaBiTe
19-06-2015, 04:06 AM
Detail textures have far too many cons to their use than benefits.

1) Maps with detail textures are very easy to cheat on. A couple edits to the texture definition file = white walls galore.
2) Detail textures can cause severe performance hits, on top of the already abysmal performance issues of AMD/Intel GPUs and styles lights.
3) Adding dozens of 512x512 targa images to likely an already pretty big resource dependency list of the map = long download times.
4) Detail textures are rarely used correctly. Often a face with a detail texture is placed next to a normal face which results in the face "popping" out. This can cause eye strain if done in large areas.
5) Additional complexity in the mapping process of maintaining multiple sets of textures AND a definition list.

Over the decade or so that detail textures have existed, I've only seen a tiny handful of maps that used them correctly. The majority of them were on CS:CZ, which is what detail textures were designed for. I think I've only seen two community maps that were bearable to look at with detail textures.

In my opinion, detail textures are just another one of those ugly bolted on hacks that Valve so frequently likes doing. The implementation is poor and the feature is almost entirely useless.

wolf-3d
19-06-2015, 07:20 AM
While I cannot disagree with you GiGaBiTe because you are fundamentally correct,
the tutorial is both clear/easy to understand and the knowledge passed on is valuable to current mappers.

We all have to remember that even a "standard box room" textured using only the halflife.wad can either be bland or look good. (Artistic/colour coordination skills vary, just like programming/logic skills or the amount of pre-design work a mapper may do before they open Hammer.)

So where possible lets keep things critical but with a positive and helpful slant. (If you cannot think of a positive slant, still post but just head it "Warnings/things to be aware of from my own personal experience".

---

If you are a "newbie mapper", this technique falls towards the end of your map building process, get your "overall" map theme on paper[i.e. Type of map/gameplay ideas etc], build your maps layout [walls, door, windows with design textures if possible], test map for problems [lack of viz blocking, choke/spawn spam points], replace design textures with final textures, then :
Think about particular areas where gameplay is both slow and where players may spend a Lot of time [e.g. a Puzzle room, where several players need to co-operate to solve something.]
This would be the ideal area to try out "Detailed Textures".
[:banghead: EDIT: Forgot Lighting, remember there is no real reason for using "Detailed Textures" in dark or unlit areas, because most players will never see them.]
If you like the results (given the amount of time and effort it took you to detail the textures), repeat in other areas where players may pause and look.

TrEmPlEr
19-06-2015, 08:18 AM
Detail textures have far too many cons to their use than benefits.

1) Maps with detail textures are very easy to cheat on. A couple edits to the texture definition file = white walls galore.
2) Detail textures can cause severe performance hits, on top of the already abysmal performance issues of AMD/Intel GPUs and styles lights.
3) Adding dozens of 512x512 targa images to likely an already pretty big resource dependency list of the map = long download times.
4) Detail textures are rarely used correctly. Often a face with a detail texture is placed next to a normal face which results in the face "popping" out. This can cause eye strain if done in large areas.
5) Additional complexity in the mapping process of maintaining multiple sets of textures AND a definition list.

Over the decade or so that detail textures have existed, I've only seen a tiny handful of maps that used them correctly. The majority of them were on CS:CZ, which is what detail textures were designed for. I think I've only seen two community maps that were bearable to look at with detail textures.

In my opinion, detail textures are just another one of those ugly bolted on hacks that Valve so frequently likes doing. The implementation is poor and the feature is almost entirely useless.

Let me answer on this :)
1. Yes you are right you can "cheat" with them, like when r_Detailtextutes 0 the map is blank, there are also console commands that render the map blank, so this can be done with .wad´s also.
2. Detailtextures cant cause server performance hits, this is not correct. Who said that? Same to light styles, these are allways expensive in use. About AMD/Intel not sure, my Radeon 4870 and also my gtx970 have no drops.
3. Yeah this is correctly the size can be big.
4. Mapper fault. You have to know how to use this technique. I found a way for myself to make this usefully.
5. Yeah it is more work but if used well the result is great.

http://cs.gamebanana.com/maps/184750 <- Here my cs 1.6 map with a lot of 512x512 DetailTextures.

And thank you for writing :) If I´m wrong with something you wrote there, I´m sry but so far I havent found a "No-Go" to use them.

w00tguy123
19-06-2015, 11:46 AM
Nice tut.! I at least want to use this method to texture my dynamic skybox. I didn't even know detail textures could fully replace normal textures. I always thought they were monochrome overlays or something.


2. Detailtextures cant cause server performance hits, this is not correct. Who said that?
Nobody did :p. He said it causes severe performance hits. This is good to know because I was beginning to think a map made out of detail textures would have better performance because of the lower wpoly.

wolf-3d
20-06-2015, 07:35 AM
...
Nobody did :p. He said it causes severe performance hits. This is good to know because I was beginning to think a map made out of detail textures would have better performance because of the lower wpoly.

Oops, now I am confused, I thought Gigabyte was referring to the General Use of "Detailed Textures" as seen in most maps. (Here I have noticed the same problems and thus agree.)

But I don't think this implementation is the same, I thought people where building those maps by using a "High Res/Sharp Texture" and then overlaying it with an "Effects/Transparent" Texture.

Whereas Trempler is suggesting using the Same Method with a "grey only texture" (Instead of a Transparent Texture with blemishes, scratches, dirt etc.)

I would assume the GPU/render code, needs to do 2 times pass for a "transparent texture" (like it does for water.) whereas here it actually just renders the "High Res/Sharp Texture" (and possibly ignores/does not render the Grey Texture? - IDK).

Have I got this wrong?
(I have not tried using Detailed Textures for many years.)

w00tguy123
20-06-2015, 11:54 AM
As I understand it, the grey texture will be rendered in addition to the detailed one. On most systems I would expect the performance hit to be negligible, but apparently some of them choke on "special effects" like this.

If HL implements detail textures using the CPU (combining textures and then sending them to the GPU to render in one pass, on demand (http://vterrain.org/Textures/detail.html)), then it would make sense that using them would hurt performance just as much as lighting styles.

GiGaBiTe
21-06-2015, 08:47 PM
I would assume the GPU/render code, needs to do 2 times pass for a "transparent texture" (like it does for water.) whereas here it actually just renders the "High Res/Sharp Texture" (and possibly ignores/does not render the Grey Texture? - IDK).

Have I got this wrong?
(I have not tried using Detailed Textures for many years.)

The base texture will always be rendered, no matter what you set the base texture to. If this wasn't the case, every detail textured face would look like a hall of mirrors to people with detail textures disabled.

Using solid colors for base textures under the detail texture is bad because it will alter radiosity lighting calculations. If you have let's say an orange base texture and a grey detail texture, the bounced light will still be orange and look very strange. The same goes with using low resolution base textures; Since the lightmap grid is tied to texture and face size, you can end up with horrible staircase lighting if the texture is expanded too much or eating too much lighting data if it's too small.


If HL implements detail textures using the CPU (combining textures and then sending them to the GPU to render in one pass, on demand (http://vterrain.org/Textures/detail.html)), then it would make sense that using them would hurt performance just as much as lighting styles.

The HL engine has no concept of advanced rendering techniques like this. It basically blasts everything to the GPU in immediate mode as the engine gets data in the frame ready. Valve today still doesn't have any concept of proper rendering techniques, which is why CS:GO has the horrible bolted on "dynamic lighting" system that needs a GTX980 to run at any respectable frame rate.

Lymphoid
05-08-2015, 12:11 PM
What exactly is happening here? There is a text file that tells the map to replace with high res image? Why does this make the game smoother? Can I do this will all my textures in game? Was this used in HL? Thanks.

GiGaBiTe
08-08-2015, 09:56 PM
What exactly is happening here? There is a text file that tells the map to replace with high res image?

That's not how detail textures work.

The detail texture definition list tells the engine which TGA image to overlay on top of an existing texture and what scale the TGA image should be rendered at. The base texture will always be rendered regardless of what detail texture is used.


Why does this make the game smoother?

Detail textures don't make the game run better, they make the game run worse.


Can I do this will all my textures in game?

Yes, you can use detail textures on pretty much all texture types. I think the only exception are special textures like water and scrolling textures (textures prefixed with ! and SCROLL respectively.)

[/QUOTE]Was this used in HL? Thanks.[/QUOTE]

No. Detail textures were added to the HL engine for Counter-Strike: Condition Zero, which was released in 2004. You could technically add detail textures to the HL campaign now, but the maps are so poorly made and lacking in detail that it'd be a pointless effort. You'd get better results by remaking all of the HL maps and fixing the massive amount of problems they have.

spy-warrior
20-08-2015, 11:39 AM
Hello everyone and welcome to my first tutorial.
...
-Trempler

Share your mapping expertise by writing a tutorial!
http://scmapdb.com/contribute:tutorial

You can copy images and files.

TrEmPlEr
20-08-2015, 03:59 PM
Detail textures don't make the game run better, they make the game run worse.


You are 100% wrong at this point, use it as I wrote and you can make the map even smoother ;)
I have a huge testmap for this if you dont trust me.

And Spy-Warrior I maybe do that soon :) was a bit lazy

GiGaBiTe
21-08-2015, 12:51 AM
You are 100% wrong at this point, use it as I wrote and you can make the map even smoother ;)
I have a huge testmap for this if you dont trust me.

Here's a real world example that isn't a box with 6 walls.

CPU: i5-2400
RAM: 8 GB
GPU: R9 280x
Res: 1600x1200

de_aztec_cz:

Without detail textures: 153 FPS
http://i.imgur.com/XfxHl0Oh.jpg

With Detail textures: 113 FPS
http://i.imgur.com/zZsiQuXh.jpg

That's a 26% reduction in frame rate.

What was that about it not affecting performance again?

I also ran the tests on two other of my machines (A8-6500 and Pentium D 805) and the performance hit is still there.

TrEmPlEr
21-08-2015, 02:45 AM
as I told you before, you havent used my methode.
http://i.imgur.com/bweMYHjl.jpg
http://i.imgur.com/UnOLKs3l.jpg
Taken on my old pc that can play hl2 on medium settings.
*edit* Fullscreen links
http://i.imgur.com/bweMYHj.jpg
http://i.imgur.com/UnOLKs3.jpg

GiGaBiTe
21-08-2015, 03:54 AM
as I told you before, you havent used my methode.

I've already proven my point that detail textures cause performance problems.

The only thing you do differently is use solid fill textures. Other than that, there's no difference in your method vs. how they're used by default.


http://i.imgur.com/bweMYHjl.jpg
http://i.imgur.com/UnOLKs3l.jpg
Taken on my old pc that can play hl2 on medium settings.

I find it very interesting that both screenshots don't register even 1 frame of difference. Even in an empty room, there is a small variation on frame rendering times.

If that doesn't say the screenshots are rigged, then being cryptic about the PC specs the map is running on gives more reason to believe they're rigged.

You're going to have to post the map for scrutiny for "your methods" to be believed. I don't need to post mine since you can grab the BSP from CS:CZ

Solokiller
21-08-2015, 05:50 AM
Different computers may produce different results due to GoldSource's renderer not being designed for modern systems. I suggest you tone down the accusations.

TrEmPlEr
21-08-2015, 07:07 AM
http://cs.gamebanana.com/maps/184750 take a look, it may can slower down some computers but so far I never noticed something.

GiGaBiTe
21-08-2015, 09:42 PM
Different computers may produce different results due to GoldSource's renderer not being designed for modern systems. I suggest you tone down the accusations.

Except in his own words:

"You are 100% wrong at this point, use it as I wrote and you can make the map even smoother :)"

IE. being an ass and then posting rigged screencaps to try and make me look like I don't know what I'm talking about.


take a look, it may can slower down some computers but so far I never noticed something.

No, you don't get to change your story to try and save face from your earlier comment. According to you, detail textures should never cause performance issues in any situation.

Here's your map:

Detail textures disabled:
http://i.imgur.com/aQZJ7jGh.jpg
149 fps

http://i.imgur.com/K3atlaMh.jpg
116 fps

Detail textures cause a 22% performance hit in this area. I don't see "your method" making any difference.

The reason that your screenshots didn't register any frame differences is because you have gl_vsync 1 and a frame rate less when detail textures are enabled and disabled.

w00tguy123
22-08-2015, 01:03 AM
I'd be interested to see how fast that area renders with normal 512x512 textures scaled down. Even if detail textures perform worse, there's still a reason to use them - the flashlight beam won't be tiny. There doesn't seem to be a way to change the flashlight scale via compiler options (I've tried -dscale, -scale, and -notexscale).

That said, using detail textures this way may be going a bit too far. If someone has a crappy framerate because of detail textures, then it would be nice to let them turn it off without seeing a completely white map.

TrEmPlEr
22-08-2015, 03:39 AM
IE. being an ass and then posting rigged screencaps to try and make me look like I don't know what I'm talking about.
No, you don't get to change your story to try and save face from your earlier comment. According to you, detail textures should never cause performance issues in any situation.
The reason that your screenshots didn't register any frame differences is because you have gl_vsync 1 and a frame rate less when detail textures are enabled and disabled.

Actually I was wrong about performance than, but tbh I never had a drop like you there.
Tested on my 3,0 Duocore Intel + 8 gb ddr + radeon 9800 pro and I have only a difference of 4-5 fps
And on my main pc 4,0 ghz Intel quadcore i7 + 16 gb ddr + gtx970 none.
( I made the screenshots with my girlfriends computer: 3,0 Quadcore Intel, 8 gb ddr , gtx 660. )

And call me using rigged picture is just a bitchmove, why should I ? were are my benefits of doing that?
Actually I cant see such a huge drop on my machines, maybe it has something to do with windowed mode or resulution or some other settings.
After talking with a good friend of mine the only possible fps eating could be the generating of mipmaps for the detailtextures and the performance loss might be because they are not generated by HL.

wolf-3d
22-08-2015, 07:36 AM
I find this very interesting and like w00tguy, would like to actually find out (if possible) the Pros and Cons of what is happening:

"The reason that your screenshots didn't register any frame differences is because you have gl_vsync 1 and a frame rate less when detail textures are enabled and disabled."

Gigabyte: "gl_vsync 1" Because I had no idea what it was/does, I did a quick search, does it force your GPU/Video card to sync(hronize) refresh rates with your monitor. (i.e. Cause your GPU to slow down but theoretically "smooth" out video playback.)
Also if "video playback" is what I think it is, why would it cause changes here. (or is SC general gameplay treated like video due to the old openGL draw code SC employs.)

And likewise Trempler for:
"After talking with a good friend of mine the only possible fps eating could be the generating of mipmaps for the detailtextures and the performance loss might be because they are not generated by HL."

Is there a possibility then what we could make some minor openGL code additions ? (or will adding mipmap generation/correcting the code be a hugh task.)


PS: Please don't let this degrade into a personal conflict over "who is right or who is wrong", "name calling etc", this thread may end up giving us some sort of road map when it comes to improving gameplay, maps and/or our code base.

Solokiller
22-08-2015, 08:24 AM
Once we've switched to shaders detail textures should be much more performant. They're basically highly detailed decals, so rendering them is a matter of drawing alpha multiplied RGB data. A shader can do that in a very efficient way.

GiGaBiTe
24-08-2015, 04:29 AM
I'd be interested to see how fast that area renders with normal 512x512 textures scaled down.

I've never been able to use more than say 5 or so 512x512 textures in HL maps without the engine crashing when the map loads with ambiguous errors. The compile tools complain too with "larger than normal texture xyz."


Actually I was wrong about performance than, but tbh I never had a drop like you there.
Tested on my 3,0 Duocore Intel + 8 gb ddr + radeon 9800 pro and I have only a difference of 4-5 fps
And on my main pc 4,0 ghz Intel quadcore i7 + 16 gb ddr + gtx970 none.
( I made the screenshots with my girlfriends computer: 3,0 Quadcore Intel, 8 gb ddr , gtx 660. )

You've made a large error in assuming that AMD and Intel hardware will perform exactly like on your Nvidia cards. It's been known for over a decade that later ATI and AMD GPUs, along with Intel parts have severe problems rendering in the HL engine. If you want to make maps that work on all three card vendors, you can't force the use of detail textures, you can never use styles lights and the obvious is to keep the w_poly count as low as possible.

The Radeon 9800 doesn't count because it was released in 2003, and based on older hardware which was around when HL1 was still popular. ATI back then did lots of work to make their hardware work right with HL1 engine games, and the Radeon 9800 as a result works fine with it. That is of course if you're using the correct driver version, as later driver bundles broke much of the performance features of the card.


Once we've switched to shaders detail textures should be much more performant. They're basically highly detailed decals, so rendering them is a matter of drawing alpha multiplied RGB data. A shader can do that in a very efficient way.

I'd much rather the dev team focus on fixing styles lights than a bolted on hack like detail textures. Styles lights cause severe performance issues on AMD and Intel GPUs and can't be turned off by the client like detail textures can. Styles lights can be disabled by the client with the cvar "r_dynamic 0", but this cvar has the cheat flag and can only be used with sv_cheats set to 1.

Disabling styles lights only has two major drawbacks, switchable lights will always be on and flashlights won't work. Other styles lights like flickering/fading lights also won't work, but most of the time they're being used incorrectly and look awful, so they can be ignored.

If the fix on the rendering engine is going to be months/years away, please make r_dynamic a non-cheat cvar so we don't have to suffer the game locking up every time someone turns a light on.

Solokiller
24-08-2015, 05:08 AM
We're going to have to deal with detail textures and light styles at the same time when we upgrade the renderer, no avoiding that.
We'll look into making r_dynamic a non-cheat cvar.