Ugly specular rings...

I tried to do a simple-simple per-pixel phong lighting(via a fragment program).
Well, I’m using the classic Blinn formula

c = N.L + (V.H)^s

I did this schema to a sphere. It worked just right, but I get some ugly rings around my specular. It is very well seen if s is not very large(about 10 - 3), resulting in a large specular highlight. I thought it could be the precision, but i’m quie shure I was doing 32 floats(FX5600).

If i draw only diffuse, or only specular components, the output is very good(clear gradient). But adding them together result somehow in brighter area at specular highlight line.

I would like to post some images, but unfortunatly I haven’tr got any website…

Thanks…

Hi !

It’s hard to help without screenshots, but from what you said, have you checked that all your vectors are normalized (N of course, but also EyeToObj, LightToObj and HalfAngle ?) Maybe also your problem could come from sign problem you should clamp both diffuse and specular to zero : those terms should never be negative.

g0b

Everything normalized per-fragment, all DP3 saturated etc, but I still get this funny effect. It really looks like a precision issue(this ugly interpolation color strips). I should test it with another driver…

Hi ,
ive had similar problems when doing lighting calculations with the fx series . The reason turned out to be the cubemap normalization which seems to be limited in precision , changing to a pure math implementation helped , increasing the size of the normalization cubemap did not . So i guess this is a general problem of the precision in which a cubemap lookup is done ( gf1 - 3 seem to have the same problem , but there it doesnt matter since everything is imprecise ) or i`m just too silly to construct a normalization cubemap

Well, your vectors are being encoded in 24 bits, so obviously you’re going to get some banding.

is it one ring per specular? then its actually from the colourclamping… as with specular you get values bigger than 1 wich get clamped. the region where one part of the colour gets bigger than one gets visible as a ring.

oh, and, you can post your images onto my webspace on davepermen.net just click on free and upload there and link to here

I wouldn’t be surprised if the driver is forcing 16bit floats for you …

As previously stated, it’s difficult to give you any concrete advice without pictures.

What I can say is that the ring your describing could just be a result of mach banding, which you can never completely get rid of. To check whether there is a problem with you per-pixel lighting you can crank up the tesselation and see if you get the same ‘ring’ using standard OpenGL lighting.

Also, make sure your using fp30 (“float”) in your fragment shader. I doubt that the driver is automagically changing your precision to fp16.

I am just about to rewrite it… Thanks for space, dave

Zengar

[This message has been edited by Zengar (edited 09-19-2003).]

Well…

  1. It isn’t a driver issue. I’ve tested it with 51.75 and 44.03 - same picture, same quality and 300% performance difference.

  2. I found out that one can load fp32 fragment programs with ARB_fragment_program! It’s quite cool - it would be nice if one will make it to documented feature - this reduces amount of work for vendor-specific optimisation.

  3. I rewrited fragment shader via cg to enshure that everything is correct. I’ve got the same result. Everything is normalized, clamped etc.

Pictures:
blinn ARB code - spec exponent 10 www.itstudents.ch/users/dave/files/sp_arb.png

blinn NV code - spec exponent 10 www.itstudents.ch/users/dave/files/sp_fp30.png

Only diffuse part http://www.itstudents.ch/users/dave/files/sp_diff.png

Only specular part www.itstudents.ch/users/dave/files/sp_spec.png

Summ of diff and spec - rings??? www.itstudents.ch/users/dave/files/sp_white.png

Blinn with high specualr exponent - 100 www.itstudents.ch/users/dave/files/sp_diff.png

Zengar.

[This message has been edited by Zengar (edited 09-19-2003).]

That all looks normal to me…

Fortunately, this is absolutely normal and precision has nothing to do with this. Blue component got clamped to 1 near border of specular highlight, resulting in non smooth change of brightnes (plus weird change in color saturation), to which human sight is sensitive (it is just like it is easy to notice linear interpolation over large areas, color changes continously, but not smoothly, so it looks ugly). You have the same ring in your high exponent pic, but it is simply smaller.

If you want to avoid these rings, you must avoid clamping. Adjust your diffuse and specular intensities so that they never exceed 1 when added, or apply exposure (better, but requires using realistic light intensities, realistic attenuation, realistic ratio between diffuse and specular material intensities… lots of more work)

Oh, I see…

MZ, this shader is a first one im my large project towards realistic lighting. unfortunatly, it’s not so easy to find well-readable information on this. I already found a number of sources on Schlick, Cook-Torrance, improved Phong etc. But i haven’t seen anything about HDR, and it would be very interesting to me. Maybe you know some good sources/articles etc.

Thank you.
Zengar.

P.S. Can one do lens effect with this clamp stuff ?

[This message has been edited by Zengar (edited 09-19-2003).]

But i haven’t seen anything about HDR, and it would be very interesting to me. Maybe you know some good sources/articles etc.
Sorry, I’m struggling with this myself like crazy For start, see recent thread about HL2, there are 2 links to Hugo Elias articles.