Page 1 of 1
blendFunc blend surfaces and z-indexing
Posted: Sat Jun 27, 2015 1:32 pm
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?
Re: blendFunc blend surfaces and z-indexing
Posted: Sat Jun 27, 2015 1:37 pm
by dONKEY
That's 'sort' *value*, right?
Re: blendFunc blend surfaces and z-indexing
Posted: Sat Jun 27, 2015 2:10 pm
by Eraser
ahhh yes thanks, that works
Re: blendFunc blend surfaces and z-indexing
Posted: Sat Jun 27, 2015 7:44 pm
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.
Re: blendFunc blend surfaces and z-indexing
Posted: Sun Jun 28, 2015 8:28 am
by Eraser
I have the advantage the brushes are always viewed from the same angle, so their physical ordering is always the same.
Re: blendFunc blend surfaces and z-indexing
Posted: Mon Jun 29, 2015 4:59 pm
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.