Jump to content


Alpha Sorting.....


10 replies to this topic

#1 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 21 December 2004 - 10:25 AM

Hello all.....

i have a few question about sorting alpha-blended objects like leafs.

here a few pictures of my current project.

http://www.netpix.or...21/04/pic01.jpg
http://www.netpix.or...21/04/pic02.jpg
http://www.netpix.or...21/04/pic03.jpg

as you can see the trees looks abit broken.....
for rendering trees i do something like this atm:

loop for each tree
-render the trunk+branches with all the settings
-render all copys of the trunks+branches without changing stats. only the world-matrix

when all trees are rendered then i do the same loop for the leafs.
but here comes the problem....

the leafs are atm like in other games so i cant render the leafs with
z-buffer-write enable on. so i have to disable z-writes.
the leafs are atm not sorted so the effect is that leafs will overlapped or shown that are normaly hide.

i know one way to solve this problem but its ofcourse the way i dont want to go because it will bring alot of stats change depends on how many different leafes-textures are active in a frame.

my idea: ( just for the leafs. trunks and branches are ok atm. )

scan the actual scene for active leafs.
sort the leafs depends on its z-value.

as you can see this method is easy.
but normaly a scene have more than just one or two leaf-textures so this will end up in texture changes depends on how many different leafs are actual seen in a frame.

ofcourse the leafs can be pack into one big-texture to get ride of the texture-change !?

so i wonder how games like: Far-Cry handle this problem....

-Andy

#2 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 21 December 2004 - 01:19 PM

It looks to me like you answered your own questions in the post :) (except for the how does farcry do it one)

But going back to the issue. You should use alpha testing with leaves. Because the transparent parts are completely not seeable. No need to use alpha blending. Turn alpha testing on, enable zwrites, and problem solved (unless of course i missed something)

#3 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 21 December 2004 - 02:36 PM

bladder said:

It looks to me like you answered your own questions in the post :) (except for the how does farcry do it one)

But going back to the issue. You should use alpha testing with leaves. Because the transparent parts are completely not seeable. No need to use alpha blending. Turn alpha testing on, enable zwrites, and problem solved (unless of course i missed something)

 


ARRRRGGGGHHHH !!!! i feel so lame now.... hehe :angry:

thank you bladder..... damn i forget about this function..... :wub:

i think you mean something like this....

-----------------------------------------------------------------------------------
dev->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
dev->SetRenderState(D3DRS_ALPHAREF, (DWORD)0x00000001);
dev->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
dev->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
-----------------------------------------------------------------------------------

sorry for this LAME post !!! hehe


- Andy

#4 bladder

    DevMaster Staff

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 21 December 2004 - 03:05 PM

Dont worry about it. People have good days and bad days :)

And yeah, those calls seem about right.

#5 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 22 December 2004 - 10:15 AM

now it works like i wanted. thanks again bladder that tip was very good !

here are some pictures......

http://www.netpix.or...22/04/pic01.jpg
http://www.netpix.or...22/04/pic02.jpg
http://www.netpix.or...22/04/pic03.jpg
http://www.netpix.or...22/04/pic04.jpg
http://www.netpix.or...22/04/pic05.jpg

dont wonder about the shadow of the trees. i just started it yesterday evening.
its just the diffuse part of the shadow and it will be combined with a texture that looks like the leafs to get better visual results.

thanks again.... this saved me alot of time !!!!

ps: reflection of the trees will be add soon. iam still working on the lod system so this is because there are no reflection atm.

- Andy

#6 NomadRock

    Senior Member

  • Members
  • PipPipPipPip
  • 785 posts

Posted 22 December 2004 - 06:39 PM

Looking good!
Jesse Coyle

#7 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 22 December 2004 - 08:15 PM

thanks !!
i hope to provide more pictures soon....

- Andy

#8 Dia

    DevMaster Staff

  • Administrators
  • 1120 posts

Posted 22 December 2004 - 09:16 PM

You could also use the Development Snapshot feature to talk about it and about the techniques used :)

#9 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 23 December 2004 - 07:49 AM

Dia Kharrat said:

You could also use the Development Snapshot feature to talk about it and about the techniques used :)

 


ok, i will do it next time. when i have make more progress and added a few more features then i will post it there. :)

i also planing to release the c# code ( project files ) for this. so every body that is new to mdx/c# could look some basic stuff up from the code.

- Andy

#10 soconne

    New Member

  • Members
  • PipPip
  • 21 posts

Posted 24 December 2004 - 08:12 PM

How are you loading the textures for the trees? You should try loading them as mipmaps, because as they get further away, it will not look so pixellated.

#11 SYS49152

    Member

  • Members
  • PipPip
  • 57 posts

Posted 27 December 2004 - 01:21 PM

soconne said:

How are you loading the textures for the trees? You should try loading them as mipmaps, because as they get further away, it will not look so pixellated.

 


since this topic is still up i will quick answer . i have use mip-maps. ofcourse its the jpg compression thats looks abit washy.

- Andy





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users