• Advertisement
Sign in to follow this  

HDR and fp special woes..

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

Hi, i've implemented HDR rendering for a game i'm working on (DX9 app). The inplementation uses fp16 render targets (D3DFMT_A16B16G16R16F), and the card i'm running it on is a GF6 6600GT. My problem is that some my meshes have a few black polys in them when rendered. I'm using normalmapping, and have created the tangent-space-basis with nvdias nvmeshmender. I have two separate renderpaths, one for SM2.0, and one with SM3.0 featuring the HDR rendering. The black polys only appear when doing the SM3.0 HDR rendering. The polys also appear to be infinately black, because they recieve no lighting at all, and can be seen through other alpha blended objects, still being completely black, even though the blend is additive (GF6 can do fp alphablend). This is why i believe that somewhere something is generating an floating point special (negative infinity). I've read nvidias paper on fp specials but it didn't help me much. The main problem is that i can't figure out where it is generated. Is it meshmender that somehow produces basis vectors that generates the special when used in the lighting? Is it a calculation in the shader? Has anyone else encountered this? Any suggestions would be greatly appreciated :) Oh, btw, i've tried switching to full 32-bit fp textures, but the problem remains.. :( /Simon

Share this post


Link to post
Share on other sites
Advertisement
I've encountered similar problem before. My problem was like the yours, but white instead of black. The problem was in division by zero, which occasionally occured in vertex shader IIRC. According to the paper you mentioned, the two cases are almost identical(you get +Inf if you divide a positive number by zero and -Inf if you divide negative number by 0). So your problem may lie there. I remember that the problem in my shader was arising in the computation of attenuation.
Maybe this helps you?

Share this post


Link to post
Share on other sites
I got one of these whilst messing with my HDRPipeline demo in the DX SDK... I seem to remember I corrected them by adding a small bias before taking a log() or division:

float f = x / (y + 1e-5);

instead of:

float f = x / y;

hth
Jack

Share this post


Link to post
Share on other sites
I've seen it happen due to tiny polygons throwing off the tangent basis calculation, etc.

Share this post


Link to post
Share on other sites
Thanks alot for your replies. I don't have any explicit divisions in my shader code, but your examples got me thinking about the HLSL intrisic functions such as normalize(), lerp() and reflect(), as they may perform a division internally. I'll look into it :)

Thanks also for the mentioning of the small triangles, i'll check the tsb-generation code for errors. Perhaps it generates null-vectors (or similar crap) that becomes fp-specials in the HLSL-functions.

/Simon

Share this post


Link to post
Share on other sites
Just to clarify, by "tiny", I mean "skinny" => i.e. two edges of the triangle are almost parallel.

Share this post


Link to post
Share on other sites
Ok, I found out what was causing it: it wasn't fp-specials in the shader, it was mesh mender generating tangents/binormals with NAN-floats in them :P

I checked the documentation for mesh mender, and in their code example they have the following pseudo-code:

if( wv.tangent == ZeroVector )
{
wv.tangent = XAxis;
}
if( wv.binormal == ZeroVector )
{
wv.binormal = ZAxis;
}

..i modified the code to include a check for NAN-vectors (as well as a zero vector), and now it works perfectly. I don't fully understand why, though, as just arbitrarily selecting an axis (X or Z) should produce weird lighing on the triangles that were previously black.

...but it seems to work, so i'm going with it for the time being ;)

Thanks for your help anyway, it's probably saved me from alot of future headache, since I'm sure I might run into one of the cases you mentioned sooner or later and then I'll know what the problem is ;)

/Simon

Share this post


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

  • Advertisement