Advertisement

What causes this?

Started by March 05, 2001 07:33 PM
8 comments, last by SilentStrike 23 years, 8 months ago
What causes the artifacting around the back of the head of the vector? In case HTML isn''t supported by the forums... http://www.geocities.com/rpgnmets/uglyshading.jpg
Hmm... no answers?

Here is the source I use to draw the vector. Is it that my polys aren''t all clockwise? Should I be using triangle strip rather than quad strip?

void drawVector(int numSides =50) {
float y , z, angle(0);
float step = 2 * PI / numSides;

glBegin(GL_POLYGON);
for (angle = 0; angle < 2*PI + step; angle+= step) {
glColor3f(1-y, .3f, 1-z);
y = sin(angle);
z = cos(angle);
glVertex3f(0.0f , .1* y , .1*z);
}
glEnd();

glBegin(GL_QUAD_STRIP);
for (angle= -PI; angle < PI + step; angle += step) {
y = sin(angle);
z = cos(angle);
glColor3f(y, .3f, z);
glVertex3f(0.0f, .1*y , .1*z);
glVertex3f(.75f, .1* y , .1*z);
}
glEnd();

glBegin(GL_QUAD_STRIP);
for (angle= -PI; angle < PI + step; angle += step) {
y = sin(angle);
z = cos(angle);
glColor3f(y, .3f, z);
glVertex3f(1.0f, 0 , 0);
glVertex3f(.55f, .1*y*2.5 , .1*z*2.5);
}
glEnd();

glBegin(GL_QUAD_STRIP);
for (angle= -PI; angle < PI + step; angle += step) {
glColor3f(1-y, .3f, 1-z);
y = sin(angle);
z = cos(angle);
glVertex3f(.55f, .1*y*2.5, .1*z*2.5);
glVertex3f(.75f, .1*y , .1*z);
}

glEnd();
}
Advertisement
Try scaling your vertices down by 1000 and see what happens.
You mean dividing all the locations of the verticies by 1000? What/how will that help?
My brother had a similar problem and it was because his verticies were too big. He scaled it down by 1000 (by dividing, yes) and it worked fine. I''m sorry if this doesn''t work. Like I said my brother had a "similar" problem so I''m not sure if it''ll work.
I tryed the code on my system, after I fixed the aprox 40 compiler warnings I got from doubles being converted to floats (make sure you put the ''f'' at the end of float numbers! (i.e. .1*z to .1f*z) and type cast the results of the sin and cos to float) it worked fine. You''ll need to reverse the order of the points in the quads for the cone because with back face culling enabled it''s culling the wrong faces. If it''s not because of the double->float conversion the only other thing it might be is a driver/card problem? I didn''t see even the slightest bit of the artifacting and I tryed a variety of detail levels from 8 to 32 for numSides.
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Advertisement
My compiler doesn''t give me any warnings with conversions from float to double for the gl functions. Odd.

Anyway, I changed all the sin() and cos() to sinf() and cosf() and made sure every coefficient was a float (.1f) but still I get them when I move far away from the vector. Could this be because of poor/improper depth testing?
I believe this is as a result of improper "near" and "far" settings in your glOrtho or glPerspective calls. The last 2 parameters.
These are used by openGL to determine the boundaries of the clipping plane. If you set the gap between near and far to a large amount then you''ll get these artifacts. That''s probably why the scaling worked for Twiglet. Try reducing this distance and see if that fixes it, if not reply with the entire source.

fs

http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//
fshana is right. Your far plane should be no more than 1000 times the near plane or you lose zBuffer resolution and get polygons fighting for z spots. I think this is with a 16-bit z buffer.

I generally use 1.0f and 1000.0f, or 0.1f and 100.0f depending upon the size of the vertices. No need to divide vertex values, because you define how big units are in your world (within reason - I wouldn''t go any smaller or larger than the examples given).

HTH

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
~~~Cheers!Brett PorterPortaLib3D : A portable 3D game/demo libary for OpenGLCommunity Service Announcement: Read How to ask questions the smart way before posting!
Thanks guys. After some testing, the near/far ratio was the cause. Is there anyway to enable myself to have a larger supported ratio? Is the ratio determined by video RAM?

This topic is closed to new replies.

Advertisement