Jump to content
  • Advertisement
Sign in to follow this  
Arcibald Wearlot

vertex shaders - oFog register, clamping

This topic is 5034 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Look at this piece of code from "dolphintween.vsh", a DXSDK example:
;------------------------------------------------------------------------------
; Fog calculation
;------------------------------------------------------------------------------

; compute fog factor f = (fog_end - dist)*(1/(fog_end-fog_start))
add r0.x, -r9.z, c23.y
mul r0.x, r0.x, c23.z
max r0.x, r0.x, c0.x       ; clamp fog to > 0.0
min oFog, r0.x, c1.x     ; clamp fog to < 1.0
They are clamping the value passed to oFog. Now read this text from the DX Documentation: "Fog Register - oFog The output fog value registers. [...] Values are clamped between zero and one before passing to the rasterizer." So there's no need to clamp the value between 0 and 1 because it is automatically done anyway! The example is wasting two instructions. And it's not the only one: dolphintween2.vsh, seafloor.vsh and seafloor2.vsh are doing the same thing. This sounds very strange to me, so, is there something I'm missing?

Share this post


Link to post
Share on other sites
Advertisement
Well they are just examples... they might do things explicitely just for illustrative purposes... or didn't want to rely on the fact that it gets clamped between 0 and 1 later in the pipeline.

Just another example of the DXSDK being a bad source for anything but reference ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!