Sign in to follow this  

vertex shaders - oFog register, clamping

This topic is 4819 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
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

This topic is 4819 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this