Horde3D

Next-Generation Graphics Engine
It is currently 27.04.2024, 12:51

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 20.05.2010, 12:57 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
I just noticed (reading the GL Spec), that the current way Horde handles the Shader's ZFunc is causing issues for us.
In a shader I set states to:
Code:
ZWriteEnable = true;
ZFunc = Always;
Maybe not a common use-case but this should be valid, I think.
Unfortunately Horde does a short cut and when seeing ZFunc=Always, it disables the depth test, and this disables updates to the depth buffer.
According to the spec:
Quote:
4.1.6 Depth Buffer Test
The depth buffer test discards the incoming fragment if a depth comparison fails. The comparison is enabled or disabled with the generic Enable and Disable commands using the symbolic constant DEPTH TEST. When disabled, the depth comparison and subsequent possible updates to the depth buffer value are bypassed and the fragment is passed to the next operation
Of course disabling the depth test and hence not writing to the depth buffer is an optimization, so maybe we a ZFunc=None could replace the current Always and disable the test, while "ZFunc=Always" uses glDepthFunc(GL_ALWAYS).
Any suggestions?


Top
 Profile  
Reply with quote  
PostPosted: 22.05.2010, 10:28 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Thanks Alex, the current behavior of ZFunc=Always is clearly wrong in combination with depth writes, so we need to fix it. Yeah, we could either introduce ZFunc=None (not to confuse with ZFunc=Never) or do it as in CgFX by introducing a ZEnable state. The latter would probably be less confusing.


Top
 Profile  
Reply with quote  
PostPosted: 31.05.2010, 09:57 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
Hi marciano.
Thanks for submitting the change to the SVN, works perfectly.
BTW: do you have a good advice for color buffer write selection, FX-like ColorWriteEnable = Red|Green|Blue or separate booleans like ColorRedWriteEnable = false;
Thanks again!
Alex


Top
 Profile  
Reply with quote  
PostPosted: 03.06.2010, 18:34 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
I think it makes sense to add a single ColorWriteEnable or ColorWriteMask. To simplify the parsing, I would suggest to specify the bit mask as a single "word", like RGBA or RGB or RGA etc.


Top
 Profile  
Reply with quote  
PostPosted: 03.06.2010, 22:19 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
Yep, sounds fine. having to check only for the presence of a char like 'A' is indeed quite simple and easy to add to the existent parser (ignoring error checking for things like "AAA" or whatever)
BTW: In our code base we also added a BlendMode "BlendPMA" to enable premultiplied alpha blend state (GL_ONE, GL_ONE_MINUS_SRC_ALPHA), because we didn't come up with a better name and writing PremultipliedAlpha in all shader contexts was too error-prone :D


Top
 Profile  
Reply with quote  
PostPosted: 17.06.2010, 09:43 
Offline

Joined: 23.06.2008, 10:23
Posts: 21
Location: Sweden
AlexL wrote:
BTW: In our code base we also added a BlendMode "BlendPMA" to enable premultiplied alpha blend state (GL_ONE, GL_ONE_MINUS_SRC_ALPHA), because we didn't come up with a better name and writing PremultipliedAlpha in all shader contexts was too error-prone :D

That would be a very useful feature, though I would probably call it PremultipliedAlpha rather than PMA.
For anyone not familiar with premultiplied alpha you can read an article about it here.


Top
 Profile  
Reply with quote  
PostPosted: 17.06.2010, 11:50 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
Would it be possible to be able to manually configure blend modes for materials? BlendMode=Custom could be used to enable this so the current convenience of the "popular" modes isn't lost.

It would be very useful to manually configure the Blend Coefficients for SrcRGB, DstRGB, SrcAlpha, DstAlpha and the blend Operation.

For example, if you're doing multi-layerd compositing with PMA (e.g. rendering particles to a seperate buffer), you'll want to use a different blend mode for RGB than you will for Alpha.
Other less-common modes like "Subtractive" also come in handy occasionally, and it would be nice to be able to use them without modifying Horde's source code.


Top
 Profile  
Reply with quote  
PostPosted: 26.06.2010, 18:12 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
DarkAngel wrote:
Would it be possible to be able to manually configure blend modes for materials? BlendMode=Custom could be used to enable this so the current convenience of the "popular" modes isn't lost.

It would be very useful to manually configure the Blend Coefficients for SrcRGB, DstRGB, SrcAlpha, DstAlpha and the blend Operation.

This is a good point. As the public API does not expose any internal render states, it makes sense to make as many of them as possible available via the FX files. This also fits Horde's data-driven approach nicely.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group