how masked alpha0 texels are processed during 3d rendering ? is it a problem if

Started by RemiD, December 14, 2024, 21:38:43

Previous topic - Next topic

RemiD

hi :),

a question to some of you who may be more knowledgeable about 3d rendering, of surface and vertices and triangles and texture and texels.

how masked alpha0 texels are processed during 3d rendering ? is it a problem if there are many 'unused' masked alpha0 texels on a texture ? will this impact the rendering time a lot ?

an example may be to have flat rectangles meshes with texels used to represent grass or leaves or small branches.

from experience i would say no, it is faster to render flat recangles meshes with some colored texels and many masked alpha0 texels, than to render the equivalent shape made of many vertices and many triangles.

your thoughts ?

thanks,

(i am not talking about partially opaque, partially transparent (alpha 0.1-0.9) texels, but about totally transparent (alpha0) texels)

Matty

If you're using Blitz3d on modern hardware then framerate is mainly affected by triangle count and bone count. Texturing and fillrate issues such as with alpha and masked textures are rarely a problem with modern hardware for stuff done with Blitz3d. In the old days it was a problem, not as much as it used to be.

Grass using meshes looks much better than grass using billboards. Eg polygon clumps of grass look better than a simple textured quad. You can use both - polygonal grass meshes for grass up close, and billboard/quads for grass at a distance. If you group the grass meshes into clumps based on small positional areas on the map then it will be faster again.

RemiD

Quote from: Matty on December 15, 2024, 07:29:32Texturing and fillrate issues such as with alpha and masked textures are rarely a problem with modern hardware for stuff done with Blitz3d.
from what i remember, there is a great difference between rendering masked alpha (0) texels, and rendering partialy alpha (between 1 and 254) texels. because the second way requires to mix the color of the pixels (of the screen) of the texels area with the color of the pixels (of the screen) of the things behind these texels.

and there may also be some z-ordering issue.

so masked alpha0 is better when possible.


i am experimenting to model a 3d tree, with a trunc made with a 3d shape, but the big branches and the small branches and the leaves made with rectangle shapes and texels.
and there will be some fully opaque alpha255 texels, but also many masked fully transparent alpha0 texels.
but there will be much less vertices and triangles than if i would model all the details with 3d shapes.

angros47

The answer to your question is complex, because it depends on how the alpha channel is processed by the GPU shader. In general, if the shader is supposed to implement alpha masking, when the alpha channel has a low value the command "discard" is executed, stopping any further processing for that specific fragment. So, performance depends on where that check is placed inside the shader: if you are using a heavy computation of per-pixel lighting, and check the alpha masking before that, it will save time (avoiding to compute the lighting of pixel that are not shown anyway), if you perform the same checking after the computation of lighting there will be zero performance gain.

If you are using Blitz3D or any other software that expects fixed function pipeline, since fixed function is emulated by shaders provided by the graphic driver, it will depend on how alpha masking is implemented in those drivers (it is vendor specific, so there is no universal answer)

The "discard" command must be used, in alpha masking, because if you don't, and you only rely on the alpha channel, the masked pixels won't be visible (they will be transparent), but they will still be rendered in the depth buffer, creating unpleasant artifacts if other surfaces are rendered afterward (I discovered that issue while attempting to render a 3d tree, too)

RemiD

Quote from: angros47 on December 15, 2024, 16:05:53since fixed function is emulated by shaders provided by the graphic driver, it will depend on how alpha masking is implemented in those drivers (it is vendor specific, so there is no universal answer)
oh ???
ok...

RemiD

experimenting...

trunc with a 3d shape ( cylinder8 ) with one color
branches with rectangles meshes + colored texels + masked texels

at left, with directx lighting (a in the sky directlight + ambientlight)
at right, with full bright