blendFunc blend surfaces and z-indexing

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

blendFunc blend surfaces and z-indexing

Post by Eraser »

I've got a problem with two brushes that are textures with nodraw, but a single surface is textured with a TGA texture that has a shader that applies a blendFunc blend on it. These two brushes are positioned behind each other. However, for some reason, the texture of the brush that is farthest away to the player is rendered on top of the other, which obviously is not what I want. The goal is to create 2D grass with a 2D tree behind it.

Is there a solution to this problem or is it something I'm going to have to work around?
dONKEY
Posts: 566
Joined: Mon Oct 15, 2001 7:00 am

Re: blendFunc blend surfaces and z-indexing

Post by dONKEY »

That's 'sort' *value*, right?
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: blendFunc blend surfaces and z-indexing

Post by Eraser »

ahhh yes thanks, that works
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: blendFunc blend surfaces and z-indexing

Post by KittenIgnition »

Sort won't really work for every scenario though, will it? As soon as you switch the positions of the two sorted items, the reverse problem will occur. As well, if you have a bunch of surfaces with the same shader on them, they will overlap each-other in odd ways (for example, leaf blocks in Minecraft maps).

One solution is to not use blendFunc, but instead alphaFunc GE128, which will turn all the pixels into on/off, so semi-transparent pixels don't work here. Another way that seems to work for me is to use depthWrite, but it can cause other conflicts in other situations.

Maybe sort does solve these problems somehow, but it's never worked properly for me, and I don't know why.
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: blendFunc blend surfaces and z-indexing

Post by Eraser »

I have the advantage the brushes are always viewed from the same angle, so their physical ordering is always the same.
obsidian
Posts: 10970
Joined: Mon Feb 04, 2002 8:00 am

Re: blendFunc blend surfaces and z-indexing

Post by obsidian »

If it's for a sprite or grate, etc. you probably want do to depth testing...

http://q3map2.robotrenegade.com/docs/sh ... #depthFunc

Check out some stock Q3 shaders for examples.
[size=85][url=http://gtkradiant.com]GtkRadiant[/url] | [url=http://q3map2.robotrenegade.com]Q3Map2[/url] | [url=http://q3map2.robotrenegade.com/docs/shader_manual/]Shader Manual[/url][/size]
Post Reply