dotproduct related question


(cis) #1

while reading about dotproduct/dotproduct-squared i was wondering if there also is a feature that is quite similar to dotproduct. as far as i understood, dotproduct blends in another texture if the surface has a certain angle, which is very great for non-flat surfaces especialy certain forms of terrain as sock’s impressive pics showed.

couldn’t this “system” be used do randomly blend in “decals” on flat surfaces. kind of a dotproduct that instead of taking xyz arguments, takes minsize, maxsize, frequency (per64x64units?), and rotation (so the “decal” texture is rotated before being applied to the surface).

for example a metal door, getting a shader with this type of dotproduct could have random “splotches” of rust all over.

if this feature already exist, it would be great if someone tells me what to look for :wink:

btw, i read somthing about overdraw related to dotproduct, does that mean, that all the textures defined in the shader are drawn, even if only one of them shows?


(ydnar) #2

Q3Map2 supports a _decal entity for projecting decals onto geometry. It fades the vertex alpha by the dotproduct of the vertex and the decal projection axis.

See the def file included with Q3Map2 to use it, or grab a recent build of Q3Map2.

y


(cis) #3

yes, i looked at it before, but the decal still is a real decal (poygonoffset), ie if it gets shot at its either have to have “nomarks” or the shot mark will cause a z-fighting effect (at least in sof2). or is there a way to “randomize” the decal with the decal projector?

i was thinking that this would be a great feature, as the “decals” would be blended in, have random position, size and form (to a degree) and even have the texture that is used as decal rotated by up to N degrees for each projection, which makes it look more natural as patterns are harder to perceive when the texture is rotated between to adjacent decals(chaos).

looking at sock’s screenshots i thought this would be also a great use for a changed q3map2 command of dotproduct, eg simlulating a wall loosing its paint, some metal construction rusting etc and all that without repetitivness and without the need to think about angles when constructing it (which would be needed for the use of dotproduct for this iirc) and the shader taking care of the complete effect which would otherwise need a lot of manual hazle.

just wanted to mention it in case u like the idea


(ratty redemption) #4

I too was going to suggest something like this, as it would be a useful way to blend in various rock textures, so terrain doesn`t repeat too much and cause the tiling patterns.


(Gleeb) #5

A similar effect can be acheived with clever use of shaders, if you can’t figure it out, I’ll post a sample when I get home :stuck_out_tongue:


(obsidian) #6

Hmmm… the only problem I can see is the number of rendering passes required to add the slightest bit of random detail. You’ll probably need at least 3 or 4 additional passes. But I’m just speculating.

In regards to your question about overdraw and dotproduct:
Yes, if you have a dotproduct shader using two rendering stages, then two rendering passes will be required for every surface that uses the dotproduct shader. Even if you can only see one pass, there is the other 100% transparent pass that you are not seeing. This is the same thing with any other shader that uses alpha effects.

If you have an area of your terrain where you can only see one layer, then simply replace it with a non-dotproduct shader to help increase performance.


(cis) #7

ah, i wasnt aware that overdraw is just another term for extra stages on the shaders, thanks for reducing my general confusion a bit more :slight_smile:

about the additional passes, the way i mean that feature it would have the same number of stages as dotproduct or dotproduct2, just that not the angle of the surface decides where to draw which texture, but instead some variables (mentioned above). of course it wouldn’t be a means to texture the whole map, but used carefully it could be an easy way to add diversity to small areas that are made to catch the eye. obviously for ppl who can do professional textures for themselves its not very interesting, but for “recyclers” like me who like to stick to the games original texture set and try to make them look different by in-game/in-editor means (eg colored lighting, shadows etc) it would be great.

well, i guess i could also use decals with alphachannel, but decals for one thing cause z fighting with bulletmarks in sof2 and there is a strange phenomenon which is caused by them. they cause “splits” of brushes. an example would be an island surrounded by water. inside the island, a room which is partialy below water level.
now if the water has polygonOffset, then it causes a split of the brushes forming the walls of that room (split at waterlevel, seems like 1 unit thick), even though that the water is not even touching any of the brushes (quite far off actualy). i have witnessed that before in an earlier build of q3map2, its not version specific. so i try to minimize decal usage. (i had decal on the water to avoid z-fighting with a fogbrush. this didnt work 100 percent though (still z-fighting at certain distances), so i removed polygonoffset and extended the fog brush to 8 units below waterlevel)


(ratty redemption) #8

@Gleeb, please enlighten us, I`m always willing to learn new shader tricks :slight_smile: