Any way to access DX blending modes & z-buffer?

Blitz3D Forums/Blitz3D Programming/Any way to access DX blending modes & z-buffer?

Roland(Posted 2011) [#1]
Hi, I'm wondering if there is any way to access the directx rendering options to control blending modes, zfunc comparisons (for writing to the zbuffer) and subsequently if it's possible to have an object only write to the zbuffer rather than to the screen.

Anyone ever work on anything like that here? The end result I'm looking for is to be able to have an object mask another object by having its zfunc comparison set to less-equal, and have it only write to the zbuffer, so that it doesn't show up on screen. Clear as mud, I'm sure. I'm certain that this is possible in other environments, but I can't get it to work with Blitz's native commands so far (entityorder, entityfx, etc.)

thanks,
roland


Rroff(Posted 2011) [#2]
z-buffer manipulation in B3D is notoriously difficult, theres a couple of dlls that supposedly give such features but last time I checked they were long ago abandoned by their developers and gave unpredictable results with modern PCs/OS.

The excellent FastExt library gives quite a bit of access to DX blend modes and some other advanced rendering options that might be of use to you however.


MCP(Posted 2011) [#3]
Multi-pass rendering trickery might produce the results that you're after and is quite possible in Blitz3D. Have a look at this code archives example I knocked up a few years ago...

http://www.blitzbasic.com/codearcs/codearcs.php?code=1770

It might give you an idea how to achieve the effect your looking for.


Kryzon(Posted 2011) [#4]
It's hard to hack RenderStates into B3D because once you call RenderWorld() it sets up its own states (and might overwrite the ones you changed).

There's the CameraCLSMode function which would at least allow you to preserve the Z-Buffer when rendering your mask objects so the next ones would be discarded.

Also, since you're using Blitz3D seriously, you might find these things useful:
- BlitzMirror
- DX7-Libs_for_Blitz3D.zip
- Devil's Child's Stuff


Roland(Posted 2011) [#5]
hey guys,

some great stuff here. The FastExt & FastImage libraries might work -- there's a very minimally documented function in FastImage that looks like it might expose control of renderstates. (SetCustomState%). Anyone have any experience with this? I'd need to be able to use the ZBufferWriteEnable and ZFunc renderstates for it to be of any value to me : http://www.toymaker.info/Games/html/render_states.html

MCP -- you're absolutely right -- multipass rendering works (and I did test it out as an option), but it's unfortunately too slow for this use case. I'd need a minimum of 6 rendering passes, and unlike a blur effect, this masking effect needs to be very crisp.

Thanks for the help guys. The B3d community never ceases to amaze. I'm becoming convinced we're still going to be coding in B3d (and loving it) when the rest of the world is using the holodeck. After 2 years of coding for the wii, coming back to blitz is like going back home for the holidays.


Rroff(Posted 2011) [#6]
The z-buffer stuff should be in the DX7 dlls Kryzon linked to, I seem to remember dx7sshad.dll providing these functions in a shadow demo but I can't remember where that came from.

Word of warning with regards to the devils shadow system - in some cases it breaks multi texturing and if your working on a commercial program I believe you potentially may have some legal issues as some of the techniques used overlap with patents held by Creative Labs.

Last edited 2011


Roland(Posted 2011) [#7]
Hey Rroff, you're right -- the zbuffer, zfunc, zwriteenabled, etc., are all in the dx7 lib. But I guess I don't know how to take advantage of them in blitz. Seems like you'd need to write directly to the buffers after changing those settings (like fastimage does), right?

What I'd love would be a way to have those settings affect a blitz3d material / entity, within the context of the regular RenderWorld calls. Is that possible?