• Advertisement
Sign in to follow this  

Question about fog

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

i just deal with fog in managed directx 9 and found the following note in the dx sdk doku: Note: The system stores the fog factor in the alpha component of the specular color for a vertex. in my applications none of my vertices have a specular color (the Vertex Format dont have the element VertexFormats.Specular) but the fog is calculated the right way. so i just want to know why fogging works, even if u dont specify a specular color in your vertex format. thanks

Share this post


Link to post
Share on other sites
Advertisement

The vertex format you specify is the input for vertex processing, the output often has very different components.

For example the input vertices for a skinned and vertex lit character model might have a Normal (for lighting), and Bone Weights (for skinning). The vertex shader (or fixed function vertex processing) then takes those components and computes lighting and skinning - the outputs of that shader (or the FFP) usually *would not* include the normal or bone weights, but *would* have a diffuse colour (the result of the lighting) and an RHW component in the position.

With the fixed function pipeline, the output vertex format is implicit - D3D outputs whatever is required by the current render states (e.g. with D3DRS_LIGHTING=TRUE it knows to output a diffuse colour if the vertex doesn't already have one).


Many graphics chips have special dedicated hardware just for the specular add and the application of fog; sometimes specular shares stuff on the chip with fog (in which case the two are intertwined and setting one might do things to the other inside the driver), sometimes it doesn't.

If you enable fog, even if your [input] vertex format doesn't contain a specular colour, and D3DRS_SPECULARENABLE=FALSE, D3D will automatically output whatever is required for fog - whether a complete specular colour (which isn't applied unless D3DRS_SPECULARENABLE=TRUE) or a separate component dedicated to fog.

Share this post


Link to post
Share on other sites
thanks for your great explanation S1CA. i didnt know that the output vertex format can differ from the input format. but of course this make sense.

Share this post


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

  • Advertisement