Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

voodoo_john

Practical Analytical Daylight Problems

This topic is 5146 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 cobbled together an attempt at implementing the imfamous "Practical Analytical Model for Daylight" paper from various sources on the boards (Illici's sky shader code I think), and surprise surprise, I'm having problems. When I render my skydome, I seem to have a jaggy seam that runs from the apex right down to the skirt of the dome. If I texture the dome, the texture has a nasty seam but it's nothing to do with clamping. When I try to color the dome, the jaggy seam breaks up the colors. I was able to fudge it so the jaggy seam went away, but then I lost the sun-bloom and instead the whole dome changed color at once based on time of day, rather than an arcing sun with halo etc. So my question is: What is the best way to generate skydome geometry that is compatible with the PAMfD method of shading? (In terms of being able to specify angles to the shading code) (I'd post screenshots but can't right now) [edited by - voodoo_john on April 14, 2004 11:59:43 AM]

Share this post


Link to post
Share on other sites
Advertisement
Here's the code


for (int j=startHeightSlice; j<heightSlices; j++)
{
float theta1 = j * HALFPI / float(heightSlices);
float theta2 = (j + 1) * HALFPI / float(heightSlices);

glBegin(GL_QUAD_STRIP);

for (int i=startRotationSlice;i<=rotationSlices;i++)
{
float theta3 = i * TWOPI / float(rotationSlices);
float c = theta3 / TWOPI * maxTexCoord;

CVector3 e1, p1;
e1.x = float(cos(theta1) * cos(theta3));
e1.y = float(sin(theta1));
e1.z = float(cos(theta1) * sin(theta3));
p1.x = radius * e1.x;
p1.y = radius2 * e1.y;
p1.z = radius * e1.z;

CVector3 e2, p2;
e2.x = float(cos(theta2) * cos(theta3));
e2.y = float(sin(theta2));
e2.z = float(cos(theta2) * sin(theta3));
p2.x = radius * e2.x;
p2.y = radius2 * e2.y;
p2.z = radius * e2.z;


CVector3 color;

color = skyColor.GetVertexColor(i*(3.14159/180),j*(3.14159/180));
//glTexCoord2f(c, float(j) / float(heightSlices));

glVertex3f(p1.x, p1.y, p1.z);
glColor3f( color.x, color.y, color.z );

//glTexCoord2f(c, float(j+1) / float(heightSlices));

//color = skyColor.GetVertexColor(theta1*(3.14159/180),theta2*(3.14159/180));

glVertex3f(p2.x, p2.y, p2.z);
glColor3f( color.x, color.y, color.z );

}


Anyone able to help at all?

[edited by - voodoo_john on April 14, 2004 6:10:18 PM]

Share this post


Link to post
Share on other sites
Acht come on guys! Surely somebody knows how to fix this!

When people say that there''s nothing left to write articles about, THIS kind of thing is exactly what is needing to be written about

Share this post


Link to post
Share on other sites
I can tell you it's probably an off-by-one error in either the loop condition or the texture-coordinate generation, but I doubt that helps much.

Why are you starting at startRotationSlice instead of at 0? If startRotationSlice != 0, then your theta3 should be (I think)

(i - startRotationSlice) * TWOPI / float(rotationSlices-startRotationSlice)

It's something like that anyway, if you're lucky someone will come along, tell me how wrong I am, and give you the correct answer.

[edit: darn line breaks never go where ya want them]

[edited by - fractoid on April 15, 2004 6:04:08 AM]

Share this post


Link to post
Share on other sites
Hey Fractoid,

Both the starting params in the loops start at 0, I just have them as variables for testing pruposes. Still no joy

The reason im going down this route is I want the dome geometry generation code separate from the sky shading code.

Thanks for replying :D

Share this post


Link to post
Share on other sites
From the screenshot it looks like there is z-fighting, perhaps you''re drawing 2 tris on top of each other or very close at that point? Drawing the dome in wireframe might give you a better view of any extra unwanted geometry.

Share this post


Link to post
Share on other sites
Didn''t look at the source yet but I was going to say the same thing, those jaggies are always a sign of z-buffer aliasing/fighting ...

Have you tried drawing the skybox first with glDisable(GL_DEPTH_TEST); and glDisable(GL_CULL_FACE); and then render the landscape ??

Share this post


Link to post
Share on other sites
Hi Paulc,

Yeah that thought had occured to me also, but the wireframe looks perfect. I will post a screenshot later.

Thing is when I texture it, there is a strange black seam like the traingles are not meeting..... Ag!

Edit: Also when you look at the dome, the left side is much darker than the right side... Why-oh-why?!

[edited by - voodoo_john on April 15, 2004 11:26:26 AM]

Share this post


Link to post
Share on other sites
Weyland,

Thanks for pointing that out, I'll test it when I get home.

Im getting old you see... too long in project management and you forget the obvious things :D

However, I have discoverd a kinds problem with the shading. I can get the sky color to change to what looks like appropriate colors, but the horizon is always lighter than the rest of the sky no matter what sun angle you use. Will post code later.

EDIT: Spelling

[edited by - voodoo_john on April 15, 2004 12:34:08 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!