Making Flares (D3D)

Started by
17 comments, last by ImNotTheOne 23 years, 9 months ago
Huh, when did Microsoft decide to remove that one? I guess you could still query for one of the older interfaces that still supports it.
Advertisement
I think my solution is a little similar to Witchlords.

Draw your normal objects first. After that, you draw a point. Check if it is visible using the d3drenderstate LASTPIXEL (or something) and checking if the point is the same color as the point you set. Also remember to turn off fog when doing this.

Is that clear?

------------------------
Captured Reality
nes8bit:
D3DRENDERSTATE_LASTPIXEL
FALSE to enable drawing the last pixel in a line or triangle. The default value is TRUE.
There is no spoon.
I think that Shinkage and WhichLord are both right.

The simplest way to test for a point''s visibility is probably to let D3D do it for you with a call to ComputeSphereVisibility using a sphere with a very small radius (or 0 if it will work, but it may not). A return value of D3DSTATUS_ZNOTVISIBLE will indicate if the point is in the view frustum but not visible due to Z Buffer checking.

Whichlord is correct that the D3DRENDERSTATE_ZVISIBLE (which is a renderstate) is no longer supported, but that''s not the same as D3DSTATUS_ZNOTVISIBLE (which is a return code from ComputeSphereVisibility).

The only (very minor) drawback that I see to this method is that the entire ComputeSphereVisibility call appears to have been removed in DX8.

...Syzygy
Why I said it wont work because of D3DRENDERSTATE_ZVISIBLE is because it needs to be set if D3DSTATUS_ZNOTVISIBLE is to work. It says so in the docs.

And Shinkage, I''m not sure if D3DRENDERSTATE_ZVISIBLE was ever supported by the hardware. That is the reason Microsoft removed the support for it in DX (I think).



- WitchLord

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

My mistake.
I didn't realize that there was such a difference between "z test" (D3DRENDERSTATE_ZENABLE) and "z-checking" (D3DRENDERSTATE_ZVISIBLE). It's unclear to my why this feature using simple depth buffering, but I made a little test program and WitchLord is absolutely right -- D3DSTATUS_ZNOTVISIBLE is never returned.

Edited by - syzygy on July 14, 2000 3:45:32 AM
quote:Original post by ImNotTheOne

nes8bit:
D3DRENDERSTATE_LASTPIXEL
FALSE to enable drawing the last pixel in a line or triangle. The default value is TRUE.


* nes8bit slaps forehead
See kids...this is why you research before you reply

------------------------
Captured Reality
As it is said, it''s nearly impossible to use direct Z-BUFFER values to compare them with C++ operators. But let then use D3D doing this with its Z-test functions.
Formats make us impossible to say if it is less or greater, but we can say if a value is DIFFERENT from another ( according to bit depth ).
There is GodLife algorihtm, with modifications :


Psuedocode:

IsFlareVisible() {
...Transform ''flare point''
...Lock Z Buffer
...Get Z buffer value from transformed flare point''s x,y
...Unlock the Z buffer
...Render the flare center as a completely transparent vertex
...Lock Z Buffer
...Get the Z buffer value from the transformed flare point''s x,y
(...Unlock the Z buffer)
...If the rendered point is DIFFERENT FROM the previous value, THEN D3D DOESN''T HAS FOUND A PIXEL BETWEEN THE FLARE AND THE VIEWER, AND YOU render the flare ( DON''T FORGET TO RESTORE OLD Z-VALUE ); IF THE Z-VALUE IS NOT ALTERED BY OLD VALUE, THERE IS SOMETHING BEFORE THE FLARE, STOP HERE.
}


-- Goodlife + TETRONICS

Just a problem : if the flare is on a previously rendered polygon...

( One good demo to see flares ? Unreal Tournament Demo ! )
OUPS ! A SMALL ERROR :
"IF THE Z-VALUE IS NOT ALTERED BY ''NEW'' VALUE".

This topic is closed to new replies.

Advertisement