# help with atmospheric rendeirng

This topic is 4411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

ive been looking a the atmosphere chapter in GPU gems 2... ive done a few trys to implement it but can get it to work... so i tried just copying the code directly from the supplied disc.. but still it doesnt work... all i get is a black dome where i get some whithecolored vertexes as i move with the camera... what am i doin wrong?

SunAngle = 45.0f;
SunDir.comptopolar(SunAngle);
void CompToPolar(int angle)
{
x = -(float)cos(angle*PIOVER180);
y = -(float)sin(angle*PIOVER180);
z = (float)0;
}

float m_nSamples = 3;		// Number of sample rays to use in integral equation
float m_Kr = 0.0025f;		// Rayleigh scattering constant
float m_Kr4PI = m_Kr*4.0f*PI;
float m_Km = 0.0010f;		// Mie scattering constant
float m_Km4PI = m_Km*4.0f*PI;
float m_ESun = 20.0f;		// Sun brightness constant
float m_g = -0.990f;		// The Mie phase asymmetry factor
float m_fExposure = 2.0f;

float m_fWavelength[3];
m_fWavelength[0] = 0.650f;		// 650 nm for red
m_fWavelength[1] = 0.570f;		// 570 nm for green
m_fWavelength[2] = 0.475f;		// 475 nm for blue
float m_fWavelength4[3];
m_fWavelength4[0] = powf(m_fWavelength[0], 4.0f);
m_fWavelength4[1] = powf(m_fWavelength[1], 4.0f);
m_fWavelength4[2] = powf(m_fWavelength[2], 4.0f);

void CTERRAIN::RenderSkyDome()
{

float m_fRayleighScaleDepth = 0.25f;
float m_fMieScaleDepth = 0.1f;

CVECTOR vCamera = m_Cam->Position;

glCallList(SkyDomeList);

void CTERRAIN::InitSkyDome()
{

SkyDomeList = glGenLists(1);

glNewList(SkyDomeList, GL_COMPILE);

int dphi = 10;
int dtheta = 10;

glBegin(GL_TRIANGLE_STRIP);

for (int phi = 0; phi <= 90-dphi; phi += (int)dphi)
{
for (int theta = 0; theta <= 360-dtheta; theta += (int)dtheta)
{

glVertex3f( DomeRadius * sinf(phi*PIOVER180) * cosf(PIOVER180*theta)+m_iSize/2,

glVertex3f( DomeRadius * sinf((phi+dphi)*PIOVER180) * cosf(theta*PIOVER180)+m_iSize/2,

glVertex3f( DomeRadius * sinf(PIOVER180*phi) * cosf(PIOVER180*(theta+dtheta))+m_iSize/2,

if (phi > -90 && phi < 90)
{

glVertex3f( DomeRadius * sinf((phi+dphi)*PIOVER180) * cosf(PIOVER180*(theta+dtheta))+m_iSize/2,
DomeRadius * sinf((phi+dphi)*PIOVER180) * sinf(PIOVER180*(theta+dtheta)) +m_iSize/2);
}
}
}

glEnd();

glEndList();

}

// SHADERS... COPIED RIGHT FROM THE CD.. "SkyFromAtmosphere"


i dont know if its allowed to post the code from the book here on the forums... if anybody knows if its okey hten ill post that also...

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633295
• Total Posts
3011243
• ### Who's Online (See full list)

There are no registered users currently online

×