Darkplaces transparent tga skin reverses draw order?

Discuss anything not covered by any of the other categories.
lth
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Darkplaces transparent tga skin reverses draw order?

Post by lth »

Hello,

I'm pretty sure I encountered this issue a couple of years ago but can't remember (or successfully search for) the answer. Basically, if I create a .mdl and add a .tga skinfile for it that has an alpha channel, Darkplaces draws the model in reverse order.

Does anyone know a way to stop this happening?

Cheers!

LTH
Feared
Posts: 95
Joined: Fri Jun 11, 2010 11:58 pm
Location: Wylie, TX

Re: Darkplaces transparent tga skin reverses draw order?

Post by Feared »

What are you using to save the .tga file?
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

It sounds like DP is disabling depth writes for models with alpha textures. So the skin is drawing in the order the triangles were given in the model (not exactly reverse order, more like effectively undefined).

If possible you could use a shader with alphatest. But if your texture includes translucent spots (not just opaque/transparent), that won't help.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
lth
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Post by lth »

I'm using the GIMP for my tgas, and yes, Sajt, I have translucent spots on them; in fact, it's only when there are translucent spots that this problem manifests.

Alternatively, is there any other way to get a translucent skin on my model that'll work in Darkplaces?
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Post by revelator »

hmm the old topside down tga bug or something else ?

later was fixed in newer tga code atleast i havent seen it for a long time but it kinda stomps me to hear about it from dp Oo.
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

No, he's not talking about that... (though I've never heard of that problem in a Quake engine)
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Post by revelator »

ah on alpha masked textures sorry was quite late when i wrote :oops:

but aye newer seen that particular bug before.

hmm might be a bug with gimp.
lth
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Post by lth »

So has anyone seen translucent TGAs working in Darkplaces at all before? Citation? Then I can compare what they're doing and see what I'm doing wrong. Anyone recommend an app that will save targas that's not the GIMP? (And free!)
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Post by revelator »

hmm can use xnview allbeit not as powerfull as the gimp it does support allmost any imageformat.

http://www.xnview.com/en/index.html

dont skip the gimp completely just export the image to another format
then use xnview to convert it to whatever you need :)
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

I'm 100% sure the image itself is fine, it's just that depth writes are disabled for translucent textures. I poked LordHavoc but he seems to be dormant.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
andrewj
Posts: 133
Joined: Mon Aug 30, 2010 3:29 pm
Location: Australia

Post by andrewj »

Darkplaces seems to have a codepath for handling transparent skins, i.e. R_ProcessTransparentTextureSurfaceList() and R_MeshQueue_RenderTransparent().

But who knows what is really wrong, I certainly can't follow LordHavoc's code very well :lol:
MichaelSteve
Posts: 4
Joined: Tue Mar 16, 2010 9:49 am

Post by MichaelSteve »

lth, did you have any luck with this issue? I'm currently encountering the same problem.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Post by Spike »

when a model is drawn, the entire mesh is drawn at once.
If you want to ensure that certain polys are drawn after others, you can use a multi-surface model format. anything that supports more than one texture. Use the second texture for any such transparent polys.

Some modeling programs may provide some feature to reorder such polys within the original mesh, but certain engines may attempt to optimise your model into triangle fans/strips still, which would pseudorandomize the order again.

Or use a shader and set up alpha testing instead of alpha blending.
lth
Posts: 144
Joined: Thu Nov 11, 2004 1:15 pm

Post by lth »

I got no further - tried a few different things including having only 0 or 1 for alpha values of parts of the skin, tried a few different dp rendering flags (like additive) but no joy.
Sajt
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Post by Sajt »

Well you have to explicitly enable alphatesting, which involves using a q3-style shader. I had to do this once, I just did what LH told me to. I don't know anything about these shaders.

scripts/filename_doesnt_matter.shader:

Code: Select all

progs/bones.mdl_0
{
	cull disable
	{
		map progs/bones.tga
		alphafunc GE128
		rgbGen vertex
	}
}
"progs/bones.mdl_0" is the skin name (minus the .tga extension).

Hope this works for you.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Post Reply