PDA

View Full Version : ET clip shader question


No1_sonuk
9th September 2005, 20:53
I'm trying to put together a nodraw clipping shader that still shows bullet marks.
After several attempts with "surfaceparm nodraw" in there, I found out that turns off any drawing.
So I've come up with this:textures/pop/pop_clipweapmetal
{
qer_editorimage "textures/common/clip_metal.tga"
qer_trans 0.3

polygonOffset

surfaceparm metalsteps
implicitMask -
}
Where pop_clipweapmetal.tga (referenced by the implicitMask) is a 16x16 TGA with the whole surface alphaed out.
This works in a test map, but I was wondering 2 things
Bearing in mind this is primarily for a lot of obstacles on a beach invasion map, would this be significantly more of a performance hit than traditional nodraw?
Is there a better way that still retains the bullet marks and the material attributes?

Thanks

EB
9th September 2005, 22:13
There is an easier way but I am out the door for the weekend...if no one else answers you by monday...I will be back.
-------------------------------------------------------------------
Q3map2 Manual Wrote:

---polygonOffset

Surfaces rendered with the polygonOffset keyword are rendered slightly off the polygon's surface. This is typically used for wall markings and "decals." The distance between the offset and the polygon is fixed. It is not a variable in Quake III Arena.

Design Notes:

* Use this for wall or floor markings, particularily for direction arrows for team games. Texture the brush with the decal shader on one face and the other faces with a nodraw shader. Then place the brush flush with the surface of the wall or floor.
* When using a _decal entity for texture projection, polygonOffset must be used to prevent Z-fighting. If you experience problems with depth sorting, try using sort 6.

---surfaceparm nomarks

Projectiles will explode upon contact with this surface, but will not leave marks. Blood will also not mark this surface. This is useful to keep lights from being temporarily obscured by battle damage.

---surfaceparm nodraw

A texture marked with nodraw will not visually appear in the game world. Most often used for triggers, clip brushes, origin brushes, shaders with cull none or cull disable and so on. This keyword is found in "common/nodraw" so you shouldn't need to specify this.

No1_sonuk
9th September 2005, 22:27
PolygonOffset was used as the shader is intended for clipping LODed misc_gamemodels using a reduced-detail version of them. Makes sure the marks show without z-fighting issues.

Omitting nomarks is no good if nodraw is used. I want the marks to show.

SCDS_reyalP
9th September 2005, 23:19
Bearing in mind this is primarily for a lot of obstacles on a beach invasion map, would this be significantly more of a performance hit than traditional nodraw?

Likely. It adds to r_speeds.

Is there a better way that still retains the bullet marks and the material attributes?
Thanks
I don't see one offhand. It seems like if you take nomarks out of a clip texture, it should have marks, but in actual fact it doesn't. If this is for a mod, that might be something worth changing in gamecode.

You might not need polygonoffset, as I suspect the actual shader for the marks already has it.

No1_sonuk
9th September 2005, 23:36
Likely. It adds to r_speeds.
Hmm. I thought it might.
It seems like if you take nomarks out of a clip texture, it should have marks, but in actual fact it doesn't
Yeah, while researching I found someone saying that nodraw implicitly sets nomarks. D'OH!

I'll look into the code issue, but aren't the shaders interpreted by the engine code, not the game code?

SCDS_reyalP
10th September 2005, 00:03
Likely. It adds to r_speeds.
Hmm. I thought it might.
It seems like if you take nomarks out of a clip texture, it should have marks, but in actual fact it doesn't
Yeah, while researching I found someone saying that nodraw implicitly sets nomarks. D'OH!

Hmm, in that case perhaps it could be fixed in q3map. However, looking at the q3map2 surfaceparam table http://www.worldwidegaming.org/developer/reyalp/surfparm.html this doesn't seem to be the case. There could be a special hack somewhere else (either in the compiler or engine).


I'll look into the code issue, but aren't the shaders interpreted by the engine code, not the game code?
Shaders are, however the actual code to draw the marks in in gamecode. I assumed you could work around it there, but that may not be the case if the engine is implicitly setting it for you.

SCDS_reyalP
11th September 2005, 00:05
OK did some investigation. Marks are actually very clever. If you make a clip shader without nomarks, it will not draw marks standing by itself. However if it is near a drawing surface, the correct type of marks will be projected on that surface. :moo:

This cleverness happens in the engine, so is outside your control. If you truely want to have marks show up on a non-drawing shader, then you have to do what you suggested with a fully transparent blend. If you just want model clipping to show marks on the model, just make versions of the clip shader without nomarks, and it Just Works.

No1_sonuk
11th September 2005, 10:06
Thanks, I'll try that.
My problem now is that I have something wrong with the model. It works as a misc_model, but not as a misc_gamemodel. I'll look into it.

No1_sonuk
11th September 2005, 14:46
If you make a clip shader without nomarks, it will not draw marks standing by itself. However if it is near a drawing surface, the correct type of marks will be projected on that surface.

OK, I tried this and it doesn't work for me.

Here's what I used on the misc_model for clipping:textures/pop/pop_clipweapmetal2
{
qer_editorimage "textures/common/clip_metal.tga"
qer_trans 0.3

// surfaceparm clipmissile
surfaceparm metalsteps
surfaceparm nodraw
// surfaceparm playerclip
// surfaceparm trans
}
Those lines that are commented out make the model non-solid when they're in.

SCDS_reyalP
11th September 2005, 21:16
What I used was

textures/reyalp/clipweapmetalmark
{
qer_trans 0.3
qer_editorimage "textures/common/clip_metal.tga"
surfaceparm nodraw
surfaceparm trans
surfaceparm metalsteps
}

In editor
http://www.collectivecomputing.com/~reed/et/etss/clipweapmarks-2.jpg
Result:
http://www.collectivecomputing.com/~reed/et/etss/clipweapmarks-1.jpg

Note that this did NOT seem to work with a misc_gamemodel, and that the clip has to be fairly close to the model surface. It's not clear exactly how close...

No1_sonuk
11th September 2005, 22:33
Note that this did NOT seem to work with a misc_gamemodel
Ah, that explains it. Where you have a barrel, I'm using a misc_gamemodel. If we were using a misc_model, I'd have thought the marks would show anyway, as long as the model skin had the right surfaceparms in the shader. A misc_model I have without a shader shows a default mark when shot.
We're using misc_gamemodel because we need to use the LOD feature as we have a lot of them (Czech Hedgehogs on a beach map).

BTW, I fixed my earlier non-displaying misc_gamemodel problem - My floor was structural instead of detail. :banghead: Hey, I'm lead modeller, not a mapper. :D

SCDS_reyalP
11th September 2005, 23:38
A misc_model I have without a shader shows a default mark when shot.

Yes this seems to be the case. Even if you clip with a nomarks shader, the model will get bullet marks (so the shader I posted above is pointless). Note that you do have to clip with something, or the bullets go right through and there are no marks.

We're using misc_gamemodel because we need to use the LOD feature as we have a lot of them
Well, that brings you back to the non-drawing shader you posted at the start. However, if performance is a concern, it might be better just to leave the hedgehogs without marks. Or benchmark it both ways and see what happens.

The difference between misc_model and misc_gamemodel in this case seems to be in the engine, but it might be possible to hack around this in gamecode (whether it would be worth the effort is a different question).

You might want to test if the LOD from misc_gamemodels is actually gaining you anything. I would suggest making a box map with an insane number of hedgehogs, so you can clearly see the difference between various versions.

Then you can test:
misc_gamemodel vs misc_model
misc_gamemodel clipped with your non-drawing shader vs. clipped with normal clip

No1_sonuk
12th September 2005, 00:28
Hmm. Thanks. I'll make sure the mapper looks in here.
WRT LOD, I think it might make a difference considering the poly counts:

pop_hedgehog.md3 (262)
pop_hedgehog_1.md3 (118)
pop_hedgehog_2.md3 (24)

kamikazee
12th September 2005, 09:47
A misc_model I have without a shader shows a default mark when shot.

Yes this seems to be the case. Even if you clip with a nomarks shader, the model will get bullet marks (so the shader I posted above is pointless). Note that you do have to clip with something, or the bullets go right through and there are no marks.
I've seen this behaviour before, it has something to do with the ability of bullets to 'punch' trough thin brushes, leaving marks on the surfaces behind the brush that's hit for as long the bullet flies. You could show this with any shader, including caulk on a detail brush. (I once tried the last one)
Allso note it can be shown on corners, if you shoot from an angle to a corner it punches trough on the sides.

Loffy
12th September 2005, 11:38
Hi!
You guys seem to know it all.
I have a question that is of no importance, but I 've been thinking about it for long.
If I put a model in my map, it is non-solid. E.g. an oil-drum.
If I shot at the oil-drum, there will be no marks. I can walk thru it also.
BUT if I put a brush over it, i.e. clip weapon metal, there will be marks on the model!
How is this possible? The clip and the drum is not 100% perfecly aligned, yet the bullet holes are clearly (to me atleast) ON the model.
How can the model "know" that there is a clip brush over it, and that it should display the bullet holes?
Perplexing
//Loffy

kamikazee
12th September 2005, 13:01
I just said it as I think it is: the engine detects a hit on a surface.
The bullet 'punches trough' the brush a certain amount of units and the engine shows this by painting bulletmarks on all surfaces it encounters till it has traveled far enough. If I'm right, it would show marks 2 times if I'd put a transparant texture over it, gonna try it now.

Loffy
12th September 2005, 13:21
carmack magic once again...

kamikazee
12th September 2005, 14:13
Conclusions of my little test:
1) Photoshop CS 2 doesn't save complete black aplha channels (normally quite useless anyway)
2) Bulletmarks don't affect misc_gamemodel, misc_model does. (no new discovery, allready known)
3) Bulletmarks do get doubled if you put a trans shader in front of the misc_model and the distance between the surface is small enough. more then 10 units should be enough to avoid doubling of bulletmarks, from most weapons.
Seen from the front as I shot the barrel:
http://users.pandora.be/jtc/pictures/front_shot.jpg
Seen from the side when I took one step to the left:
http://users.pandora.be/jtc/pictures/side_shot.jpg

No1_sonuk
12th September 2005, 18:49
Err, please explain something to me?
If you're going to use misc_model anyway, why not use its solid spawnflag, and make an appropriate shader for its skin?
I know this works, because we're using it to make the clip models (with metallic bullet marks) around our misc_gamemodel hedgehogs.

SCDS_reyalP
12th September 2005, 20:01
Err, please explain something to me?
If you're going to use misc_model anyway, why not use its solid spawnflag, and make an appropriate shader for its skin?
I know this works, because we're using it to make the clip models (with metallic bullet marks) around our misc_gamemodel hedgehogs.
Unless your misc_model is very simply, the solid spawnflag creates really nasty brushwork.


How is this possible? The clip and the drum is not 100% perfecly aligned, yet the bullet holes are clearly (to me atleast) ON the model.


trap_R_ProjectDecal

The gamecode detects what surface it would hit, and then tells the engine to project the bullet mark on the nearest drawing surface.

No1_sonuk
12th September 2005, 20:45
Unless your misc_model is very simply, the solid spawnflag creates really nasty brushwork.
Sorry, but my question was "If you're going to use misc_model anyway, why not use its solid spawnflag, and make an appropriate shader for its skin?"
Solid or not, as a misc_model, surely it'll create the same brushwork?

SCDS_reyalP
12th September 2005, 21:23
No, unless a misc_model is solid, no brushwork exists for it.

No1_sonuk
12th September 2005, 22:02
So how is it drawn?

SCDS_reyalP
12th September 2005, 22:09
So how is it drawn?
With triangles, as specified by the surfaces lump. See http://graphics.stanford.edu/~kekoa/q3/ (that pages calls the surfaces lump faces)

Brushes are not used for drawing in the .bsp. They are only used for collision detection and various surface and content attributes.