Specifics of Decal Rendering Created 5 years ago2013-02-05 11:04:08 UTC by Penguinboy Penguinboy

Created 5 years ago2013-02-05 11:04:08 UTC by Penguinboy Penguinboy

Posted 5 years ago2013-02-05 11:04:08 UTC Post #312479
I was wondering if any Goldsource veterans could enlighten me about how decals are supposed to work when they appply to multiple faces. I've been messing with Hammer for a little while now and I still have no idea what behaviour Hammer and the engine use for decals, aside from the fact that the two are quite different.

Let me demonstrate (please excuse my silly example map):
User posted image
User posted image
Both behaviours seem illogical. Sometimes the decal is applied to multiple faces, sometimes it isn't. And when you try some different angles:
User posted image
The VDC and a few other places say that the decal texture is projected outwards from the infodecal entity, however this explanation seems inconsistent with the screenshots above. Hammer seems to be projecting to all faces in the first and last screenshot, but didn't project at all in the second one. The reverse is true for the in-engine screenshots.

Does anybody have any idea how the engine renders decals like this?
Penguinboy PenguinboyHaha, I died again!
Posted 5 years ago2013-02-05 12:09:33 UTC Post #312481
I really can't answer your question. But I do recall in CS 1.6 that the spray tag decal inherits the texture's scale and rotation properties when applied to a surface.
Posted 5 years ago2013-02-05 14:41:32 UTC Post #312484
In the game code it determines the world geometry affected by tracing along the min/max of a 10x10x10 bounding box centered around the origin of the infodecal.
User posted image
That makes sense on the left, as the bottom brush might be more than 5 units away from the infodecal origin. It's not as clear in your other screenshots, but I'd start from that figure.
Daubster DaubsterVault Dweller
Posted 5 years ago2013-02-05 22:05:20 UTC Post #312485
Never made sense to me either.

Time to dig through the HL source code :P
Posted 5 years ago2013-02-06 09:21:09 UTC Post #312486
@Daubster: Awesome, that makes a lot of sense, the engine behaviour does seem consistent with your explanation. I don't even know what Hammer is doing, but what the engine does is the important thing in the end. Is the decal code you mentioned available in the SDK? Can you point me to the file so I can take a look?

Edit: I tested this theory and it seems correct, except it looks to be an 8x8x8 box rather than a 10x10x10 one. This screenshot has a bunch of brushes with a decal applied to the bottom side of each brush. The decal is applied to the floor for the first three, but doesn't when the distance from the floor is >= 4, which suggests a bounding box of 8 units.
User posted image
Penguinboy PenguinboyHaha, I died again!
Posted 5 years ago2013-02-06 19:03:24 UTC Post #312497
World.cpp in the server project, CDecal class. Forgot the exact name of the method, but I referenced the one for static decals.

It's interesting how the bounding box appears to be smaller than the one defined in the game code. Then again, there's probably stuff to do with projecting the decal in the engine that changes things. Either way, good to see some consistency. :)
Daubster DaubsterVault Dweller
Posted 5 years ago2013-02-08 03:33:22 UTC Post #312514
I checked out the code, and it looks like the 5-unit box is for testing against something else (my best guess would be perhaps decals showing on models), and then it sends the decal across to the engine regardless of whether that test succeeds or fails. So it looks like the engine itself determines what faces the decal is visible on. I'm going to stick with the 4-unit radius because that's how the engine is behaving in my tests.
Penguinboy PenguinboyHaha, I died again!
Posted 5 years ago2013-02-09 21:24:54 UTC Post #312532
I always had one idea how to have almost Source-like RGB decals in HL without any mods. Simply make 3 separate textures for each of the RGB channels and put all 3 decals into same spot. A bit expensy but u have fully RGB, 768 color ^^ decals.

Also I just found the working of env_sound very interesting. Believe it or not but it affects the player in a very similar manner explosions does in HL! Turns out you not only need to be in it's radius, but you also have to see the env_sound entity itself for it to affect you. This way it doesn't affect you through walls, even if you're inside the radius...

EDIT: I just also noticed that for the transition from one env_sound to another to be successful you have to stay in the new one for at least half a second or something. If the radius of the new env_sound is so small that by longjumping or gaussjumping you can pass through it in miliseconds, the new env_sound won't take effect. The solution is to simply set a bigger radius for the new env_sound so you stay longer in it. Thanks rufee for testing.
User posted image
Posted 5 years ago2013-02-09 22:15:00 UTC Post #312533
Who is portrayed in the image above?
a. A. Cooper
b. Capt. J. Sparrow
c. A Potato
d. I don't know
e. All of the above
Captain Terror Captain Terrorwhen a man loves a woman
Posted 5 years ago2013-02-09 23:00:30 UTC Post #312534
Captain Jack Sparrow onboard the black dozer
rufee rufeeSledge fanboy
Posted 5 years ago2013-02-12 16:43:57 UTC Post #312585
There are many entities we can investigate deeper
Posted 5 years ago2013-02-12 21:48:16 UTC Post #312586
Love seeing this type of research, even if it's a 15 year old game engine. Wonder if there are people doing this with newer engines too.
You must be logged in to post a response.