PDA

View Full Version : Wrong shading



nik_bg
11-23-2004, 05:26 AM
http://map3d.tripod.com/temp/untitled.bmp

This is a simple quad with 4 vertices in smooth shading. Why the shading in reality is not smooth, but has such strange artifacts (horizontal darker lines) ??? If you don't see them at first, zoom the picture.

ZbuffeR
11-23-2004, 06:40 AM
Mmh, no artifacts in this perfect RGB 24 bit color image.
Inspect it with a color picker (Gimp, Photoshop, etc) and you will see that color values increase only by one each time.

You may enhance it by setting slightly values to different color component , ie 245,255,243 instead of full white. That way one component at a time will do its 'color band' so it will be less noticeable.

If you really need more precision, you may try floating point buffers and then dithering to 24 bit color, but it is hard work ...

... don't worry too much about it, your shading is perfect.

nik_bg
11-23-2004, 07:28 AM
On my computer it is with horizontal dark lines. The upper two vertices are glColor3f(0.3, 0.3, 0.3), the lower two vertices are glColor3f(0.1, 0.1, 0.1). If I increase the color range (e.g 0.9 x 0.1), the horizontal lines disappear. I have taken the image using keyboard prntscr, and the horizontal lines are clearly visible ?!?!?!

ZbuffeR
11-23-2004, 12:50 PM
PLEASE READ carefully my previous post.
Indeed the colors go like this (Use Gimp or Photoshop or PaintShopPro or whatever you like but DO IT).

R,G,B:
60,60,60
60,60,60
... wide section with same flat color ....
60,60,60
59,59,59
59,59,59
... wide section with same flat color ....
59,59,59
58,58,58
... wide section with same flat color ....
58,58,58
58,58,58
etc.

YOU CAN NOT HAVE MORE COLOR PRECISION.
So if you see the lines separating the uniform parts it means that a) you have very good eyes and/or b) the gamma/brightness/contrast of your monitor is set too high.

With high range, it is normal that those lines disappear, because color changes almost every line.

Don't rely on floating point measures of color. Stay with 8bit per color component, it means GLubyte, integer values ranging from [0 to 255].

Really, try the solution I gave, that is do not use plain gray, but slightly modified colors like glColor3ub (74 , 76 , 75 );

nik_bg
11-23-2004, 10:21 PM
Zbuffer,

You are right. I also investigated the file, it is correct. Tried on other computer/video card and it looks correct, except when it is large zoom. So the reason is some hardware tuning on my computer.

I am quite familiar with floating/ubyte colors, the floating point precision for 32bit color is 1.0/255. I will try your suggestion and will add some low-sigma normal noise to the uniform color.

But this effect is quite interesting: if the color of a vertical line from my image is like
60,60,60,60,
59,59,59,59,
58,58,58,58

on the display it looks like e.g.

59,60,61,62,
58,59,60,61,
57,58,59,60 etc

The most interesting is that if the color of the whole image is uniform, it looks OK.

I just can't find reasonable explanation ...