PDA

View Full Version : Demo Dynamic Branching per PS2.0!


Thunder82
02-07-2004, 12:18
http://esprit.campus.luth.se/~humus/3D/dynamicbranching_large.jpg



One of the main features of pixel shader 3.0 is that is supports dynamic branching (also called data dependent branching), something that nVidia of course makes a big deal about. This demo however shows a way to implement dynamic branching without pixel shader 3.0, using basic graphics functionality such as alpha testing and stencil testing. Not only is it doable, but also gives every bit of the performance of real dynamic branching.
One scenario where dynamic branching comes in handy is when you have range-limited lights. Whenever a fragment is outside the range of the light, you can skip all the lighting math and just return zero immediately. With pixel shader 3.0 you'd simply implement this with an if-statement. Without pixel shader 3.0, you just move this check to another shader. This shader returns a truth value to alpha. The alpha test then kills all unlit fragments. Surviving fragments will write 1 to stencil. In the next pass you simply draw lighting as usual. The stencil test will remove any fragments that aren't tagged as lit. If the hardware performs the stencil test prior to shading you will save a lot of shading power. In fact, the shading workload is reduced to the same level of pixel shader 3.0, or in some cases even slightly below since the alpha test can do a compare that otherwise would have to be performed in the shader.
The result is that early-out speeds things up considerably. In this demo the speed-up is generally in the range of two to four times as fast than without early-out. And with more complex lighting, the gain would have been even larger.

This demo should run on Radeon 9500 and up, and GeForce FX 5200 and up.

--------------------------------------------------------------------------------
Required Direct3D capabilities:

Pixel shader 2.0
Vertex shader 1.1

http://esprit.campus.luth.se/~humus/3D/index.php

DOWNLOAD DEMO
http://esprit.campus.luth.se/~humus/3D/DynamicBranching.zip





Praticamente il dynamic branching coi ps2.0 richiede meno potenza dagli shader che coi ps3.0 perchè il controllo se la luce è visibile o non non viene fatto con uno shader... :D

MaBru
02-07-2004, 12:50
http://forum.hwupgrade.it/showthread.php?s=&threadid=718904

Thunder82
02-07-2004, 12:56
Originariamente inviato da MaBru
http://forum.hwupgrade.it/showthread.php?s=&threadid=718904

non me n'ero accorto :( :cry:

Maury
02-07-2004, 13:00
Originariamente inviato da Thunder82
non me n'ero accorto :( :cry:

:spam: :banned: :p

andreamarra
02-07-2004, 17:17
Originariamente inviato da Maury
:spam: :banned: :p

E tu subito che ne approfitti per fare un bel pò di sano spaMm :O





:asd: :D :)

seccio
02-07-2004, 18:18
maury sta faccina mi spezza dal ridere!! http://www.vocinelweb.it/faccine/confuse/83.gif

:D :D :D :sofico: