ioquake / ioq3

The ioquake3 community effort to continue supporting/developing id's Quake III Arena
https://ioquake3.org/
GNU General Public License v2.0
2.39k stars 529 forks source link

OpenGL2: shaders, blendFunc, alpha channel #317

Closed Tasijjj closed 7 years ago

Tasijjj commented 7 years ago

bush_problem

Hello, is anybody familiar with the kind of "bug" shown on the picture? Although, the smaller bush plant is clearly further away from the player than the bigger one, the texture of the distant bush plant has somehow priority over the texture of the closer one.

The shader code I'm using:

texturepath/texturename { cull none { map texturepath/texturename.tga blendFunc blend } }

Am I missing something in the shader?

Any kind of help would be appreciated.

zturtleman commented 7 years ago

Quake 3 doesn't preform distance sorting for blended surfaces. Consider replacing the blendFunc with an alpha mask (alphaFunc GE128) and depthWrite. Also see the discussion by Hipshot, sock, and obsidian for alpha masked grass with correct view order and a soft edge (textures/moteof/grass01d_indoor) here.

Tasijjj commented 7 years ago

Thank you for that clear and fast answer.

While waiting for the response, we found out, that UrbanTerror uses alphaFunc 128 and depthWrite in its shaders for textures with alpha channel, so we used that as well.

Nevertheless, a confirmation, that something doesn't exist in the code, is always very helpful.