Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

render.cpp File Reference

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <config.h>
#include <celutil/debug.h>
#include <celmath/frustum.h>
#include <celmath/distance.h>
#include <celmath/intersect.h>
#include <celutil/utf8.h>
#include <celutil/util.h>
#include "gl.h"
#include "astro.h"
#include "glext.h"
#include "vecgl.h"
#include "glshader.h"
#include "shadermanager.h"
#include "spheremesh.h"
#include "lodspheremesh.h"
#include "model.h"
#include "regcombine.h"
#include "vertexprog.h"
#include "texmanager.h"
#include "meshmanager.h"
#include "render.h"

Include dependency graph for render.cpp:

Go to the source code of this file.

Defines

#define FAR_DIST   1.0e9f
#define FOV   45.0f
#define GL_COLOR_SUM_EXT   0x8458
#define NEAR_DIST   0.5f

Functions

static Point3d astrocentricPosition (const UniversalCoord &pos, const Star &star, double t)
static const Color compassColor (0.4f, 0.4f, 1.0f)
static void disableSmoothLines ()
static Vec3f ellipsoidTangent (const Vec3f &recipSemiAxes, const Vec3f &w, const Vec3f &e, const Vec3f &e_, float ee)
static void enableSmoothLines ()
static void GlareTextureEval (float u, float v, float w, unsigned char *pixel)
static void IllumMapEval (float x, float y, float z, unsigned char *pixel)
bool operator< (const Renderer::Label &a, const Renderer::Label &b)
bool operator< (const RenderListEntry &a, const RenderListEntry &b)
static void PenumbraFunctionEval (float u, float v, float w, unsigned char *pixel)
 Lookup function for eclipse penumbras--the input is the amount of overlap.
static void ProcessCometTailVertex (const CometTailVertex &v, const Point3f &eyePos_obj, float b, float h)
static void ProcessCometTailVertex (const CometTailVertex &v, const Point3f &cameraPos)
static void ProcessCometTailVertex (const CometTailVertex &v, const Vec3f &viewDir, float fadeDistFromSun)
void renderAtmosphere (const Atmosphere &atmosphere, Point3f center, float radius, const Vec3f &sunDirection, Color ambientColor, float fade, bool lit)
static void renderBumpMappedMesh (const GLContext &context, Texture &baseTexture, Texture &bumpTexture, Vec3f lightDirection, Quatf orientation, Color ambientColor, const Frustum &frustum, float lod)
static void renderClouds_GLSL (const RenderInfo &ri, const LightingState &ls, Texture *cloudTex, float texOffset, RingSystem *rings, float radius, const Mat4f &planetMat, const Frustum &frustum, const GLContext &context)
void renderCompass (Point3f center, const Quatf &orientation, Vec3f semiAxes, float pixelSize)
static void renderEclipseShadows (Model *model, vector< EclipseShadow > &eclipseShadows, RenderInfo &ri, float planetRadius, Mat4f &planetMat, Frustum &viewFrustum, const GLContext &context)
static void renderEclipseShadows_Shaders (Model *model, vector< EclipseShadow > &eclipseShadows, RenderInfo &ri, float planetRadius, Mat4f &planetMat, Frustum &viewFrustum, const GLContext &context)
static void renderModel_GLSL (Model *Model, const LightingState &ls, float radius, const Mat4f &planetMat)
static void renderModelDefault (Model *model, const RenderInfo &ri, bool lit)
void renderOrbitColor (const Body *body, bool selected)
static void renderRings (RingSystem &rings, RenderInfo &ri, float planetRadius, float planetOblateness, unsigned int textureResolution, bool renderShadow, const GLContext &context, unsigned int nSections)
static void renderRings_GLSL (RingSystem &rings, RenderInfo &ri, const LightingState &ls, float planetRadius, float planetOblateness, unsigned int textureResolution, bool renderShadow, unsigned int nSections)
static void renderRingShadowsVS (Model *model, const RingSystem &rings, const Vec3f &sunDir, RenderInfo &ri, float planetRadius, float oblateness, Mat4f &planetMat, Frustum &viewFrustum, const GLContext &context)
static void renderRingSystem (float innerRadius, float outerRadius, float beginAngle, float endAngle, unsigned int nSections)
static void renderShadowedModelDefault (Model *model, const RenderInfo &ri, const Frustum &frustum, float *sPlane, float *tPlane, const Vec3f &lightDir, bool useShadowMask, const GLContext &context)
static void renderShadowedModelVertexShader (const RenderInfo &ri, const Frustum &frustum, float *sPlane, float *tPlane, Vec3f &lightDir, const GLContext &context)
static void renderSmoothMesh (const GLContext &context, Texture &baseTexture, Vec3f lightDirection, Quatf orientation, Color ambientColor, float lod, const Frustum &frustum, bool invert=false)
static void renderSphere_Combiners (const RenderInfo &ri, const Frustum &frustum, const GLContext &context)
static void renderSphere_Combiners_VP (const RenderInfo &ri, const LightingState &ls, const Frustum &frustum, const GLContext &context)
static void renderSphere_DOT3_VP (const RenderInfo &ri, const LightingState &ls, const Frustum &frustum, const GLContext &context)
static void renderSphere_FP_VP (const RenderInfo &ri, const Frustum &frustum, const GLContext &context)
static void renderSphere_GLSL (const RenderInfo &ri, const LightingState &ls, RingSystem *rings, float radius, const Mat4f &planetMat, const Frustum &frustum, const GLContext &context)
static void renderSphereDefault (const RenderInfo &ri, const Frustum &frustum, bool lit, const GLContext &context)
static void setEclipseShadowShaderConstants (const LightingState &ls, float planetRadius, const Mat4f &planetMat, CelestiaGLProgram &prog)
static void setLightParameters_GLSL (CelestiaGLProgram &prog, const ShaderProperties &shadprop, const LightingState &ls, Color materialDiffuse, Color materialSpecular)
static void setLightParameters_VP (VertexProcessor &vproc, const LightingState &ls, Color materialDiffuse, Color materialSpecular)
static void setupBumpTexenv ()
static void setupBumpTexenvAmbient (Color ambientColor)
static void setupLightSources (const vector< const Star * > &nearStars, const Star &sun, double t, vector< Renderer::LightSource > &lightSources)
static void setupNightTextureCombine ()
static void setupObjectLighting (const vector< Renderer::LightSource > &suns, const Point3d &objPosition, const Quatf &objOrientation, const Vec3f &objScale, const Point3f &objPosition_eye, LightingState &ls)
static void setupTexenvAmbient (Color ambientColor)
static void setupTexenvGlossMapAlpha ()
static void ShadowTextureEval (float u, float v, float w, unsigned char *pixel)
static void StarTextureEval (float u, float v, float w, unsigned char *pixel)
static void texGenPlane (GLenum coord, GLenum mode, const Vec4f &plane)
void transformOrbits (const PlanetarySystem *system)

Variables

static bool buggyVertexProgramEmulation = true
static const int CometTailSlices = 16
static CometTailVertex cometTailVertices [CometTailSlices *MaxCometTailPoints]
static bool commonDataInitialized = false
static SphericalCoordLabelcoordLabels = NULL
static const float CoronaHeight = 0.2f
static const double DSO_DISTANCE_LIMIT = 1.8e9
static TextureeclipseShadowTextures [4]
static TextureglareTex = NULL
static LODSphereMeshlodSphere = NULL
static const int MaxCometTailPoints = 20
static const float MaxFarNearRatio = 2000.0f
static const float MaxScaledDiscStarSize = 8.0f
static const int MaxSkyRings = 32
static const int MaxSkySlices = 180
static const float MinFeatureSizeForLabel = 20.0f
static const float MinNearPlaneDistance = 0.0001f
static const float MinOrbitSizeForLabel = 20.0f
static const int MinSkySlices = 30
static int nCoordLabels = 32
static TexturenormalizationTex = NULL
static TexturepenumbraFunctionTexture = NULL
static const float PixelOffset = 0.125f
static const int REF_DISTANCE_TO_SCREEN = 400
static const float RenderDistance = 50.0f
static TextureshadowMaskTexture = NULL
static TextureshadowTex = NULL
static const float ShadowTextureScale = 15.0f / 16.0f
static const float STAR_DISTANCE_LIMIT = 1.0e6f
static TexturestarTex = NULL
static const int StarVertexListSize = 1024
static const float X0_SOL = astro::AUtoKilometers(5.0f)


Define Documentation

#define FAR_DIST   1.0e9f
 

Definition at line 46 of file render.cpp.

Referenced by Renderer::render().

#define FOV   45.0f
 

Definition at line 44 of file render.cpp.

Referenced by Renderer::autoMag(), StarRenderer::process(), Renderer::renderBodyAsParticle(), Renderer::Renderer(), and Renderer::setFieldOfView().

#define GL_COLOR_SUM_EXT   0x8458
 

Definition at line 50 of file render.cpp.

Referenced by renderSphere_Combiners_VP(), and renderSphere_FP_VP().

#define NEAR_DIST   0.5f
 

Definition at line 45 of file render.cpp.

Referenced by Renderer::render().


Function Documentation

static Point3d astrocentricPosition const UniversalCoord pos,
const Star star,
double  t
[static]
 

Definition at line 1175 of file render.cpp.

References Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by StarRenderer::process(), Renderer::render(), and Renderer::renderPlanetarySystem().

01178 {
01179     UniversalCoord starPos = star.getPosition(t);
01180 
01181     Vec3d v = pos - starPos;
01182     return Point3d(astro::microLightYearsToKilometers(v.x),
01183                    astro::microLightYearsToKilometers(v.y),
01184                    astro::microLightYearsToKilometers(v.z));
01185 }

static const Color compassColor 0.  4f,
0.  4f,
1.  0f
[static]
 

Referenced by renderCompass().

static void disableSmoothLines  )  [static]
 

Definition at line 843 of file render.cpp.

Referenced by Renderer::render(), Renderer::renderDeepSkyObjects(), Renderer::renderForegroundOrbits(), and Renderer::renderPlanet().

00844 {
00845     // glDisable(GL_BLEND);
00846     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
00847     glDisable(GL_LINE_SMOOTH);
00848     glLineWidth(1.0f);
00849 }

static Vec3f ellipsoidTangent const Vec3f recipSemiAxes,
const Vec3f w,
const Vec3f e,
const Vec3f e_,
float  ee
[static]
 

Definition at line 2358 of file render.cpp.

References sqrt(), square(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by renderCompass(), and Renderer::renderEllipsoidAtmosphere().

02363 {
02364     // We want to find t such that -E(1-t) + Wt is the direction of a ray
02365     // tangent to the ellipsoid.  A tangent ray will intersect the ellipsoid
02366     // at exactly one point.  Finding the intersection between a ray and an
02367     // ellipsoid ultimately requires using the quadratic formula, which has
02368     // one solution when the discriminant (b^2 - 4ac) is zero.  The code below
02369     // computes the value of t that results in a discriminant of zero.
02370     Vec3f w_(w.x * recipSemiAxes.x, w.y * recipSemiAxes.y, w.z * recipSemiAxes.z);
02371     float ww = w_ * w_;
02372     float ew = w_ * e_;
02373 
02374     // Before elimination of terms:
02375     // float a =  4 * square(ee + ew) - 4 * (ee + 2 * ew + ww) * (ee - 1.0f);
02376     // float b = -8 * ee * (ee + ew)  - 4 * (-2 * (ee + ew) * (ee - 1.0f));
02377     // float c =  4 * ee * ee         - 4 * (ee * (ee - 1.0f));
02378 
02379     float a =  4 * square(ee + ew) - 4 * (ee + 2 * ew + ww) * (ee - 1.0f);
02380     float b = -8 * (ee + ew);
02381     float c =  4 * ee;
02382 
02383     float t = 0.0f;
02384     float discriminant = b * b - 4 * a * c;
02385 
02386     if (discriminant < 0.0f)
02387         t = (-b + (float) sqrt(-discriminant)) / (2 * a); // Bad!
02388     else
02389         t = (-b + (float) sqrt(discriminant)) / (2 * a);
02390 
02391     // V is the direction vector.  We now need the point of intersection,
02392     // which we obtain by solving the quadratic equation for the ray-ellipse
02393     // intersection.  Since we already know that the discriminant is zero,
02394     // the solution is just -b/2a
02395     Vec3f v = -e * (1 - t) + w * t;
02396     Vec3f v_(v.x * recipSemiAxes.x, v.y * recipSemiAxes.y, v.z * recipSemiAxes.z);
02397     float a1 = v_ * v_;
02398     float b1 = 2.0f * v_ * e_;
02399     float t1 = -b1 / (2 * a1);
02400 
02401     return e + v * t1;
02402 }

static void enableSmoothLines  )  [static]
 

Definition at line 835 of file render.cpp.

Referenced by Renderer::render(), Renderer::renderDeepSkyObjects(), Renderer::renderForegroundOrbits(), and Renderer::renderPlanet().

00836 {
00837     // glEnable(GL_BLEND);
00838     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
00839     glEnable(GL_LINE_SMOOTH);
00840     glLineWidth(1.5f);
00841 }

static void GlareTextureEval float  u,
float  v,
float  w,
unsigned char *  pixel
[static]
 

Definition at line 206 of file render.cpp.

References sqrt().

Referenced by Renderer::init().

00208 {
00209     float r = 0.9f - (float) sqrt(u * u + v * v);
00210     if (r < 0)
00211         r = 0;
00212 
00213     int pixVal = (int) (r * 255.99f);
00214     pixel[0] = 65;
00215     pixel[1] = 64;
00216     pixel[2] = 65;
00217     pixel[3] = pixVal;
00218 }

static void IllumMapEval float  x,
float  y,
float  z,
unsigned char *  pixel
[static]
 

Definition at line 306 of file render.cpp.

References Vector3< T >::normalize(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::init().

00308 {
00309     Vec3f v(x, y, z);
00310     Vec3f u(0, 0, 1);
00311 
00312 #if 0
00313     Vec3f n(0, 0, 1);
00314     // Experimental illumination function
00315     float c = v * n;
00316     if (c < 0.0f)
00317     {
00318         u = v;
00319     }
00320     else
00321     {
00322         c = (1 - ((1 - c))) * 1.0f;
00323         u = v + (c * n);
00324         u.normalize();
00325     }
00326 #else
00327     u = v;
00328 #endif
00329 
00330     pixel[0] = 128 + (int) (127 * u.x);
00331     pixel[1] = 128 + (int) (127 * u.y);
00332     pixel[2] = 128 + (int) (127 * u.z);
00333 }

bool operator< const Renderer::Label a,
const Renderer::Label b
 

Definition at line 373 of file render.cpp.

References Vector3< T >::z.

00374 {
00375     return a.position.z > b.position.z;
00376 }

bool operator< const RenderListEntry a,
const RenderListEntry b
 

Definition at line 335 of file render.cpp.

References distance(), Vector3< T >::normalize(), and testIntersection().

00336 {
00337     // This comparison functions tries to determine which of two objects is
00338     // closer to the viewer.  Looking just at the distances of the centers
00339     // is not enough, nor is comparing distances to the bounding spheres.
00340     // Here we trace a ray from the viewer to the center of the smaller
00341     // of the two objects and see which object it intersects first.  If the
00342     // ray doesn't intersect the larger object at all, it's safe to use
00343     // the distance to bounding sphere test.
00344     if (a.radius < b.radius)
00345     {
00346         Vec3f dir = a.position - Point3f(0.0f, 0.0f, 0.0f);
00347         float distance;
00348         dir.normalize();
00349         if (testIntersection(Ray3f(Point3f(0.0f, 0.0f, 0.0f), dir),
00350                              Spheref(b.position, b.radius),
00351                              distance))
00352         {
00353             return a.distance - a.radius < distance;
00354         }
00355     }
00356     else
00357     {
00358         Vec3f dir = b.position - Point3f(0.0f, 0.0f, 0.0f);
00359         float distance;
00360         dir.normalize();
00361         if (testIntersection(Ray3f(Point3f(0.0f, 0.0f, 0.0f), dir),
00362                              Spheref(a.position, a.radius),
00363                              distance))
00364         {
00365             return distance < b.distance - b.radius;
00366         }
00367     }
00368 
00369     return a.distance - a.radius < b.distance - b.radius;
00370 }

static void PenumbraFunctionEval float  u,
float  v,
float  w,
unsigned char *  pixel
[static]
 

Lookup function for eclipse penumbras--the input is the amount of overlap.

Definition at line 238 of file render.cpp.

Referenced by Renderer::init().

00240 {
00241     u = (u + 1.0f) * 0.5f;
00242 
00243     // Using the cube root produces a good visual result
00244     unsigned char pixVal = (unsigned char) (::pow((double) u, 0.33) * 255.99);
00245 
00246     pixel[0] = pixVal;
00247 }

static void ProcessCometTailVertex const CometTailVertex v,
const Point3f eyePos_obj,
float  b,
float  h
[static]
 

Definition at line 5815 of file render.cpp.

References glVertex(), max, min, sqrt(), square(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

05819 {
05820     float shade = 0.0f;
05821     Vec3f R = v.paraboloidPoint - eyePos_obj;
05822     float c0 = b * (square(eyePos_obj.x) + square(eyePos_obj.y)) + eyePos_obj.z;
05823     float c1 = 2 * b * (R.x * eyePos_obj.x + R.y * eyePos_obj.y) - R.z;
05824     float c2 = b * (square(R.x) + square(R.y));
05825 
05826     float disc = square(c1) - 4 * c0 * c2;
05827 
05828     if (disc < 0.0f)
05829     {
05830         shade = 0.0f;
05831     }
05832     else
05833     {
05834         disc = (float) sqrt(disc);
05835         float s = 1.0f / (2 * c2);
05836         float t0 = (h - eyePos_obj.z) / R.z;
05837         float t1 = (c1 - disc) * s;
05838         float t2 = (c1 + disc) * s;
05839         float u0 = max(t0, 0.0f);
05840         float u1, u2;
05841 
05842         if (R.z < 0.0f)
05843         {
05844             u1 = max(t1, t0);
05845             u2 = max(t2, t0);
05846         }
05847         else
05848         {
05849             u1 = min(t1, t0);
05850             u2 = min(t2, t0);
05851         }
05852         u1 = max(0.0f, u1);
05853         u2 = max(0.0f, u2);
05854 
05855         shade = u2 - u1;
05856     }
05857 
05858     glColor4f(0.0f, 0.5f, 1.0f, shade);
05859     glVertex(v.point);
05860 }

static void ProcessCometTailVertex const CometTailVertex v,
const Point3f cameraPos
[static]
 

Definition at line 5804 of file render.cpp.

References abs(), glVertex(), Vector3< T >::normalize(), and CometTailVertex::point.

05806 {
05807     Vec3f viewDir = v.point - cameraPos;
05808     viewDir.normalize();
05809     float shade = abs(viewDir * v.normal * v.brightness);
05810     glColor4f(0.0f, 0.5f, 1.0f, shade);
05811     glVertex(v.point);
05812 }

static void ProcessCometTailVertex const CometTailVertex v,
const Vec3f viewDir,
float  fadeDistFromSun
[static]
 

Definition at line 5791 of file render.cpp.

References abs(), and glVertex().

Referenced by Renderer::renderCometTail().

05794 {
05795     // If fadeDistFromSun = x/x0 >= 1.0, comet tail starts fading,
05796     // i.e. fadeFactor quickly transits from 1 to 0.
05797     
05798     float fadeFactor = 0.5f - 0.5f * tanh(fadeDistFromSun - 1.0f / fadeDistFromSun);
05799     float shade = abs(viewDir * v.normal * v.brightness * fadeFactor);
05800     glColor4f(0.5f, 0.5f, 0.75f, shade);
05801     glVertex(v.point);
05802 }

void renderAtmosphere const Atmosphere atmosphere,
Point3f  center,
float  radius,
const Vec3f sunDirection,
Color  ambientColor,
float  fade,
bool  lit
 

Definition at line 2264 of file render.cpp.

References abs(), cos(), glVertex(), Vector3< T >::length(), Math< T >::lerp(), Vector3< T >::normalize(), PI, Color::red(), sin(), sqrt(), square(), and Vector3< T >::y.

Referenced by Renderer::renderObject().

02271 {
02272     if (atmosphere.height == 0.0f)
02273         return;
02274 
02275     glDepthMask(GL_FALSE);
02276 
02277     Vec3f eyeVec = center - Point3f(0.0f, 0.0f, 0.0f);
02278     double centerDist = eyeVec.length();
02279     // double surfaceDist = (double) centerDist - (double) radius;
02280 
02281     Vec3f normal = eyeVec;
02282     normal = normal / (float) centerDist;
02283 
02284     float tangentLength = (float) sqrt(square(centerDist) - square(radius));
02285     float atmRadius = tangentLength * radius / (float) centerDist;
02286     float atmOffsetFromCenter = square(radius) / (float) centerDist;
02287     Point3f atmCenter = center - atmOffsetFromCenter * normal;
02288 
02289     Vec3f uAxis, vAxis;
02290     if (abs(normal.x) < abs(normal.y) && abs(normal.x) < abs(normal.z))
02291     {
02292         uAxis = Vec3f(1, 0, 0) ^ normal;
02293         uAxis.normalize();
02294     }
02295     else if (abs(eyeVec.y) < abs(normal.z))
02296     {
02297         uAxis = Vec3f(0, 1, 0) ^ normal;
02298         uAxis.normalize();
02299     }
02300     else
02301     {
02302         uAxis = Vec3f(0, 0, 1) ^ normal;
02303         uAxis.normalize();
02304     }
02305     vAxis = uAxis ^ normal;
02306 
02307     float height = atmosphere.height / radius;
02308 
02309     glBegin(GL_QUAD_STRIP);
02310     int divisions = 180;
02311     for (int i = 0; i <= divisions; i++)
02312     {
02313         float theta = (float) i / (float) divisions * 2 * (float) PI;
02314         Vec3f v = (float) cos(theta) * uAxis + (float) sin(theta) * vAxis;
02315         Point3f base = atmCenter + v * atmRadius;
02316         Vec3f toCenter = base - center;
02317 
02318         float cosSunAngle = (toCenter * sunDirection) / radius;
02319         float brightness = 1.0f;
02320         float botColor[3];
02321         float topColor[3];
02322         botColor[0] = atmosphere.lowerColor.red();
02323         botColor[1] = atmosphere.lowerColor.green();
02324         botColor[2] = atmosphere.lowerColor.blue();
02325         topColor[0] = atmosphere.upperColor.red();
02326         topColor[1] = atmosphere.upperColor.green();
02327         topColor[2] = atmosphere.upperColor.blue();
02328 
02329         if (cosSunAngle < 0.2f && lit)
02330         {
02331             if (cosSunAngle < -0.2f)
02332             {
02333                 brightness = 0;
02334             }
02335             else
02336             {
02337                 float t = (0.2f + cosSunAngle) * 2.5f;
02338                 brightness = t;
02339                 botColor[0] = Mathf::lerp(t, 1.0f, botColor[0]);
02340                 botColor[1] = Mathf::lerp(t, 0.3f, botColor[1]);
02341                 botColor[2] = Mathf::lerp(t, 0.0f, botColor[2]);
02342                 topColor[0] = Mathf::lerp(t, 1.0f, topColor[0]);
02343                 topColor[1] = Mathf::lerp(t, 0.3f, topColor[1]);
02344                 topColor[2] = Mathf::lerp(t, 0.0f, topColor[2]);
02345             }
02346         }
02347 
02348         glColor4f(botColor[0], botColor[1], botColor[2],
02349                   0.85f * fade * brightness + ambientColor.red());
02350         glVertex(base - toCenter * height * 0.05f);
02351         glColor4f(topColor[0], topColor[1], topColor[2], 0.0f);
02352         glVertex(base + toCenter * height);
02353     }
02354     glEnd();
02355 }

static void renderBumpMappedMesh const GLContext context,
Texture baseTexture,
Texture bumpTexture,
Vec3f  lightDirection,
Quatf  orientation,
Color  ambientColor,
const Frustum frustum,
float  lod
[static]
 

Definition at line 2016 of file render.cpp.

References DisableCombiners(), GL_NORMAL_MAP_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, glRotate(), lodSphere, normalizationTex, Vector3< T >::normalize(), PI, LODSphereMesh::render(), Quaternion< T >::setAxisAngle(), and SetupCombinersBumpMap().

Referenced by renderSphere_Combiners().

02024 {
02025     // We're doing our own per-pixel lighting, so disable GL's lighting
02026     glDisable(GL_LIGHTING);
02027 
02028     // Render the base texture on the first pass . . .  The color
02029     // should have already been set up by the caller.
02030     lodSphere->render(context,
02031                       LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
02032                       frustum, lod,
02033                       &baseTexture);
02034 
02035     // The 'default' light vector for the bump map is (0, 0, 1).  Determine
02036     // a rotation transformation that will move the sun direction to
02037     // this vector.
02038     Quatf lightOrientation;
02039     {
02040         Vec3f zeroLightDirection(0, 0, 1);
02041         Vec3f axis = lightDirection ^ zeroLightDirection;
02042         float cosAngle = zeroLightDirection * lightDirection;
02043         float angle = 0.0f;
02044         float epsilon = 1e-5f;
02045 
02046         if (cosAngle + 1 < epsilon)
02047         {
02048             axis = Vec3f(0, 1, 0);
02049             angle = (float) PI;
02050         }
02051         else if (cosAngle - 1 > -epsilon)
02052         {
02053             axis = Vec3f(0, 1, 0);
02054             angle = 0.0f;
02055         }
02056         else
02057         {
02058             axis.normalize();
02059             angle = (float) acos(cosAngle);
02060         }
02061         lightOrientation.setAxisAngle(axis, angle);
02062     }
02063 
02064     glEnable(GL_BLEND);
02065     glBlendFunc(GL_DST_COLOR, GL_ZERO);
02066 
02067     // Set up the bump map with one directional light source
02068     SetupCombinersBumpMap(bumpTexture, *normalizationTex, ambientColor);
02069 
02070     // The second set texture coordinates will contain the light
02071     // direction in tangent space.  We'll generate the texture coordinates
02072     // from the surface normals using GL_NORMAL_MAP_EXT and then
02073     // use the texture matrix to rotate them into tangent space.
02074     // This method of generating tangent space light direction vectors
02075     // isn't as general as transforming the light direction by an
02076     // orthonormal basis for each mesh vertex, but it works well enough
02077     // for spheres illuminated by directional light sources.
02078     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02079 
02080     // Set up GL_NORMAL_MAP_EXT texture coordinate generation.  This
02081     // mode is part of the cube map extension.
02082     glEnable(GL_TEXTURE_GEN_R);
02083     glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02084     glEnable(GL_TEXTURE_GEN_S);
02085     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02086     glEnable(GL_TEXTURE_GEN_T);
02087     glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02088 
02089     // Set up the texture transformation--the light direction and the
02090     // viewer orientation both need to be considered.
02091     glMatrixMode(GL_TEXTURE);
02092     glScalef(-1.0f, 1.0f, 1.0f);
02093     glRotate(lightOrientation * ~orientation);
02094     glMatrixMode(GL_MODELVIEW);
02095     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02096 
02097     lodSphere->render(context,
02098                       LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
02099                       frustum, lod,
02100                       &bumpTexture);
02101 
02102     // Reset the second texture unit
02103     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02104     glMatrixMode(GL_TEXTURE);
02105     glLoadIdentity();
02106     glMatrixMode(GL_MODELVIEW);
02107     glDisable(GL_TEXTURE_GEN_R);
02108     glDisable(GL_TEXTURE_GEN_S);
02109     glDisable(GL_TEXTURE_GEN_T);
02110 
02111     DisableCombiners();
02112     glDisable(GL_BLEND);
02113 }

static void renderClouds_GLSL const RenderInfo ri,
const LightingState ls,
Texture cloudTex,
float  texOffset,
RingSystem rings,
float  radius,
const Mat4f planetMat,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3863 of file render.cpp.

References CelestiaGLProgram::ambientColor, Texture::bind(), ShaderManager::getShader(), GetShaderManager(), GL_CLAMP_TO_BORDER_ARB, GL_TEXTURE0_ARB, glx::glActiveTextureARB, glx::glUseProgramObjectARB, lodSphere, medres, min, ShaderProperties::nLights, LODSphereMesh::render(), CelestiaGLProgram::ringRadius, CelestiaGLProgram::ringWidth, setEclipseShadowShaderConstants(), setLightParameters_GLSL(), ShaderProperties::setShadowCountForLight(), ShaderProperties::shadowCounts, CelestiaGLProgram::textureOffset, ShaderProperties::texUsage, and CelestiaGLProgram::use().

Referenced by Renderer::renderObject().

03872 {
03873     unsigned int nTextures = 0;
03874 
03875     glDisable(GL_LIGHTING);
03876 
03877     ShaderProperties shadprop;
03878     shadprop.nLights = ls.nLights;
03879 
03880     // Set up the textures used by this object
03881     if (cloudTex != NULL)
03882     {
03883         shadprop.texUsage = ShaderProperties::DiffuseTexture;
03884         nTextures++;
03885     }
03886 
03887     if (rings != NULL)
03888         //(renderFlags & ShowRingShadows) != 0)
03889     {
03890         Texture* ringsTex = rings->texture.find(medres);
03891         if (ringsTex != NULL)
03892         {
03893             glx::glActiveTextureARB(GL_TEXTURE0_ARB + nTextures);
03894             ringsTex->bind();
03895             nTextures++;
03896 
03897             // Tweak the texture--set clamp to border and a border color with
03898             // a zero alpha.
03899             float bc[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
03900             glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bc);
03901             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
03902                             GL_CLAMP_TO_BORDER_ARB);
03903             glx::glActiveTextureARB(GL_TEXTURE0_ARB);
03904 
03905             shadprop.texUsage |= ShaderProperties::RingShadowTexture;
03906         }
03907     }
03908 
03909     // Set the shadow information.
03910     // Track the total number of shadows; if there are too many, we'll have
03911     // to fall back to multipass.
03912     unsigned int totalShadows = 0;
03913     for (unsigned int li = 0; li < ls.nLights; li++)
03914     {
03915         if (ls.shadows[li] && !ls.shadows[li]->empty())
03916         {
03917             unsigned int nShadows = (unsigned int) min((size_t) MaxShaderShadows, ls.shadows[li]->size());
03918             shadprop.setShadowCountForLight(li, nShadows);
03919             totalShadows += nShadows;
03920         }
03921     }
03922 
03923     // Get a shader for the current rendering configuration
03924     CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
03925     if (prog == NULL)
03926         return;
03927 
03928     prog->use();
03929 
03930     setLightParameters_GLSL(*prog, shadprop, ls,
03931                             ri.color, ri.specularColor);
03932 
03933     prog->ambientColor = Vec3f(ri.ambientColor.red(), ri.ambientColor.green(),
03934                                ri.ambientColor.blue());
03935     prog->textureOffset = texOffset;
03936     
03937     if (shadprop.texUsage & ShaderProperties::RingShadowTexture)
03938     {
03939         float ringWidth = rings->outerRadius - rings->innerRadius;
03940         prog->ringRadius = rings->innerRadius / radius;
03941         prog->ringWidth = 1.0f / (ringWidth / radius);
03942     }
03943 
03944     if (shadprop.shadowCounts != 0)    
03945         setEclipseShadowShaderConstants(ls, radius, planetMat, *prog);
03946 
03947     unsigned int attributes = LODSphereMesh::Normals;
03948     lodSphere->render(context,
03949                       LODSphereMesh::Normals,
03950                       frustum, ri.pixWidth,
03951                       cloudTex);
03952 
03953     prog->textureOffset = 0.0f;
03954 
03955     glx::glUseProgramObjectARB(0);
03956 }

void renderCompass Point3f  center,
const Quatf orientation,
Vec3f  semiAxes,
float  pixelSize
 

Definition at line 2693 of file render.cpp.

References compassColor(), conjugate(), cos(), distance(), ellipsoidTangent(), glColor(), glVertex(), Vector3< T >::length(), max, Vector3< T >::normalize(), PI, Matrix3< float >::scaling(), sin(), sqrt(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderPlanet().

02697 {
02698     Mat3f rot = orientation.toMatrix3();
02699     Mat3f irot = conjugate(orientation).toMatrix3();
02700 
02701     Point3f eyePos(0.0f, 0.0f, 0.0f);
02702     float radius = max(semiAxes.x, max(semiAxes.y, semiAxes.z));
02703     Vec3f eyeVec = center - eyePos;
02704     eyeVec = eyeVec * irot;
02705     double centerDist = eyeVec.length();
02706 
02707     float height = 1.0f / radius;
02708     Vec3f recipSemiAxes(1.0f / semiAxes.x,
02709                         1.0f / semiAxes.y,
02710                         1.0f / semiAxes.z);
02711 
02712     Vec3f recipAtmSemiAxes = recipSemiAxes / (1.0f + height);
02713     Mat3f A = Mat3f::scaling(recipAtmSemiAxes);
02714     Mat3f A1 = Mat3f::scaling(recipSemiAxes);
02715 
02716     const int nCompassPoints = 16;
02717     Vec3f compassPoints[nCompassPoints];
02718     
02719 
02720     // ellipDist is not the true distance from the surface unless the
02721     // planet is spherical.  Computing the true distance requires finding
02722     // the roots of a sixth degree polynomial, and isn't actually what we
02723     // want anyhow since the atmosphere region is just the planet ellipsoid
02724     // multiplied by a uniform scale factor.  The value that we do compute
02725     // is the distance to the surface along a line from the eye position to
02726     // the center of the ellipsoid.
02727     float ellipDist = (float) sqrt((eyeVec * A1) * (eyeVec * A1)) - 1.0f;
02728 
02729     Vec3f e = -eyeVec;
02730     Vec3f e_(e.x * recipSemiAxes.x, e.y * recipSemiAxes.y, e.z * recipSemiAxes.z);
02731     float ee = e_ * e_;
02732 
02733     Vec3f normal = eyeVec;
02734     normal = normal / (float) centerDist;
02735 
02736     Vec3f uAxis, vAxis;
02737     Vec3f northPole(0.0f, 1.0f, 0.0f);
02738     vAxis = normal ^ northPole;
02739     vAxis.normalize();
02740     uAxis = vAxis ^ normal;
02741 
02742     // Compute the compass points
02743     int i;
02744     for (i = 0; i < nCompassPoints; i++)
02745     {
02746         // We want rays with an origin at the eye point and tangent to the the
02747         // ellipsoid.
02748         float theta = (float) i / (float) nCompassPoints * 2 * (float) PI;
02749         Vec3f w = (float) cos(theta) * uAxis + (float) sin(theta) * vAxis;
02750         w = w * (float) centerDist;
02751 
02752         Vec3f toCenter = ellipsoidTangent(recipSemiAxes, w, e, e_, ee);
02753         compassPoints[i] = toCenter * rot;
02754     }
02755 
02756     glColor(compassColor);
02757     glBegin(GL_LINES);
02758     glDisable(GL_LIGHTING);
02759     for (i = 0; i < nCompassPoints; i++)
02760     {
02761         float distance = (center + compassPoints[i]).distanceFromOrigin();
02762         
02763         float length = distance * pixelSize * 8.0f;
02764         if (i % 4 == 0)
02765             length *= 3.0f;
02766         else if (i % 2 == 0)
02767             length *= 2.0f;
02768         
02769         glVertex(center + compassPoints[i]);
02770         glVertex(center + compassPoints[i] * (1.0f + length));
02771     }
02772     glEnd();
02773 }

static void renderEclipseShadows Model model,
vector< EclipseShadow > &  eclipseShadows,
RenderInfo ri,
float  planetRadius,
Mat4f planetMat,
Frustum viewFrustum,
const GLContext context
[static]
 

Definition at line 4376 of file render.cpp.

References Texture::bind(), EclipseShadow::direction, Point3< T >::distanceFromOrigin(), eclipseShadowTextures, GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_CONSTANT_EXT, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_PREVIOUS_EXT, GL_SOURCE0_RGB_EXT, GL_SOURCE1_RGB_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, glVertex(), Vector3< T >::normalize(), EclipseShadow::origin, EclipseShadow::penumbraRadius, renderShadowedModelDefault(), renderShadowedModelVertexShader(), Matrix4< float >::rotation(), shadowMaskTexture, shadowTex, EclipseShadow::umbraRadius, Vector3< T >::x, Point3< T >::x, Vector3< T >::y, Point3< T >::y, Vector3< T >::z, and Point3< T >::z.

Referenced by Renderer::renderObject().

04383 {
04384     // Eclipse shadows on mesh objects aren't working yet.
04385     if (model != NULL)
04386         return;
04387 
04388     for (vector<EclipseShadow>::iterator iter = eclipseShadows.begin();
04389          iter != eclipseShadows.end(); iter++)
04390     {
04391         EclipseShadow shadow = *iter;
04392 
04393 #ifdef DEBUG_ECLIPSE_SHADOWS
04394         // Eclipse debugging: render the central axis of the eclipse
04395         // shadow volume.
04396         glDisable(GL_TEXTURE_2D);
04397         glColor4f(1, 0, 0, 1);
04398         Point3f blorp = shadow.origin * planetMat;
04399         Vec3f blah = shadow.direction * planetMat;
04400         blorp.x /= planetRadius; blorp.y /= planetRadius; blorp.z /= planetRadius;
04401         float foo = blorp.distanceFromOrigin();
04402         glBegin(GL_LINES);
04403         glVertex(blorp);
04404         glVertex(blorp + foo * blah);
04405         glEnd();
04406         glEnable(GL_TEXTURE_2D);
04407 #endif
04408 
04409         // Determine which eclipse shadow texture to use.  This is only
04410         // a very rough approximation to reality.  Since there are an
04411         // infinite number of possible eclipse volumes, what we should be
04412         // doing is generating the eclipse textures on the fly using
04413         // render-to-texture.  But for now, we'll just choose from a fixed
04414         // set of eclipse shadow textures based on the relative size of
04415         // the umbra and penumbra.
04416         Texture* eclipseTex = NULL;
04417         float umbra = shadow.umbraRadius / shadow.penumbraRadius;
04418         if (umbra < 0.1f)
04419             eclipseTex = eclipseShadowTextures[0];
04420         else if (umbra < 0.35f)
04421             eclipseTex = eclipseShadowTextures[1];
04422         else if (umbra < 0.6f)
04423             eclipseTex = eclipseShadowTextures[2];
04424         else if (umbra < 0.9f)
04425             eclipseTex = eclipseShadowTextures[3];
04426         else
04427             eclipseTex = shadowTex;
04428 
04429         // Compute the transformation to use for generating texture
04430         // coordinates from the object vertices.
04431         Point3f origin = shadow.origin * planetMat;
04432         Vec3f dir = shadow.direction * planetMat;
04433         float scale = planetRadius / shadow.penumbraRadius;
04434         Vec3f axis = Vec3f(0, 1, 0) ^ dir;
04435         float angle = (float) acos(Vec3f(0, 1, 0) * dir);
04436         axis.normalize();
04437         Mat4f mat = Mat4f::rotation(axis, -angle);
04438         Vec3f sAxis = Vec3f(0.5f * scale, 0, 0) * mat;
04439         Vec3f tAxis = Vec3f(0, 0, 0.5f * scale) * mat;
04440 
04441         float sPlane[4] = { 0, 0, 0, 0 };
04442         float tPlane[4] = { 0, 0, 0, 0 };
04443         sPlane[0] = sAxis.x; sPlane[1] = sAxis.y; sPlane[2] = sAxis.z;
04444         tPlane[0] = tAxis.x; tPlane[1] = tAxis.y; tPlane[2] = tAxis.z;
04445         sPlane[3] = (Point3f(0, 0, 0) - origin) * sAxis / planetRadius + 0.5f;
04446         tPlane[3] = (Point3f(0, 0, 0) - origin) * tAxis / planetRadius + 0.5f;
04447 
04448         // TODO: Multiple eclipse shadows should be rendered in a single
04449         // pass using multitexture.
04450         if (eclipseTex != NULL)
04451             eclipseTex->bind();
04452         // shadowMaskTexture->bind();
04453         glEnable(GL_BLEND);
04454         glBlendFunc(GL_ZERO, GL_SRC_COLOR);
04455 
04456         // If the ambient light level is greater than zero, reduce the
04457         // darkness of the shadows.
04458         if (ri.useTexEnvCombine)
04459         {
04460             float color[4] = { ri.ambientColor.red(), ri.ambientColor.green(),
04461                                ri.ambientColor.blue(), 1.0f };
04462             glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
04463             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
04464             glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_CONSTANT_EXT);
04465             glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
04466             glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
04467             glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
04468             glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
04469 
04470             // The second texture unit has the shadow 'mask'
04471             glx::glActiveTextureARB(GL_TEXTURE1_ARB);
04472             glEnable(GL_TEXTURE_2D);
04473             shadowMaskTexture->bind();
04474             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
04475             glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
04476             glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
04477             glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
04478             glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
04479             glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
04480             glx::glActiveTextureARB(GL_TEXTURE0_ARB);
04481         }
04482 
04483         // Since invariance between nVidia's vertex programs and the
04484         // standard transformation pipeline isn't guaranteed, we have to
04485         // make sure to use the same transformation engine on subsequent
04486         // rendering passes as we did on the initial one.
04487         if (context.getVertexPath() != GLContext::VPath_Basic && model == NULL)
04488         {
04489             renderShadowedModelVertexShader(ri, viewFrustum,
04490                                            sPlane, tPlane,
04491                                            dir,
04492                                            context);
04493         }
04494         else
04495         {
04496             renderShadowedModelDefault(model, ri, viewFrustum,
04497                                        sPlane, tPlane,
04498                                        dir,
04499                                        ri.useTexEnvCombine,
04500                                        context);
04501         }
04502 
04503         if (ri.useTexEnvCombine)
04504         {
04505             // Disable second texture unit
04506             glx::glActiveTextureARB(GL_TEXTURE1_ARB);
04507             glDisable(GL_TEXTURE_2D);
04508             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
04509             glx::glActiveTextureARB(GL_TEXTURE0_ARB);
04510 
04511             float color[4] = { 0, 0, 0, 0 };
04512             glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
04513             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
04514         }
04515 
04516         glBlendFunc(GL_SRC_ALPHA, GL_ONE);
04517         glDisable(GL_BLEND);
04518     }
04519 }

static void renderEclipseShadows_Shaders Model model,
vector< EclipseShadow > &  eclipseShadows,
RenderInfo ri,
float  planetRadius,
Mat4f planetMat,
Frustum viewFrustum,
const GLContext context
[static]
 

Definition at line 4523 of file render.cpp.

References Texture::bind(), EclipseShadow::direction, FragmentProcessor::disable(), VertexProcessor::disable(), FragmentProcessor::enable(), VertexProcessor::enable(), lodSphere, Vector3< T >::normalize(), EclipseShadow::origin, VertexProcessor::parameter(), FragmentProcessor::parameter(), penumbraFunctionTexture, EclipseShadow::penumbraRadius, LODSphereMesh::render(), Matrix4< float >::rotation(), EclipseShadow::umbraRadius, FragmentProcessor::use(), VertexProcessor::use(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderObject().

04530 {
04531     // Eclipse shadows on mesh objects aren't working yet.
04532     if (model != NULL)
04533         return;
04534 
04535     glEnable(GL_TEXTURE_2D);
04536     penumbraFunctionTexture->bind();
04537 
04538     glEnable(GL_BLEND);
04539     glBlendFunc(GL_ZERO, GL_SRC_COLOR);
04540 
04541     float sPlanes[4][4];
04542     float tPlanes[4][4];
04543     float shadowParams[4][4];
04544 
04545     int n = 0;
04546     for (vector<EclipseShadow>::iterator iter = eclipseShadows.begin();
04547          iter != eclipseShadows.end() && n < 4; iter++, n++)
04548     {
04549         EclipseShadow shadow = *iter;
04550 
04551         float R2 = 0.25f;
04552         float umbra = shadow.umbraRadius / shadow.penumbraRadius;
04553         umbra = umbra * umbra;
04554         if (umbra < 0.0001f)
04555             umbra = 0.0001f;
04556         else if (umbra > 0.99f)
04557             umbra = 0.99f;
04558 
04559         float umbraRadius = R2 * umbra;
04560         float penumbraRadius = R2;
04561         float shadowBias = 1.0f / (1.0f - penumbraRadius / umbraRadius);
04562         float shadowScale = -shadowBias / umbraRadius;
04563 
04564         shadowParams[n][0] = shadowScale;
04565         shadowParams[n][1] = shadowBias;
04566         shadowParams[n][2] = 0.0f;
04567         shadowParams[n][3] = 0.0f;
04568 
04569         // Compute the transformation to use for generating texture
04570         // coordinates from the object vertices.
04571         Point3f origin = shadow.origin * planetMat;
04572         Vec3f dir = shadow.direction * planetMat;
04573         float scale = planetRadius / shadow.penumbraRadius;
04574         Vec3f axis = Vec3f(0, 1, 0) ^ dir;
04575         float angle = (float) acos(Vec3f(0, 1, 0) * dir);
04576         axis.normalize();
04577         Mat4f mat = Mat4f::rotation(axis, -angle);
04578         Vec3f sAxis = Vec3f(0.5f * scale, 0, 0) * mat;
04579         Vec3f tAxis = Vec3f(0, 0, 0.5f * scale) * mat;
04580 
04581         sPlanes[n][0] = sAxis.x;
04582         sPlanes[n][1] = sAxis.y;
04583         sPlanes[n][2] = sAxis.z;
04584         sPlanes[n][3] = (Point3f(0, 0, 0) - origin) * sAxis / planetRadius + 0.5f;
04585         tPlanes[n][0] = tAxis.x;
04586         tPlanes[n][1] = tAxis.y;
04587         tPlanes[n][2] = tAxis.z;
04588         tPlanes[n][3] = (Point3f(0, 0, 0) - origin) * tAxis / planetRadius + 0.5f;
04589     }
04590 
04591 
04592     VertexProcessor* vproc = context.getVertexProcessor();
04593     FragmentProcessor* fproc = context.getFragmentProcessor();
04594 
04595     vproc->enable();
04596     vproc->use(vp::multiShadow);
04597 
04598     fproc->enable();
04599     if (n == 1)
04600         fproc->use(fp::eclipseShadow1);
04601     else
04602         fproc->use(fp::eclipseShadow2);
04603 
04604     fproc->parameter(fp::ShadowParams0, shadowParams[0]);
04605     vproc->parameter(vp::TexGen_S, sPlanes[0]);
04606     vproc->parameter(vp::TexGen_T, tPlanes[0]);
04607     if (n >= 2)
04608     {
04609         fproc->parameter(fp::ShadowParams1, shadowParams[1]);
04610         vproc->parameter(vp::TexGen_S2, sPlanes[1]);
04611         vproc->parameter(vp::TexGen_T2, tPlanes[1]);
04612     }
04613     if (n >= 3)
04614     {
04615         //fproc->parameter(fp::ShadowParams2, shadowParams[2]);
04616         vproc->parameter(vp::TexGen_S3, sPlanes[2]);
04617         vproc->parameter(vp::TexGen_T3, tPlanes[2]);
04618     }
04619     if (n >= 4)
04620     {
04621         //fproc->parameter(fp::ShadowParams3, shadowParams[3]);
04622         vproc->parameter(vp::TexGen_S4, sPlanes[3]);
04623         vproc->parameter(vp::TexGen_T4, tPlanes[3]);
04624     }
04625 
04626     //vproc->parameter(vp::LightDirection0, lightDir);
04627 
04628     lodSphere->render(context,
04629                       LODSphereMesh::Normals | LODSphereMesh::Multipass,
04630                       viewFrustum,
04631                       ri.pixWidth, NULL);
04632 
04633     vproc->disable();
04634     fproc->disable();
04635 
04636     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
04637     glDisable(GL_BLEND);
04638 }

static void renderModel_GLSL Model Model,
const LightingState ls,
float  radius,
const Mat4f planetMat
[static]
 

Definition at line 3106 of file render.cpp.

03110 {
03111     glDisable(GL_LIGHTING);
03112 }

static void renderModelDefault Model model,
const RenderInfo ri,
bool  lit
[static]
 

Definition at line 3057 of file render.cpp.

References glColor(), RenderContext::lock(), RenderContext::setMaterial(), and RenderContext::setRenderPass().

Referenced by Renderer::renderObject().

03060 {
03061     FixedFunctionRenderContext rc;
03062     //rc.makeCurrent();
03063 
03064     if (lit)
03065         glEnable(GL_LIGHTING);
03066     else
03067         glDisable(GL_LIGHTING);
03068 
03069     if (ri.baseTex == NULL)
03070     {
03071         glDisable(GL_TEXTURE_2D);
03072     }
03073     else
03074     {
03075         glEnable(GL_TEXTURE_2D);
03076         ri.baseTex->bind();
03077     }
03078 
03079     glColor(ri.color);
03080 
03081     if (ri.baseTex != NULL)
03082         rc.lock();
03083 
03084     model->render(rc);
03085     if (model->usesTextureType(Mesh::EmissiveMap))
03086     {
03087         glDisable(GL_LIGHTING);
03088         glEnable(GL_BLEND);
03089         glBlendFunc(GL_ONE, GL_ONE);
03090         rc.setRenderPass(RenderContext::EmissivePass);
03091         rc.setMaterial(NULL);
03092 
03093         model->render(rc);
03094     }
03095 
03096     // Reset the material
03097     float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
03098     float zero = 0.0f;
03099     glColor4fv(black);
03100     glMaterialfv(GL_FRONT, GL_EMISSION, black);
03101     glMaterialfv(GL_FRONT, GL_SPECULAR, black);
03102     glMaterialfv(GL_FRONT, GL_SHININESS, &zero);
03103 }

void renderOrbitColor const Body body,
bool  selected
 

Definition at line 886 of file render.cpp.

Referenced by Renderer::renderForegroundOrbits(), and Renderer::renderOrbits().

00887 {
00888     if (selected)
00889     {
00890         // Highlight the orbit of the selected object in red
00891         glColor4f(1, 0, 0, 1);
00892     }
00893     else
00894     {
00895         switch (body->getClassification())
00896         {
00897         case Body::Moon:
00898             glColor4f(0.0f, 0.2f, 0.5f, 1.0f);
00899             break;
00900         case Body::Asteroid:
00901             glColor4f(0.35f, 0.2f, 0.0f, 1.0f);
00902             break;
00903         case Body::Comet:
00904             glColor4f(0.0f, 0.5f, 0.5f, 1.0f);
00905             break;
00906         case Body::Spacecraft:
00907             glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
00908             break;
00909         case Body::Planet:
00910         default:
00911             glColor4f(0.0f, 0.4f, 1.0f, 1.0f);
00912             break;
00913         }
00914     }
00915 }

static void renderRings RingSystem rings,
RenderInfo ri,
float  planetRadius,
float  planetOblateness,
unsigned int  textureResolution,
bool  renderShadow,
const GLContext context,
unsigned int  nSections
[static]
 

Definition at line 4043 of file render.cpp.

References Texture::bind(), VertexProcessor::disable(), FragmentProcessor::disable(), FragmentProcessor::enable(), VertexProcessor::enable(), GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, glAmbientLightColor(), Vector3< T >::normalize(), FragmentProcessor::parameter(), VertexProcessor::parameter(), PI, renderRingSystem(), shadowTex, ShadowTextureScale, sqrt(), square(), FragmentProcessor::use(), VertexProcessor::use(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderObject().

04051 {
04052     float inner = rings.innerRadius / planetRadius;
04053     float outer = rings.outerRadius / planetRadius;
04054 
04055     // Ring Illumination:
04056     // Since a ring system is composed of millions of individual
04057     // particles, it's not at all realistic to model it as a flat
04058     // Lambertian surface.  We'll approximate the llumination
04059     // function by assuming that the ring system contains Lambertian
04060     // particles, and that the brightness at some point in the ring
04061     // system is proportional to the illuminated fraction of a
04062     // particle there.  In fact, we'll simplify things further and
04063     // set the illumination of the entire ring system to the same
04064     // value, computing the illuminated fraction of a hypothetical
04065     // particle located at the center of the planet.  This
04066     // approximation breaks down when you get close to the planet.
04067     float ringIllumination = 0.0f;
04068     {
04069         float illumFraction = (1.0f + ri.eyeDir_obj * ri.sunDir_obj) / 2.0f;
04070         // Just use the illuminated fraction for now . . .
04071         ringIllumination = illumFraction;
04072     }
04073 
04074     GLContext::VertexPath vpath = context.getVertexPath();
04075     VertexProcessor* vproc = context.getVertexProcessor();
04076     FragmentProcessor* fproc = context.getFragmentProcessor();
04077 
04078     if (vproc != NULL)
04079     {
04080         vproc->enable();
04081         vproc->use(vp::ringIllum);
04082         vproc->parameter(vp::LightDirection0, ri.sunDir_obj);
04083         vproc->parameter(vp::DiffuseColor0, ri.sunColor * rings.color);
04084         vproc->parameter(vp::AmbientColor, ri.ambientColor * ri.color);
04085         vproc->parameter(vp::Constant0, Vec3f(0, 0.5, 1.0));
04086     }
04087 
04088     // If we have multi-texture support, we'll use the second texture unit
04089     // to render the shadow of the planet on the rings.  This is a bit of
04090     // a hack, and assumes that the planet is ellipsoidal in shape,
04091     // and only works for a planet illuminated by a single sun where the
04092     // distance to the sun is very large relative to its diameter.
04093     if (renderShadow)
04094     {
04095         glx::glActiveTextureARB(GL_TEXTURE1_ARB);
04096         glEnable(GL_TEXTURE_2D);
04097         shadowTex->bind();
04098 
04099         float sPlane[4] = { 0, 0, 0, 0.5f };
04100         float tPlane[4] = { 0, 0, 0, 0.5f };
04101 
04102         // Compute the projection vectors based on the sun direction.
04103         // I'm being a little careless here--if the sun direction lies
04104         // along the y-axis, this will fail.  It's unlikely that a
04105         // planet would ever orbit underneath its sun (an orbital
04106         // inclination of 90 degrees), but this should be made
04107         // more robust anyway.
04108         Vec3f axis = Vec3f(0, 1, 0) ^ ri.sunDir_obj;
04109         float cosAngle = Vec3f(0.0f, 1.0f, 0.0f) * ri.sunDir_obj;
04110         float angle = (float) acos(cosAngle);
04111         axis.normalize();
04112 
04113         float sScale = 1.0f;
04114         float tScale = 1.0f;
04115         if (fproc == NULL)
04116         {
04117             // When fragment programs aren't used, we render shadows with circular
04118             // textures.  We scale up the texture slightly to account for the
04119             // padding pixels near the texture borders.
04120             sScale *= ShadowTextureScale;
04121             tScale *= ShadowTextureScale;
04122         }
04123 
04124         if (planetOblateness != 0.0f)
04125         {
04126             // For oblate planets, the size of the shadow volume will vary based
04127             // on the light direction.
04128 
04129             // A vertical slice of the planet is an ellipse
04130             float a = 1.0f;                          // semimajor axis
04131             float b = a * (1.0f - planetOblateness); // semiminor axis
04132             float ecc2 = 1.0f - (b * b) / (a * a);   // square of eccentricity
04133 
04134             // Calculate the radius of the ellipse at the incident angle of the
04135             // light on the ring plane + 90 degrees.
04136             float r = a * (float) sqrt((1.0f - ecc2) /
04137                                        (1.0f - ecc2 * square(cosAngle)));
04138             
04139             tScale *= a / r;
04140         }
04141 
04142         // The s axis is perpendicular to the shadow axis in the plane of the
04143         // of the rings, and the t axis completes the orthonormal basis.
04144         Vec3f sAxis = axis * 0.5f;
04145         Vec3f tAxis = (axis ^ ri.sunDir_obj) * 0.5f * tScale;
04146 
04147         sPlane[0] = sAxis.x; sPlane[1] = sAxis.y; sPlane[2] = sAxis.z;
04148         tPlane[0] = tAxis.x; tPlane[1] = tAxis.y; tPlane[2] = tAxis.z;
04149 
04150         if (vproc != NULL)
04151         {
04152             vproc->parameter(vp::TexGen_S, sPlane);
04153             vproc->parameter(vp::TexGen_T, tPlane);
04154         }
04155         else
04156         {
04157             glEnable(GL_TEXTURE_GEN_S);
04158             glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
04159             glTexGenfv(GL_S, GL_EYE_PLANE, sPlane);
04160             glEnable(GL_TEXTURE_GEN_T);
04161             glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
04162             glTexGenfv(GL_T, GL_EYE_PLANE, tPlane);
04163         }
04164 
04165         glx::glActiveTextureARB(GL_TEXTURE0_ARB);
04166 
04167         if (fproc != NULL)
04168         {
04169             float r0 = 0.24f;
04170             float r1 = 0.25f;
04171             float bias = 1.0f / (1.0f - r1 / r0);
04172             float scale = -bias / r0;
04173 
04174             fproc->enable();
04175             fproc->use(fp::sphereShadowOnRings);
04176             fproc->parameter(fp::ShadowParams0, scale, bias, 0.0f, 0.0f);
04177             fproc->parameter(fp::AmbientColor, ri.ambientColor * ri.color);
04178         }
04179     }
04180 
04181     glEnable(GL_BLEND);
04182     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
04183 
04184     Texture* ringsTex = rings.texture.find(textureResolution);
04185 
04186     if (ringsTex != NULL)
04187         ringsTex->bind();
04188     else
04189         glDisable(GL_TEXTURE_2D);
04190         
04191     // Perform our own lighting for the rings.
04192     // TODO: Don't forget about light source color (required when we
04193     // paying attention to star color.)
04194     if (vpath == GLContext::VPath_Basic)
04195     {
04196         glDisable(GL_LIGHTING);
04197         Vec3f litColor(rings.color.red(), rings.color.green(), rings.color.blue());
04198         litColor = litColor * ringIllumination +
04199             Vec3f(ri.ambientColor.red(), ri.ambientColor.green(),
04200                   ri.ambientColor.blue());
04201         glColor4f(litColor.x, litColor.y, litColor.z, 1.0f);
04202     }
04203 
04204     // This gets tricky . . .  we render the rings in two parts.  One
04205     // part is potentially shadowed by the planet, and we need to
04206     // render that part with the projected shadow texture enabled.
04207     // The other part isn't shadowed, but will appear so if we don't
04208     // first disable the shadow texture.  The problem is that the
04209     // shadow texture will affect anything along the line between the
04210     // sun and the planet, regardless of whether it's in front or
04211     // behind the planet.
04212 
04213     // Compute the angle of the sun projected on the ring plane
04214     float sunAngle = (float) atan2(ri.sunDir_obj.z, ri.sunDir_obj.x);
04215 
04216     // If there's a fragment program, it will handle the ambient term--make
04217     // sure that we don't add it both in the fragment and vertex programs.
04218     if (vproc != NULL && fproc != NULL)
04219         glAmbientLightColor(Color::Black);
04220 
04221     renderRingSystem(inner, outer,
04222                      (float) (sunAngle + PI / 2),
04223                      (float) (sunAngle + 3 * PI / 2),
04224                      nSections / 2);
04225     renderRingSystem(inner, outer,
04226                      (float) (sunAngle +  3 * PI / 2),
04227                      (float) (sunAngle + PI / 2),
04228                      nSections / 2);
04229 
04230     if (vproc != NULL && fproc != NULL)
04231         glAmbientLightColor(ri.ambientColor * ri.color);
04232 
04233     // Disable the second texture unit if it was used
04234     if (renderShadow)
04235     {
04236         glx::glActiveTextureARB(GL_TEXTURE1_ARB);
04237         glDisable(GL_TEXTURE_2D);
04238         glDisable(GL_TEXTURE_GEN_S);
04239         glDisable(GL_TEXTURE_GEN_T);
04240         glx::glActiveTextureARB(GL_TEXTURE0_ARB);
04241 
04242         if (fproc != NULL)
04243             fproc->disable();
04244     }
04245 
04246     // Render the unshadowed side
04247     renderRingSystem(inner, outer,
04248                      (float) (sunAngle - PI / 2),
04249                      (float) (sunAngle + PI / 2),
04250                      nSections / 2);
04251     renderRingSystem(inner, outer,
04252                      (float) (sunAngle + PI / 2),
04253                      (float) (sunAngle - PI / 2),
04254                      nSections / 2);
04255     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
04256 
04257     if (vproc != NULL)
04258         vproc->disable();
04259 }

static void renderRings_GLSL RingSystem rings,
RenderInfo ri,
const LightingState ls,
float  planetRadius,
float  planetOblateness,
unsigned int  textureResolution,
bool  renderShadow,
unsigned int  nSections
[static]
 

Definition at line 4262 of file render.cpp.

References CelestiaGLProgram::ambientColor, CelestiaGLProgramShadow::bias, Texture::bind(), DirectionalLight::direction_obj, CelestiaGLProgram::eyePosition, ShaderManager::getShader(), GetShaderManager(), glx::glUseProgramObjectARB, ShaderProperties::lightModel, min, ShaderProperties::nLights, Vector3< T >::normalize(), PI, renderRingSystem(), CelestiaGLProgramShadow::scale, setLightParameters_GLSL(), ShaderProperties::setShadowCountForLight(), CelestiaGLProgram::shadows, sqrt(), square(), CelestiaGLProgramShadow::texGenS, CelestiaGLProgramShadow::texGenT, ShaderProperties::texUsage, CelestiaGLProgram::use(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderObject().

04270 {
04271     float inner = rings.innerRadius / planetRadius;
04272     float outer = rings.outerRadius / planetRadius;
04273     Texture* ringsTex = rings.texture.find(textureResolution);
04274 
04275     ShaderProperties shadprop;
04276     // Set up the shader properties for ring rendering
04277     {
04278         shadprop.lightModel = ShaderProperties::RingIllumModel;
04279         shadprop.nLights = min(ls.nLights, MaxShaderLights);
04280 
04281         if (renderShadow)
04282         {
04283             // Set one shadow (the planet's) per light
04284             for (unsigned int li = 0; li < ls.nLights; li++)
04285                 shadprop.setShadowCountForLight(li, 1);
04286         }
04287 
04288         if (ringsTex)
04289             shadprop.texUsage = ShaderProperties::DiffuseTexture;
04290     }
04291             
04292 
04293     // Get a shader for the current rendering configuration
04294     CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
04295     if (prog == NULL)
04296         return;
04297 
04298     prog->use();
04299 
04300     prog->eyePosition = ls.eyePos_obj;
04301     prog->ambientColor = Vec3f(ri.ambientColor.red(), ri.ambientColor.green(),
04302                                ri.ambientColor.blue());
04303     setLightParameters_GLSL(*prog, shadprop, ls,
04304                             ri.color, ri.specularColor);
04305         
04306     for (unsigned int li = 0; li < ls.nLights; li++)
04307     {
04308         const DirectionalLight& light = ls.lights[li];
04309 
04310         // Compute the projection vectors based on the sun direction.
04311         // I'm being a little careless here--if the sun direction lies
04312         // along the y-axis, this will fail.  It's unlikely that a
04313         // planet would ever orbit underneath its sun (an orbital
04314         // inclination of 90 degrees), but this should be made
04315         // more robust anyway.
04316         Vec3f axis = Vec3f(0, 1, 0) ^ light.direction_obj;
04317         float cosAngle = Vec3f(0.0f, 1.0f, 0.0f) * light.direction_obj;
04318         float angle = (float) acos(cosAngle);
04319         axis.normalize();
04320 
04321         float tScale = 1.0f;
04322         if (planetOblateness != 0.0f)
04323         {
04324             // For oblate planets, the size of the shadow volume will vary
04325             // based on the light direction.
04326 
04327             // A vertical slice of the planet is an ellipse
04328             float a = 1.0f;                          // semimajor axis
04329             float b = a * (1.0f - planetOblateness); // semiminor axis
04330             float ecc2 = 1.0f - (b * b) / (a * a);   // square of eccentricity
04331 
04332             // Calculate the radius of the ellipse at the incident angle of the
04333             // light on the ring plane + 90 degrees.
04334             float r = a * (float) sqrt((1.0f - ecc2) /
04335                                        (1.0f - ecc2 * square(cosAngle)));
04336             
04337             tScale *= a / r;
04338         }
04339 
04340         // The s axis is perpendicular to the shadow axis in the plane of the
04341         // of the rings, and the t axis completes the orthonormal basis.
04342         Vec3f sAxis = axis * 0.5f;
04343         Vec3f tAxis = (axis ^ light.direction_obj) * 0.5f * tScale;
04344         Vec4f texGenS(sAxis.x, sAxis.y, sAxis.z, 0.5f);
04345         Vec4f texGenT(tAxis.x, tAxis.y, tAxis.z, 0.5f);
04346 
04347         float r0 = 0.24f;
04348         float r1 = 0.25f;
04349         float bias = 1.0f / (1.0f - r1 / r0);
04350         float scale = -bias / r0;
04351 
04352         prog->shadows[li][0].texGenS = texGenS;
04353         prog->shadows[li][0].texGenT = texGenT;
04354         prog->shadows[li][0].bias = bias;
04355         prog->shadows[li][0].scale = -bias / r0;
04356     }
04357 
04358     glEnable(GL_BLEND);
04359     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
04360 
04361     if (ringsTex != NULL)
04362         ringsTex->bind();
04363     else
04364         glDisable(GL_TEXTURE_2D);
04365         
04366     renderRingSystem(inner, outer, 0, (float) PI * 2.0f, nSections);
04367     renderRingSystem(inner, outer, (float) PI * 2.0f, 0, nSections);
04368 
04369     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
04370 
04371     glx::glUseProgramObjectARB(0);
04372 }

static void renderRingShadowsVS Model model,
const RingSystem rings,
const Vec3f sunDir,
RenderInfo ri,
float  planetRadius,
float  oblateness,
Mat4f planetMat,
Frustum viewFrustum,
const GLContext context
[static]
 

Definition at line 4642 of file render.cpp.

References abs(), VertexProcessor::disable(), VertexProcessor::enable(), GL_CLAMP_TO_BORDER_ARB, GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_CONSTANT_EXT, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_SOURCE0_RGB_EXT, GL_SOURCE1_RGB_EXT, lodSphere, VertexProcessor::parameter(), LODSphereMesh::render(), and VertexProcessor::use().

Referenced by Renderer::renderObject().

04651 {
04652     // Compute the transformation to use for generating texture
04653     // coordinates from the object vertices.
04654     float ringWidth = rings.outerRadius - rings.innerRadius;
04655     float s = ri.sunDir_obj.y;
04656     float scale = (abs(s) < 0.001f) ? 1000.0f : 1.0f / s;
04657 
04658     if (abs(s) > 1.0f - 1.0e-4f)
04659     {
04660         // Planet is illuminated almost directly from above, so
04661         // no ring shadow will be cast on the planet.  Conveniently
04662         // avoids some potential division by zero when ray-casting.
04663         return;
04664     }
04665 
04666     glEnable(GL_BLEND);
04667     glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
04668 
04669     // If the ambient light level is greater than zero, reduce the
04670     // darkness of the shadows.
04671     float color[4] = { ri.ambientColor.red(), ri.ambientColor.green(),
04672                        ri.ambientColor.blue(), 1.0f };
04673     glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
04674     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
04675     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_CONSTANT_EXT);
04676     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
04677     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
04678     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
04679     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
04680 
04681     // Tweak the texture--set clamp to border and a border color with
04682     // a zero alpha.  If a graphics card doesn't support clamp to border,
04683     // it doesn't get to play.  It's possible to get reasonable behavior
04684     // by turning off mipmaps and assuming transparent rows of pixels for
04685     // the top and bottom of the ring textures . . . maybe later.
04686     float bc[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
04687     glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bc);
04688     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER_ARB);
04689 
04690     // Ring shadows look strange if they're always completely black.  Vary
04691     // the darkness of the shadow based on the angle between the sun and the
04692     // ring plane.  There's some justification for this--the larger the angle
04693     // between the sun and the ring plane (normal), the more ring material
04694     // there is to travel through.
04695     //float alpha = (1.0f - abs(ri.sunDir_obj.y)) * 1.0f;
04696     // ...but, images from Cassini are showing very dark ring shadows, so we'll
04697     // go with that.
04698     float alpha = 1.0f;
04699 
04700     VertexProcessor* vproc = context.getVertexProcessor();
04701     assert(vproc != NULL);
04702 
04703     vproc->enable();
04704     vproc->use(vp::ringShadow);
04705     vproc->parameter(vp::LightDirection0, ri.sunDir_obj);
04706     vproc->parameter(vp::DiffuseColor0, 1, 1, 1, alpha); // color = white
04707     vproc->parameter(vp::TexGen_S,
04708                      rings.innerRadius / planetRadius,
04709                      1.0f / (ringWidth / planetRadius),
04710                      0.0f, 0.5f);
04711     vproc->parameter(vp::TexGen_T, scale, 0, 0, 0);
04712     lodSphere->render(context, LODSphereMesh::Multipass,
04713                       viewFrustum, ri.pixWidth, NULL);
04714     vproc->disable();
04715 
04716     // Restore the texture combiners
04717     if (ri.useTexEnvCombine)
04718     {
04719         float color[4] = { 0, 0, 0, 0 };
04720         glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
04721         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
04722     }
04723 
04724     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
04725     glDisable(GL_BLEND);
04726 }

static void renderRingSystem float  innerRadius,
float  outerRadius,
float  beginAngle,
float  endAngle,
unsigned int  nSections
[static]
 

Definition at line 1885 of file render.cpp.

References cos(), and sin().

Referenced by renderRings(), and renderRings_GLSL().

01890 {
01891     float angle = endAngle - beginAngle;
01892 
01893     glBegin(GL_QUAD_STRIP);
01894     for (unsigned int i = 0; i <= nSections; i++)
01895     {
01896         float t = (float) i / (float) nSections;
01897         float theta = beginAngle + t * angle;
01898         float s = (float) sin(theta);
01899         float c = (float) cos(theta);
01900         glTexCoord2f(0, 0.5f);
01901         glVertex3f(c * innerRadius, 0, s * innerRadius);
01902         glTexCoord2f(1, 0.5f);
01903         glVertex3f(c * outerRadius, 0, s * outerRadius);
01904     }
01905     glEnd();
01906 }

static void renderShadowedModelDefault Model model,
const RenderInfo ri,
const Frustum frustum,
float *  sPlane,
float *  tPlane,
const Vec3f lightDir,
bool  useShadowMask,
const GLContext context
[static]
 

Definition at line 3966 of file render.cpp.

References GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, lodSphere, LODSphereMesh::render(), and texGenPlane().

Referenced by renderEclipseShadows().

03974 {
03975     glEnable(GL_TEXTURE_GEN_S);
03976     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
03977     glTexGenfv(GL_S, GL_OBJECT_PLANE, sPlane);
03978     //texGenPlane(GL_S, GL_OBJECT_PLANE, sPlane);
03979     glEnable(GL_TEXTURE_GEN_T);
03980     glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
03981     glTexGenfv(GL_T, GL_OBJECT_PLANE, tPlane);
03982 
03983     if (useShadowMask)
03984     {
03985         glx::glActiveTextureARB(GL_TEXTURE1_ARB);
03986         glEnable(GL_TEXTURE_GEN_S);
03987         glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
03988         texGenPlane(GL_S, GL_OBJECT_PLANE,
03989                     Vec4f(lightDir.x, lightDir.y, lightDir.z, 0.5f));
03990         glx::glActiveTextureARB(GL_TEXTURE0_ARB);
03991     }
03992 
03993     glColor4f(1, 1, 1, 1);
03994     glDisable(GL_LIGHTING);
03995 
03996     if (model == NULL)
03997     {
03998         lodSphere->render(context,
03999                           LODSphereMesh::Normals | LODSphereMesh::Multipass,
04000                           frustum, ri.pixWidth, NULL);
04001     }
04002     else
04003     {
04004         FixedFunctionRenderContext rc;
04005         model->render(rc);
04006     }
04007     glEnable(GL_LIGHTING);
04008 
04009     if (useShadowMask)
04010     {
04011         glx::glActiveTextureARB(GL_TEXTURE1_ARB);
04012         glDisable(GL_TEXTURE_GEN_S);
04013         glx::glActiveTextureARB(GL_TEXTURE0_ARB);
04014     }
04015     glDisable(GL_TEXTURE_GEN_S);
04016     glDisable(GL_TEXTURE_GEN_T);
04017 }

static void renderShadowedModelVertexShader const RenderInfo ri,
const Frustum frustum,
float *  sPlane,
float *  tPlane,
Vec3f lightDir,
const GLContext context
[static]
 

Definition at line 4020 of file render.cpp.

References VertexProcessor::disable(), VertexProcessor::enable(), lodSphere, VertexProcessor::parameter(), LODSphereMesh::render(), and VertexProcessor::use().

Referenced by renderEclipseShadows().

04025 {
04026     VertexProcessor* vproc = context.getVertexProcessor();
04027     assert(vproc != NULL);
04028 
04029     vproc->enable();
04030     vproc->parameter(vp::LightDirection0, lightDir);
04031     vproc->parameter(vp::TexGen_S, sPlane);
04032     vproc->parameter(vp::TexGen_T, tPlane);
04033     vproc->use(vp::shadowTexture);
04034 
04035     lodSphere->render(context,
04036                       LODSphereMesh::Normals | LODSphereMesh::Multipass, frustum,
04037                       ri.pixWidth, NULL);
04038 
04039     vproc->disable();
04040 }

static void renderSmoothMesh const GLContext context,
Texture baseTexture,
Vec3f  lightDirection,
Quatf  orientation,
Color  ambientColor,
float  lod,
const Frustum frustum,
bool  invert = false
[static]
 

Definition at line 2116 of file render.cpp.

References DisableCombiners(), GL_NORMAL_MAP_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, glRotate(), lodSphere, normalizationTex, Vector3< T >::normalize(), PI, LODSphereMesh::render(), Quaternion< T >::setAxisAngle(), and SetupCombinersSmooth().

Referenced by renderSphere_Combiners().

02124 {
02125     Texture* textures[4];
02126 
02127     // We're doing our own per-pixel lighting, so disable GL's lighting
02128     glDisable(GL_LIGHTING);
02129 
02130     // The 'default' light vector for the bump map is (0, 0, 1).  Determine
02131     // a rotation transformation that will move the sun direction to
02132     // this vector.
02133     Quatf lightOrientation;
02134     {
02135         Vec3f zeroLightDirection(0, 0, 1);
02136         Vec3f axis = lightDirection ^ zeroLightDirection;
02137         float cosAngle = zeroLightDirection * lightDirection;
02138         float angle = 0.0f;
02139         float epsilon = 1e-5f;
02140 
02141         if (cosAngle + 1 < epsilon)
02142         {
02143             axis = Vec3f(0, 1, 0);
02144             angle = (float) PI;
02145         }
02146         else if (cosAngle - 1 > -epsilon)
02147         {
02148             axis = Vec3f(0, 1, 0);
02149             angle = 0.0f;
02150         }
02151         else
02152         {
02153             axis.normalize();
02154             angle = (float) acos(cosAngle);
02155         }
02156         lightOrientation.setAxisAngle(axis, angle);
02157     }
02158 
02159     SetupCombinersSmooth(baseTexture, *normalizationTex, ambientColor, invert);
02160 
02161     // The second set texture coordinates will contain the light
02162     // direction in tangent space.  We'll generate the texture coordinates
02163     // from the surface normals using GL_NORMAL_MAP_EXT and then
02164     // use the texture matrix to rotate them into tangent space.
02165     // This method of generating tangent space light direction vectors
02166     // isn't as general as transforming the light direction by an
02167     // orthonormal basis for each mesh vertex, but it works well enough
02168     // for spheres illuminated by directional light sources.
02169     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02170 
02171     // Set up GL_NORMAL_MAP_EXT texture coordinate generation.  This
02172     // mode is part of the cube map extension.
02173     glEnable(GL_TEXTURE_GEN_R);
02174     glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02175     glEnable(GL_TEXTURE_GEN_S);
02176     glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02177     glEnable(GL_TEXTURE_GEN_T);
02178     glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_NORMAL_MAP_EXT);
02179 
02180     // Set up the texture transformation--the light direction and the
02181     // viewer orientation both need to be considered.
02182     glMatrixMode(GL_TEXTURE);
02183     glRotate(lightOrientation * ~orientation);
02184     glMatrixMode(GL_MODELVIEW);
02185     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02186 
02187     textures[0] = &baseTexture;
02188     lodSphere->render(context,
02189                       LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
02190                       frustum, lod,
02191                       textures, 1);
02192 
02193     // Reset the second texture unit
02194     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02195     glMatrixMode(GL_TEXTURE);
02196     glLoadIdentity();
02197     glMatrixMode(GL_MODELVIEW);
02198     glDisable(GL_TEXTURE_GEN_R);
02199     glDisable(GL_TEXTURE_GEN_S);
02200     glDisable(GL_TEXTURE_GEN_T);
02201 
02202     DisableCombiners();
02203 }

static void renderSphere_Combiners const RenderInfo ri,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3172 of file render.cpp.

References glColor(), lodSphere, LODSphereMesh::render(), renderBumpMappedMesh(), and renderSmoothMesh().

Referenced by Renderer::renderObject().

03175 {
03176     glDisable(GL_LIGHTING);
03177 
03178     if (ri.baseTex == NULL)
03179     {
03180         glDisable(GL_TEXTURE_2D);
03181     }
03182     else
03183     {
03184         glEnable(GL_TEXTURE_2D);
03185         ri.baseTex->bind();
03186     }
03187 
03188     glColor(ri.color * ri.sunColor);
03189 
03190     if (ri.bumpTex != NULL)
03191     {
03192         renderBumpMappedMesh(context,
03193                              *(ri.baseTex),
03194                              *(ri.bumpTex),
03195                              ri.sunDir_eye,
03196                              ri.orientation,
03197                              ri.ambientColor,
03198                              frustum,
03199                              ri.pixWidth);
03200     }
03201     else if (ri.baseTex != NULL)
03202     {
03203         renderSmoothMesh(context,
03204                          *(ri.baseTex),
03205                          ri.sunDir_eye,
03206                          ri.orientation,
03207                          ri.ambientColor,
03208                          ri.pixWidth,
03209                          frustum);
03210     }
03211     else
03212     {
03213         glEnable(GL_LIGHTING);
03214         lodSphere->render(context, frustum, ri.pixWidth, NULL, 0);
03215     }
03216 
03217     if (ri.nightTex != NULL)
03218     {
03219         ri.nightTex->bind();
03220         glEnable(GL_BLEND);
03221         glBlendFunc(GL_ONE, GL_ONE);
03222         renderSmoothMesh(context,
03223                          *(ri.nightTex),
03224                          ri.sunDir_eye, 
03225                          ri.orientation,
03226                          Color::Black,
03227                          ri.pixWidth,
03228                          frustum,
03229                          true);
03230     }
03231 
03232     if (ri.overlayTex != NULL)
03233     {
03234         glEnable(GL_LIGHTING);
03235         ri.overlayTex->bind();
03236         glEnable(GL_BLEND);
03237         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
03238         lodSphere->render(context,
03239                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0, 
03240                           frustum, ri.pixWidth,
03241                           ri.overlayTex);
03242 #if 0
03243         renderSmoothMesh(context,
03244                          *(ri.overlayTex),
03245                          ri.sunDir_eye,
03246                          ri.orientation,
03247                          ri.ambientColor,
03248                          ri.pixWidth,
03249                          frustum);
03250 #endif
03251         glBlendFunc(GL_ONE, GL_ONE);
03252     }
03253 
03254     glBlendFunc(GL_SRC_ALPHA, GL_ONE);
03255 }

static void renderSphere_Combiners_VP const RenderInfo ri,
const LightingState ls,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3400 of file render.cpp.

References buggyVertexProgramEmulation, VertexProcessor::disable(), DisableCombiners(), VertexProcessor::enable(), GL_COLOR_SUM_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, lodSphere, VertexProcessor::parameter(), LODSphereMesh::render(), setLightParameters_VP(), SetupCombinersDecalAndBumpMap(), SetupCombinersGlossMap(), SetupCombinersGlossMapWithFog(), setupNightTextureCombine(), and VertexProcessor::use().

Referenced by Renderer::renderObject().

03404 {
03405     Texture* textures[4];
03406     VertexProcessor* vproc = context.getVertexProcessor();
03407     assert(vproc != NULL);
03408 
03409     if (ri.baseTex == NULL)
03410     {
03411         glDisable(GL_TEXTURE_2D);
03412     }
03413     else
03414     {
03415         glEnable(GL_TEXTURE_2D);
03416         ri.baseTex->bind();
03417     }
03418 
03419     // Set up the fog parameters if the haze density is non-zero
03420     float hazeDensity = ri.hazeColor.alpha();
03421 
03422     if (hazeDensity > 0.0f && !buggyVertexProgramEmulation)
03423     {
03424         glEnable(GL_FOG);
03425         float fogColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
03426         fogColor[0] = ri.hazeColor.red();
03427         fogColor[1] = ri.hazeColor.green();
03428         fogColor[2] = ri.hazeColor.blue();
03429         glFogfv(GL_FOG_COLOR, fogColor);
03430         glFogi(GL_FOG_MODE, GL_LINEAR);
03431         glFogf(GL_FOG_START, 0.0);
03432         glFogf(GL_FOG_END, 1.0f / hazeDensity);
03433     }
03434 
03435     vproc->enable();
03436 
03437     vproc->parameter(vp::EyePosition, ri.eyePos_obj);
03438     setLightParameters_VP(*vproc, ls, ri.color, ri.specularColor);
03439 
03440     vproc->parameter(vp::SpecularExponent, 0.0f, 1.0f, 0.5f, ri.specularPower);
03441     vproc->parameter(vp::AmbientColor, ri.ambientColor * ri.color);
03442     vproc->parameter(vp::HazeColor, ri.hazeColor);
03443 
03444     if (ri.bumpTex != NULL)
03445     {
03446         if (hazeDensity > 0.0f)
03447             vproc->use(vp::diffuseBumpHaze);
03448         else
03449             vproc->use(vp::diffuseBump);
03450         SetupCombinersDecalAndBumpMap(*(ri.bumpTex),
03451                                       ri.ambientColor * ri.color,
03452                                       ri.sunColor * ri.color);
03453         lodSphere->render(context,
03454                           LODSphereMesh::Normals | LODSphereMesh::Tangents |
03455                           LODSphereMesh::TexCoords0 | LODSphereMesh::VertexProgParams,
03456                           frustum, ri.pixWidth,
03457                           ri.baseTex, ri.bumpTex);
03458         DisableCombiners();
03459 
03460         // Render a specular pass
03461         if (ri.specularColor != Color::Black)
03462         {
03463             glEnable(GL_BLEND);
03464             glBlendFunc(GL_ONE, GL_ONE);
03465             glEnable(GL_COLOR_SUM_EXT);
03466             vproc->use(vp::specular);
03467 
03468             // Disable ambient and diffuse
03469             vproc->parameter(vp::AmbientColor, Color::Black);
03470             vproc->parameter(vp::DiffuseColor0, Color::Black);
03471             SetupCombinersGlossMap(ri.glossTex != NULL ? GL_TEXTURE0_ARB : 0);
03472 
03473             textures[0] = ri.glossTex != NULL ? ri.glossTex : ri.baseTex;
03474             lodSphere->render(context,
03475                               LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03476                               frustum, ri.pixWidth,
03477                               textures, 1);
03478 
03479             // re-enable diffuse
03480             vproc->parameter(vp::DiffuseColor0, ri.sunColor * ri.color);
03481 
03482             DisableCombiners();
03483             glDisable(GL_COLOR_SUM_EXT);
03484             glDisable(GL_BLEND);
03485         }
03486     }
03487     else if (ri.specularColor != Color::Black)
03488     {
03489         glEnable(GL_COLOR_SUM_EXT);
03490         if (ls.nLights > 1)
03491             vproc->use(vp::specular_2light);
03492         else
03493             vproc->use(vp::specular);
03494         SetupCombinersGlossMapWithFog(ri.glossTex != NULL ? GL_TEXTURE1_ARB : 0);
03495         unsigned int attributes = LODSphereMesh::Normals | LODSphereMesh::TexCoords0 |
03496             LODSphereMesh::VertexProgParams;
03497         lodSphere->render(context,
03498                           attributes, frustum, ri.pixWidth,
03499                           ri.baseTex, ri.glossTex);
03500         DisableCombiners();
03501         glDisable(GL_COLOR_SUM_EXT);
03502     }
03503     else
03504     {
03505         if (ls.nLights > 1)
03506         {
03507             if (hazeDensity > 0.0f)
03508                 vproc->use(vp::diffuseHaze_2light);
03509             else
03510                 vproc->use(vp::diffuse_2light);
03511         }
03512         else
03513         {
03514             if (hazeDensity > 0.0f)
03515                 vproc->use(vp::diffuseHaze);
03516             else
03517                 vproc->use(vp::diffuse);
03518         }
03519 
03520         lodSphere->render(context,
03521                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0 |
03522                           LODSphereMesh::VertexProgParams,
03523                           frustum, ri.pixWidth,
03524                           ri.baseTex);
03525     }
03526 
03527     if (hazeDensity > 0.0f)
03528         glDisable(GL_FOG);
03529 
03530     if (ri.nightTex != NULL)
03531     {
03532         ri.nightTex->bind();
03533         if (ls.nLights > 1)
03534             vproc->use(vp::nightLights_2light);
03535         else
03536             vproc->use(vp::nightLights);
03537         setupNightTextureCombine();
03538         glEnable(GL_BLEND);
03539         glBlendFunc(GL_ONE, GL_ONE);
03540         lodSphere->render(context,
03541                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03542                           frustum, ri.pixWidth,
03543                           ri.nightTex);
03544         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03545     }
03546 
03547     if (ri.overlayTex != NULL)
03548     {
03549         ri.overlayTex->bind();
03550         vproc->use(vp::diffuse);
03551         glEnable(GL_BLEND);
03552         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
03553         lodSphere->render(context,
03554                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03555                           frustum, ri.pixWidth,
03556                           ri.overlayTex);
03557         glBlendFunc(GL_ONE, GL_ONE);
03558     }
03559 
03560     vproc->disable();
03561 }

static void renderSphere_DOT3_VP const RenderInfo ri,
const LightingState ls,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3258 of file render.cpp.

References VertexProcessor::disable(), VertexProcessor::enable(), GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, glx::glActiveTextureARB, lodSphere, VertexProcessor::parameter(), LODSphereMesh::render(), setLightParameters_VP(), setupBumpTexenv(), setupNightTextureCombine(), setupTexenvAmbient(), setupTexenvGlossMapAlpha(), and VertexProcessor::use().

Referenced by Renderer::renderObject().

03262 {
03263     VertexProcessor* vproc = context.getVertexProcessor();
03264     assert(vproc != NULL);
03265 
03266     if (ri.baseTex == NULL)
03267     {
03268         glDisable(GL_TEXTURE_2D);
03269     }
03270     else
03271     {
03272         glEnable(GL_TEXTURE_2D);
03273         ri.baseTex->bind();
03274     }
03275 
03276     vproc->enable();
03277     vproc->parameter(vp::EyePosition, ri.eyePos_obj);
03278     setLightParameters_VP(*vproc, ls, ri.color, ri.specularColor);
03279 
03280     vproc->parameter(vp::AmbientColor, ri.ambientColor * ri.color);
03281     vproc->parameter(vp::SpecularExponent, 0.0f, 1.0f, 0.5f, ri.specularPower);
03282 
03283     if (ri.bumpTex != NULL && ri.baseTex != NULL)
03284     {
03285         // We don't yet handle the case where there's a bump map but no
03286         // base texture.
03287         vproc->use(vp::diffuseBump);
03288         if (ri.ambientColor != Color::Black)
03289         {
03290             // If there's ambient light, we'll need to render in two passes:
03291             // one for the ambient light, and the second for light from the star.
03292             // We could do this in a single pass using three texture stages, but
03293             // this isn't won't work with hardware that only supported two
03294             // texture stages.
03295 
03296             // Render the base texture modulated by the ambient color
03297             setupTexenvAmbient(ri.ambientColor);
03298             lodSphere->render(context,
03299                               LODSphereMesh::TexCoords0 | LODSphereMesh::VertexProgParams,
03300                               frustum, ri.pixWidth,
03301                               ri.baseTex);
03302 
03303             // Add the light from the sun
03304             glEnable(GL_BLEND);
03305             glBlendFunc(GL_ONE, GL_ONE);
03306             setupBumpTexenv();
03307             lodSphere->render(context,
03308                               LODSphereMesh::Normals | LODSphereMesh::Tangents |
03309                               LODSphereMesh::TexCoords0 | LODSphereMesh::VertexProgParams,
03310                               frustum, ri.pixWidth,
03311                               ri.bumpTex, ri.baseTex);
03312             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03313             glDisable(GL_BLEND);
03314         }
03315         else
03316         {
03317             glx::glActiveTextureARB(GL_TEXTURE1_ARB);
03318             ri.baseTex->bind();
03319             glx::glActiveTextureARB(GL_TEXTURE0_ARB);
03320             ri.bumpTex->bind();
03321             setupBumpTexenv();
03322             lodSphere->render(context,
03323                               LODSphereMesh::Normals | LODSphereMesh::Tangents |
03324                               LODSphereMesh::TexCoords0 | LODSphereMesh::VertexProgParams,
03325                               frustum, ri.pixWidth,
03326                               ri.bumpTex, ri.baseTex);
03327             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03328         }
03329     }
03330     else
03331     {
03332         if (ls.nLights > 1)
03333             vproc->use(vp::diffuse_2light);
03334         else
03335             vproc->use(vp::diffuse);
03336         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03337         lodSphere->render(context,
03338                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0 |
03339                           LODSphereMesh::VertexProgParams,
03340                           frustum, ri.pixWidth,
03341                           ri.baseTex);
03342     }
03343 
03344     // Render a specular pass; can't be done in one pass because
03345     // specular needs to be modulated with a gloss map.
03346     if (ri.specularColor != Color::Black)
03347     {
03348         glEnable(GL_BLEND);
03349         glBlendFunc(GL_ONE, GL_ONE);
03350         vproc->use(vp::glossMap);
03351 
03352         if (ri.glossTex != NULL)
03353             glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03354         else
03355             setupTexenvGlossMapAlpha();
03356 
03357         lodSphere->render(context,
03358                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03359                           frustum, ri.pixWidth,
03360                           ri.glossTex != NULL ? ri.glossTex : ri.baseTex);
03361 
03362         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03363         glDisable(GL_BLEND);
03364     }
03365 
03366     if (ri.nightTex != NULL)
03367     {
03368         ri.nightTex->bind();
03369         if (ls.nLights > 1)
03370             vproc->use(vp::nightLights_2light);
03371         else
03372             vproc->use(vp::nightLights);
03373         setupNightTextureCombine();
03374         glEnable(GL_BLEND);
03375         glBlendFunc(GL_ONE, GL_ONE);
03376         lodSphere->render(context,
03377                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03378                           frustum, ri.pixWidth,
03379                           ri.nightTex);
03380         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03381     }
03382 
03383     if (ri.overlayTex != NULL)
03384     {
03385         ri.overlayTex->bind();
03386         vproc->use(vp::diffuse);
03387         glEnable(GL_BLEND);
03388         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
03389         lodSphere->render(context,
03390                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03391                           frustum, ri.pixWidth,
03392                           ri.overlayTex);
03393         glBlendFunc(GL_ONE, GL_ONE);
03394     }
03395 
03396     vproc->disable();
03397 }

static void renderSphere_FP_VP const RenderInfo ri,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3565 of file render.cpp.

References VertexProcessor::disable(), FragmentProcessor::disable(), DisableCombiners(), FragmentProcessor::enable(), VertexProcessor::enable(), GL_COLOR_SUM_EXT, GL_TEXTURE0_ARB, Vector3< T >::length(), lodSphere, Vector3< T >::normalize(), FragmentProcessor::parameter(), VertexProcessor::parameter(), LODSphereMesh::render(), SetupCombinersGlossMap(), setupNightTextureCombine(), FragmentProcessor::use(), and VertexProcessor::use().

Referenced by Renderer::renderObject().

03568 {
03569     Texture* textures[4];
03570     VertexProcessor* vproc = context.getVertexProcessor();
03571     FragmentProcessor* fproc = context.getFragmentProcessor();
03572     assert(vproc != NULL && fproc != NULL);
03573 
03574     if (ri.baseTex == NULL)
03575     {
03576         glDisable(GL_TEXTURE_2D);
03577     }
03578     else
03579     {
03580         glEnable(GL_TEXTURE_2D);
03581         ri.baseTex->bind();
03582     }
03583 
03584     // Compute the half angle vector required for specular lighting
03585     Vec3f halfAngle_obj = ri.eyeDir_obj + ri.sunDir_obj;
03586     if (halfAngle_obj.length() != 0.0f)
03587         halfAngle_obj.normalize();
03588 
03589     // Set up the fog parameters if the haze density is non-zero
03590     float hazeDensity = ri.hazeColor.alpha();
03591 
03592     if (hazeDensity > 0.0f)
03593     {
03594         glEnable(GL_FOG);
03595         float fogColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
03596         fogColor[0] = ri.hazeColor.red();
03597         fogColor[1] = ri.hazeColor.green();
03598         fogColor[2] = ri.hazeColor.blue();
03599         glFogfv(GL_FOG_COLOR, fogColor);
03600         glFogi(GL_FOG_MODE, GL_LINEAR);
03601         glFogf(GL_FOG_START, 0.0);
03602         glFogf(GL_FOG_END, 1.0f / hazeDensity);
03603     }
03604 
03605     vproc->enable();
03606 
03607     vproc->parameter(vp::EyePosition, ri.eyePos_obj);
03608     vproc->parameter(vp::LightDirection0, ri.sunDir_obj);
03609     vproc->parameter(vp::DiffuseColor0, ri.sunColor * ri.color);
03610     vproc->parameter(vp::SpecularExponent, 0.0f, 1.0f, 0.5f, ri.specularPower);
03611     vproc->parameter(vp::SpecularColor0, ri.sunColor * ri.specularColor);
03612     vproc->parameter(vp::AmbientColor, ri.ambientColor * ri.color);
03613     vproc->parameter(vp::HazeColor, ri.hazeColor);
03614 
03615     if (ri.bumpTex != NULL)
03616     {
03617         fproc->enable();
03618         
03619         if (hazeDensity > 0.0f)
03620             vproc->use(vp::diffuseBumpHaze);
03621         else
03622             vproc->use(vp::diffuseBump);
03623         fproc->use(fp::texDiffuseBump);
03624         lodSphere->render(context,
03625                           LODSphereMesh::Normals | LODSphereMesh::Tangents |
03626                           LODSphereMesh::TexCoords0 | LODSphereMesh::VertexProgParams,
03627                           frustum, ri.pixWidth,
03628                           ri.baseTex, ri.bumpTex);
03629         fproc->disable();
03630 
03631         // Render a specular pass
03632         if (ri.specularColor != Color::Black)
03633         {
03634             glEnable(GL_BLEND);
03635             glBlendFunc(GL_ONE, GL_ONE);
03636             glEnable(GL_COLOR_SUM_EXT);
03637             vproc->use(vp::specular);
03638 
03639             // Disable ambient and diffuse
03640             vproc->parameter(vp::AmbientColor, Color::Black);
03641             vproc->parameter(vp::DiffuseColor0, Color::Black);
03642             SetupCombinersGlossMap(ri.glossTex != NULL ? GL_TEXTURE0_ARB : 0);
03643 
03644             textures[0] = ri.glossTex != NULL ? ri.glossTex : ri.baseTex;
03645             lodSphere->render(context,
03646                               LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03647                               frustum, ri.pixWidth,
03648                               textures, 1);
03649 
03650             // re-enable diffuse
03651             vproc->parameter(vp::DiffuseColor0, ri.sunColor * ri.color);
03652 
03653             DisableCombiners();
03654             glDisable(GL_COLOR_SUM_EXT);
03655             glDisable(GL_BLEND);
03656         }
03657     }
03658     else if (ri.specularColor != Color::Black)
03659     {
03660         fproc->enable();
03661         if (ri.glossTex == NULL)
03662         {
03663             vproc->use(vp::perFragmentSpecularAlpha);
03664             fproc->use(fp::texSpecularAlpha);
03665         }
03666         else
03667         {
03668             vproc->use(vp::perFragmentSpecular);
03669             fproc->use(fp::texSpecular);
03670         }
03671         fproc->parameter(fp::DiffuseColor, ri.sunColor * ri.color);
03672         fproc->parameter(fp::SunDirection, ri.sunDir_obj);
03673         fproc->parameter(fp::SpecularColor, ri.specularColor);
03674         fproc->parameter(fp::SpecularExponent, ri.specularPower, 0.0f, 0.0f, 0.0f);
03675         fproc->parameter(fp::AmbientColor, ri.ambientColor);
03676 
03677         unsigned int attributes = LODSphereMesh::Normals |
03678                                   LODSphereMesh::TexCoords0 |
03679                                   LODSphereMesh::VertexProgParams;
03680         lodSphere->render(context,
03681                           attributes, frustum, ri.pixWidth,
03682                           ri.baseTex, ri.glossTex);
03683         fproc->disable();
03684     }
03685     else
03686     {
03687         fproc->enable();
03688         if (hazeDensity > 0.0f)
03689             vproc->use(vp::diffuseHaze);
03690         else
03691             vproc->use(vp::diffuse);
03692         fproc->use(fp::texDiffuse);
03693         lodSphere->render(context,
03694                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0 |
03695                           LODSphereMesh::VertexProgParams,
03696                           frustum, ri.pixWidth,
03697                           ri.baseTex);
03698         fproc->disable();
03699     }
03700 
03701     if (hazeDensity > 0.0f)
03702         glDisable(GL_FOG);
03703 
03704     if (ri.nightTex != NULL)
03705     {
03706         ri.nightTex->bind();
03707         vproc->use(vp::nightLights);
03708         setupNightTextureCombine();
03709         glEnable(GL_BLEND);
03710         glBlendFunc(GL_ONE, GL_ONE);
03711         lodSphere->render(context,
03712                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03713                           frustum, ri.pixWidth,
03714                           ri.nightTex);
03715         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03716     }
03717 
03718     if (ri.overlayTex != NULL)
03719     {
03720         ri.overlayTex->bind();
03721         vproc->use(vp::diffuse);
03722         glEnable(GL_BLEND);
03723         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
03724         lodSphere->render(context,
03725                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03726                           frustum, ri.pixWidth,
03727                           ri.overlayTex);
03728         glBlendFunc(GL_ONE, GL_ONE);
03729     }
03730 
03731     vproc->disable();
03732 }

static void renderSphere_GLSL const RenderInfo ri,
const LightingState ls,
RingSystem rings,
float  radius,
const Mat4f planetMat,
const Frustum frustum,
const GLContext context
[static]
 

Definition at line 3735 of file render.cpp.

References CelestiaGLProgram::ambientColor, Texture::bind(), ShaderManager::getShader(), GetShaderManager(), GL_CLAMP_TO_BORDER_ARB, GL_TEXTURE0_ARB, glx::glActiveTextureARB, glColor(), glx::glUseProgramObjectARB, ShaderProperties::lightModel, lodSphere, medres, min, ShaderProperties::nLights, LODSphereMesh::render(), CelestiaGLProgram::ringRadius, CelestiaGLProgram::ringWidth, setEclipseShadowShaderConstants(), setLightParameters_GLSL(), ShaderProperties::setShadowCountForLight(), ShaderProperties::shadowCounts, CelestiaGLProgram::shininess, ShaderProperties::texUsage, and CelestiaGLProgram::use().

Referenced by Renderer::renderObject().

03742 {
03743     Texture* textures[4] = { NULL, NULL, NULL, NULL };
03744     unsigned int nTextures = 0;
03745     //VertexProcessor* vproc = context.getVertexProcessor();
03746     //assert(vproc != NULL);
03747 
03748     //vproc->disable();
03749     glDisable(GL_LIGHTING);
03750 
03751     ShaderProperties shadprop;
03752     shadprop.nLights = min(ls.nLights, MaxShaderLights);
03753 
03754     // Set up the textures used by this object
03755     if (ri.baseTex != NULL)
03756     {
03757         shadprop.texUsage = ShaderProperties::DiffuseTexture;
03758         textures[nTextures++] = ri.baseTex;
03759     }
03760 
03761     if (ri.bumpTex != NULL)
03762     {
03763         shadprop.texUsage |= ShaderProperties::NormalTexture;
03764         textures[nTextures++] = ri.bumpTex;
03765     }
03766 
03767     if (ri.specularColor != Color::Black)
03768     {
03769         shadprop.lightModel = ShaderProperties::SpecularModel;
03770         if (ri.glossTex == NULL)
03771         {
03772             shadprop.texUsage |= ShaderProperties::SpecularInDiffuseAlpha;
03773         }
03774         else
03775         {
03776             shadprop.texUsage |= ShaderProperties::SpecularTexture;
03777             textures[nTextures++] = ri.glossTex;
03778         }
03779     }
03780 
03781     if (ri.nightTex != NULL)
03782     {
03783         shadprop.texUsage |= ShaderProperties::NightTexture;
03784         textures[nTextures++] = ri.nightTex;
03785     }
03786     
03787     if (rings != NULL)
03788 #if 0
03789         (renderFlags & ShowRingShadows) != 0)
03790 #endif
03791     {
03792         Texture* ringsTex = rings->texture.find(medres);
03793         if (ringsTex != NULL)
03794         {
03795             glx::glActiveTextureARB(GL_TEXTURE0_ARB + nTextures);
03796             ringsTex->bind();
03797             nTextures++;
03798 
03799             // Tweak the texture--set clamp to border and a border color with
03800             // a zero alpha.
03801             float bc[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
03802             glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bc);
03803             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
03804                             GL_CLAMP_TO_BORDER_ARB);
03805             glx::glActiveTextureARB(GL_TEXTURE0_ARB);
03806 
03807             shadprop.texUsage |= ShaderProperties::RingShadowTexture;
03808         }
03809     }
03810 
03811     // Set the shadow information.
03812     // Track the total number of shadows; if there are too many, we'll have
03813     // to fall back to multipass.
03814     unsigned int totalShadows = 0;
03815     for (unsigned int li = 0; li < ls.nLights; li++)
03816     {
03817         if (ls.shadows[li] && !ls.shadows[li]->empty())
03818         {
03819             unsigned int nShadows = (unsigned int) min((size_t) MaxShaderShadows, ls.shadows[li]->size());
03820             shadprop.setShadowCountForLight(li, nShadows);
03821             totalShadows += nShadows;
03822         }
03823     }
03824 
03825     // Get a shader for the current rendering configuration
03826     CelestiaGLProgram* prog = GetShaderManager().getShader(shadprop);
03827     if (prog == NULL)
03828         return;
03829 
03830     prog->use();
03831 
03832     setLightParameters_GLSL(*prog, shadprop, ls,
03833                             ri.color, ri.specularColor);
03834 
03835     prog->shininess = ri.specularPower;
03836     prog->ambientColor = Vec3f(ri.ambientColor.red(), ri.ambientColor.green(),
03837                                ri.ambientColor.blue());
03838     
03839     if (shadprop.texUsage & ShaderProperties::RingShadowTexture)
03840     {
03841         float ringWidth = rings->outerRadius - rings->innerRadius;
03842         prog->ringRadius = rings->innerRadius / radius;
03843         prog->ringWidth = 1.0f / (ringWidth / radius);
03844     }
03845 
03846     if (shadprop.shadowCounts != 0)    
03847         setEclipseShadowShaderConstants(ls, radius, planetMat, *prog);
03848 
03849     glColor(ri.color);
03850 
03851     unsigned int attributes = LODSphereMesh::Normals;
03852     if (ri.bumpTex != NULL)
03853         attributes |= LODSphereMesh::Tangents;
03854     lodSphere->render(context,
03855                       attributes,
03856                       frustum, ri.pixWidth,
03857                       textures[0], textures[1], textures[2], textures[3]);
03858 
03859     glx::glUseProgramObjectARB(0);
03860 }

static void renderSphereDefault const RenderInfo ri,
const Frustum frustum,
bool  lit,
const GLContext context
[static]
 

Definition at line 3115 of file render.cpp.

References glAmbientLightColor(), glColor(), lodSphere, LODSphereMesh::render(), and setupNightTextureCombine().

Referenced by Renderer::renderObject().

03119 {
03120     if (lit)
03121         glEnable(GL_LIGHTING);
03122     else
03123         glDisable(GL_LIGHTING);
03124 
03125     if (ri.baseTex == NULL)
03126     {
03127         glDisable(GL_TEXTURE_2D);
03128     }
03129     else
03130     {
03131         glEnable(GL_TEXTURE_2D);
03132         ri.baseTex->bind();
03133     }
03134 
03135     glColor(ri.color);
03136 
03137     lodSphere->render(context,
03138                       LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03139                       frustum, ri.pixWidth,
03140                       ri.baseTex);
03141     if (ri.nightTex != NULL && ri.useTexEnvCombine)
03142     {
03143         ri.nightTex->bind();
03144         setupNightTextureCombine();
03145         glEnable(GL_BLEND);
03146         glBlendFunc(GL_ONE, GL_ONE);
03147         glAmbientLightColor(Color::Black); // Disable ambient light
03148         lodSphere->render(context,
03149                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03150                           frustum, ri.pixWidth,
03151                           ri.nightTex);
03152         glAmbientLightColor(ri.ambientColor);
03153         glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
03154     }
03155 
03156     if (ri.overlayTex != NULL)
03157     {
03158         ri.overlayTex->bind();
03159         glEnable(GL_BLEND);
03160         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
03161         lodSphere->render(context,
03162                           LODSphereMesh::Normals | LODSphereMesh::TexCoords0,
03163                           frustum, ri.pixWidth,
03164                           ri.overlayTex);
03165         glBlendFunc(GL_ONE, GL_ONE);
03166     }
03167 }

static void setEclipseShadowShaderConstants const LightingState ls,
float  planetRadius,
const Mat4f planetMat,
CelestiaGLProgram prog
[static]
 

Definition at line 2901 of file render.cpp.

References CelestiaGLProgramShadow::bias, EclipseShadow::direction, min, Vector3< T >::normalize(), EclipseShadow::origin, EclipseShadow::penumbraRadius, Matrix4< float >::rotation(), CelestiaGLProgramShadow::scale, CelestiaGLProgramShadow::texGenS, CelestiaGLProgramShadow::texGenT, EclipseShadow::umbraRadius, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), and renderSphere_GLSL().

02905 {
02906     for (unsigned int li = 0;
02907          li < min(ls.nLights, MaxShaderLights);
02908          li++)
02909     {
02910         vector<EclipseShadow>* shadows = ls.shadows[li];
02911 
02912         if (shadows != NULL)
02913         {
02914             unsigned int nShadows = min((size_t) MaxShaderShadows, 
02915                                         shadows->size());
02916 
02917             for (unsigned int i = 0; i < nShadows; i++)
02918             {
02919                 EclipseShadow& shadow = shadows->at(i);
02920                 CelestiaGLProgramShadow& shadowParams = prog.shadows[li][i];
02921 
02922                 float R2 = 0.25f;
02923                 float umbra = shadow.umbraRadius / shadow.penumbraRadius;
02924                 umbra = umbra * umbra;
02925                 if (umbra < 0.0001f)
02926                     umbra = 0.0001f;
02927                 else if (umbra > 0.99f)
02928                     umbra = 0.99f;
02929 
02930                 float umbraRadius = R2 * umbra;
02931                 float penumbraRadius = R2;
02932                 float shadowBias = 1.0f / (1.0f - penumbraRadius / umbraRadius);
02933                 shadowParams.bias = shadowBias;
02934                 shadowParams.scale = -shadowBias / umbraRadius;
02935 
02936                 // Compute the transformation to use for generating texture
02937                 // coordinates from the object vertices.
02938                 Point3f origin = shadow.origin * planetMat;
02939                 Vec3f dir = shadow.direction * planetMat;
02940                 float scale = planetRadius / shadow.penumbraRadius;
02941                 Vec3f axis = Vec3f(0, 1, 0) ^ dir;
02942                 float angle = (float) acos(Vec3f(0, 1, 0) * dir);
02943                 axis.normalize();
02944                 Mat4f mat = Mat4f::rotation(axis, -angle);
02945                 Vec3f sAxis = Vec3f(0.5f * scale, 0, 0) * mat;
02946                 Vec3f tAxis = Vec3f(0, 0, 0.5f * scale) * mat;
02947 
02948                 float sw = (Point3f(0, 0, 0) - origin) * sAxis / planetRadius + 0.5f;
02949                 float tw = (Point3f(0, 0, 0) - origin) * tAxis / planetRadius + 0.5f;
02950                 shadowParams.texGenS = Vec4f(sAxis.x, sAxis.y, sAxis.z, sw);
02951                 shadowParams.texGenT = Vec4f(tAxis.x, tAxis.y, tAxis.z, tw);
02952             }
02953         }
02954     }
02955 }

static void setLightParameters_GLSL CelestiaGLProgram prog,
const ShaderProperties shadprop,
const LightingState ls,
Color  materialDiffuse,
Color  materialSpecular
[static]
 

Definition at line 3001 of file render.cpp.

References Color::blue(), DirectionalLight::color, DirectionalLight::direction_obj, Color::green(), DirectionalLight::irradiance, Vector3< T >::length(), min, Vector3< T >::normalize(), Color::red(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by GLSL_RenderContext::makeCurrent(), renderClouds_GLSL(), renderRings_GLSL(), and renderSphere_GLSL().

03006 {
03007     unsigned int nLights = min(MaxShaderLights, ls.nLights);
03008 
03009     Vec3f diffuseColor(materialDiffuse.red(),
03010                        materialDiffuse.green(),
03011                        materialDiffuse.blue());
03012     Vec3f specularColor(materialSpecular.red(),
03013                         materialSpecular.green(),
03014                         materialSpecular.blue());
03015     
03016     for (unsigned int i = 0; i < nLights; i++)
03017     {
03018         const DirectionalLight& light = ls.lights[i];
03019 
03020         Vec3f lightColor = Vec3f(light.color.red(),
03021                                  light.color.green(),
03022                                  light.color.blue()) * light.irradiance;
03023         prog.lights[i].direction = light.direction_obj;
03024 
03025         if (shadprop.usesShadows() ||
03026             shadprop.usesFragmentLighting() ||
03027             shadprop.lightModel == ShaderProperties::RingIllumModel)
03028         {
03029             prog.fragLightColor[i] = Vec3f(lightColor.x * diffuseColor.x,
03030                                            lightColor.y * diffuseColor.y,
03031                                            lightColor.z * diffuseColor.z);
03032             if (shadprop.lightModel == ShaderProperties::SpecularModel)
03033             {
03034                 prog.fragLightSpecColor[i] = Vec3f(lightColor.x * specularColor.x,
03035                                                    lightColor.y * specularColor.y,
03036                                                    lightColor.z * specularColor.z);
03037             }
03038         }
03039         else
03040         {
03041             prog.lights[i].diffuse = Vec3f(lightColor.x * diffuseColor.x,
03042                                            lightColor.y * diffuseColor.y,
03043                                            lightColor.z * diffuseColor.z);
03044         }
03045         prog.lights[i].specular = Vec3f(lightColor.x * specularColor.x,
03046                                         lightColor.y * specularColor.y,
03047                                         lightColor.z * specularColor.z);
03048 
03049         Vec3f halfAngle_obj = ls.eyeDir_obj + light.direction_obj;
03050         if (halfAngle_obj.length() != 0.0f)
03051             halfAngle_obj.normalize();
03052         prog.lights[i].halfVector = halfAngle_obj;
03053     }
03054 }

static void setLightParameters_VP VertexProcessor vproc,
const LightingState ls,
Color  materialDiffuse,
Color  materialSpecular
[static]
 

Definition at line 2958 of file render.cpp.

References Color::blue(), DirectionalLight::color, vp::diffuse, Color::green(), DirectionalLight::irradiance, Color::red(), vp::specular, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderObject(), renderSphere_Combiners_VP(), and renderSphere_DOT3_VP().

02962 {
02963     Vec3f diffuseColor(materialDiffuse.red(),
02964                        materialDiffuse.green(),
02965                        materialDiffuse.blue());
02966     Vec3f specularColor(materialSpecular.red(),
02967                         materialSpecular.green(),
02968                         materialSpecular.blue());
02969 
02970     for (unsigned int i = 0; i < ls.nLights; i++)
02971     {
02972         const DirectionalLight& light = ls.lights[i];
02973 
02974         Vec3f lightColor = Vec3f(light.color.red(),
02975                                  light.color.green(),
02976                                  light.color.blue()) * light.irradiance;
02977         Vec3f diffuse(diffuseColor.x * lightColor.x,
02978                       diffuseColor.y * lightColor.y,
02979                       diffuseColor.z * lightColor.z);
02980         Vec3f specular(specularColor.x * lightColor.x,
02981                        specularColor.y * lightColor.y,
02982                        specularColor.z * lightColor.z);
02983 
02984         // Just handle two light sources for now
02985         if (i == 0)
02986         {
02987             vproc.parameter(vp::LightDirection0, ls.lights[0].direction_obj);
02988             vproc.parameter(vp::DiffuseColor0, diffuse);
02989             vproc.parameter(vp::SpecularColor0, specular);
02990         }
02991         else if (i == 1)
02992         {
02993             vproc.parameter(vp::LightDirection1, ls.lights[1].direction_obj);
02994             vproc.parameter(vp::DiffuseColor1, diffuse);
02995             vproc.parameter(vp::SpecularColor1, specular);
02996         }
02997     }
02998 }

static void setupBumpTexenv  )  [static]
 

Definition at line 2787 of file render.cpp.

References GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_ARB, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_SOURCE0_RGB_EXT, GL_SOURCE1_RGB_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, and glx::glActiveTextureARB.

Referenced by renderSphere_DOT3_VP().

02788 {
02789     // Set up the texenv_combine extension to do DOT3 bump mapping.
02790     // No support for ambient light yet.
02791     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02792 
02793     // The primary color contains the light direction in surface
02794     // space, and texture0 is a normal map.  The lighting is
02795     // calculated by computing the dot product.
02796     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_ARB);
02797     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
02798     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02799     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
02800     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02801 
02802     // In the final stage, modulate the lighting value by the
02803     // base texture color.
02804     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02805     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
02806     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
02807     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02808     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
02809     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02810     glEnable(GL_TEXTURE_2D);
02811 
02812     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02813 }

static void setupBumpTexenvAmbient Color  ambientColor  )  [static]
 

Definition at line 2816 of file render.cpp.

References Color::alpha(), Color::blue(), GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_CONSTANT_EXT, GL_DOT3_RGB_ARB, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_PREVIOUS_EXT, GL_PRIMARY_COLOR_EXT, GL_SOURCE0_RGB_EXT, GL_SOURCE1_RGB_EXT, GL_TEXTURE0_ARB, GL_TEXTURE1_ARB, GL_TEXTURE2_ARB, glx::glActiveTextureARB, Color::green(), and Color::red().

02817 {
02818     float texenvConst[4];
02819     texenvConst[0] = ambientColor.red();
02820     texenvConst[1] = ambientColor.green();
02821     texenvConst[2] = ambientColor.blue();
02822     texenvConst[3] = ambientColor.alpha();
02823 
02824     // Set up the texenv_combine extension to do DOT3 bump mapping.
02825     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02826 
02827     // The primary color contains the light direction in surface
02828     // space, and texture0 is a normal map.  The lighting is
02829     // calculated by computing the dot product.
02830     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02831     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_ARB);
02832     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
02833     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02834     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
02835     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02836 
02837     // Add in the ambient color
02838     glx::glActiveTextureARB(GL_TEXTURE1_ARB);
02839     glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texenvConst);
02840     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02841     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_ADD);
02842     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
02843     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02844     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
02845     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02846     glEnable(GL_TEXTURE_2D);
02847 
02848     // In the final stage, modulate the lighting value by the
02849     // base texture color.
02850     glx::glActiveTextureARB(GL_TEXTURE2_ARB);
02851     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02852     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
02853     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
02854     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02855     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
02856     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02857     glEnable(GL_TEXTURE_2D);
02858 
02859     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02860 }

static void setupLightSources const vector< const Star * > &  nearStars,
const Star sun,
double  t,
vector< Renderer::LightSource > &  lightSources
[static]
 

Definition at line 1199 of file render.cpp.

References Renderer::LightSource::color, Renderer::LightSource::luminosity, astro::microLightYearsToKilometers(), Renderer::LightSource::position, Renderer::LightSource::radius, Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::render().

01203 {
01204     UniversalCoord center = sun.getPosition(t);
01205 
01206     lightSources.clear();
01207 
01208     for (vector<const Star*>::const_iterator iter = nearStars.begin();
01209          iter != nearStars.end(); iter++)
01210     {
01211         if ((*iter)->getVisibility())
01212         {
01213             Vec3d v = ((*iter)->getPosition(t) - center) *
01214                 astro::microLightYearsToKilometers(1.0);
01215 
01216             Renderer::LightSource ls;
01217             ls.position = Point3d(v.x, v.y, v.z);
01218             ls.luminosity = (*iter)->getLuminosity();
01219             ls.radius = (*iter)->getRadius();
01220 
01221             // If the star is sufficiently cool, change the light color
01222             // from white.  Though our sun appears yellow, we still make
01223             // it and all hotter stars emit white light, as this is the
01224             // 'natural' light to which our eyes are accustomed.  We also
01225             // assign a slight bluish tint to light from O and B type stars,
01226             // though these will almost never have planets for their light
01227             // to shine upon.
01228             float temp = (*iter)->getTemperature();
01229             if (temp > 30000.0f)
01230                 ls.color = Color(0.8f, 0.8f, 1.0f);
01231             else if (temp > 10000.0f)
01232                 ls.color = Color(0.9f, 0.9f, 1.0f);
01233             else if (temp > 5400.0f)
01234                 ls.color = Color(1.0f, 1.0f, 1.0f);
01235             else if (temp > 3900.0f)
01236                 ls.color = Color(1.0f, 0.9f, 0.8f);
01237             else if (temp > 2000.0f)
01238                 ls.color = Color(1.0f, 0.7f, 0.7f);
01239             else
01240                 ls.color = Color(1.0f, 0.4f, 0.4f);
01241 
01242             lightSources.push_back(ls);
01243         }
01244     }
01245 }

static void setupNightTextureCombine  )  [static]
 

Definition at line 2776 of file render.cpp.

References GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_PRIMARY_COLOR_EXT, GL_SOURCE0_RGB_EXT, and GL_SOURCE1_RGB_EXT.

Referenced by renderSphere_Combiners_VP(), renderSphere_DOT3_VP(), renderSphere_FP_VP(), and renderSphereDefault().

02777 {
02778     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02779     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
02780     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_ONE_MINUS_SRC_COLOR);
02781     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
02782     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02783     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
02784 }

static void setupObjectLighting const vector< Renderer::LightSource > &  suns,
const Point3d objPosition,
const Quatf objOrientation,
const Vec3f objScale,
const Point3f objPosition_eye,
LightingState ls
[static]
 

Definition at line 4848 of file render.cpp.

References distance(), astro::kilometersToAU(), Vector3< T >::length(), log(), min, pow(), Vector3< T >::x, Vector3< T >::y, and Vector3< T >::z.

Referenced by Renderer::renderPlanet().

04854 {
04855     unsigned int nLights = min(MaxLights, (unsigned int) suns.size());
04856     if (nLights == 0)
04857         return;
04858 
04859     unsigned int i;
04860     for (i = 0; i < nLights; i++)
04861     {
04862         Vec3d dir = suns[i].position - objPosition;
04863         ls.lights[i].direction_eye =
04864             Vec3f((float) dir.x, (float) dir.y, (float) dir.z);
04865         float distance = ls.lights[i].direction_eye.length();
04866         ls.lights[i].direction_eye *= 1.0f / distance;
04867         distance = astro::kilometersToAU((float) dir.length());
04868         ls.lights[i].irradiance = suns[i].luminosity / (distance * distance);
04869         ls.lights[i].color = suns[i].color;
04870 
04871         // Store the position and apparent size because we'll need them for
04872         // testing for eclipses.
04873         ls.lights[i].position = suns[i].position;
04874         ls.lights[i].apparentSize = (float) (suns[i].radius / dir.length());
04875     }
04876 
04877     // Sort light sources by brightness.  Light zero should always be the
04878     // brightest.  Optimize common cases of one and two lights.
04879     if (nLights == 2)
04880     {
04881         if (ls.lights[0].irradiance < ls.lights[1].irradiance)
04882             swap(ls.lights[0], ls.lights[1]);
04883     }
04884     else if (nLights > 2)
04885     {
04886         sort(ls.lights, ls.lights + nLights, LightIrradiancePredicate());
04887     }
04888 
04889     // Compute the total irradiance
04890     float totalIrradiance = 0.0f;
04891     for (i = 0; i < nLights; i++)
04892         totalIrradiance += ls.lights[i].irradiance;
04893 
04894     // Compute a gamma factor to make dim light sources visible.  This is
04895     // intended to approximate what we see with our eyes--for example,
04896     // Earth-shine is visible on the night side of the Moon, even though
04897     // the amount of reflected light from the Earth is 1/10000 of what
04898     // the Moon receives directly from the Sun.
04899     //
04900     // TODO: Skip this step when high dynamic range rendering to floating point
04901     //   buffers is enabled.
04902     float minVisibleFraction = 1.0f / 10000.0f;
04903     float minDisplayableValue = 1.0f / 255.0f;
04904     float gamma = (float) (log(minDisplayableValue) / log(minVisibleFraction));
04905     float minVisibleIrradiance = minVisibleFraction * totalIrradiance;
04906 
04907     Mat3f m = (~objOrientation).toMatrix3();
04908 
04909     // Gamma scale and normalize the light sources; cull light sources that
04910     // aren't bright enough to contribute the final pixels rendered into the
04911     // frame buffer.
04912     ls.nLights = 0;
04913     for (i = 0; i < nLights && ls.lights[i].irradiance > minVisibleIrradiance; i++)
04914     {
04915         ls.lights[i].irradiance =
04916             (float) pow(ls.lights[i].irradiance / totalIrradiance, gamma);
04917 
04918         // Compute the direction of the light in object space
04919         ls.lights[i].direction_obj = ls.lights[i].direction_eye * m;
04920 
04921         ls.nLights++;
04922     }
04923 
04924     Point3f pos((float) objPosition.x,
04925                 (float) objPosition.y,
04926                 (float) objPosition.z);
04927     ls.eyePos_obj = Point3f(-objPosition_eye.x / objScale.x,
04928                             -objPosition_eye.y / objScale.y,
04929                             -objPosition_eye.z / objScale.z) * m;
04930     ls.eyeDir_obj = (Point3f(0.0f, 0.0f, 0.0f) - objPosition_eye) * m;
04931     ls.eyeDir_obj.normalize();
04932 
04933 #if 0
04934     // Old code: linear scaling approach
04935 
04936     // After sorting, the first light is always the brightest
04937     float maxIrradiance = ls.lights[0].irradiance;
04938 
04939     // Normalize the brightnesses of the light sources.
04940     // TODO: Investigate logarithmic functions for scaling light brightness, to
04941     //   better simulate what the human eye would see.
04942     ls.nLights = 0;
04943     for (i = 0; i < nLights; i++)
04944     {
04945         ls.lights[i].irradiance /= maxIrradiance;
04946         
04947         // Cull light sources that don't contribute significantly (less than
04948         // the resolution of an 8-bit color channel.)
04949         if (ls.lights[i].irradiance < 1.0f / 255.0f)
04950             break;
04951 
04952         // Compute the direction of the light in object space
04953         ls.lights[i].direction_obj = ls.lights[i].direction_eye * m;
04954 
04955         ls.nLights++;
04956     }
04957 #endif
04958 }

static void setupTexenvAmbient Color  ambientColor  )  [static]
 

Definition at line 2863 of file render.cpp.

References Color::alpha(), Color::blue(), GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_CONSTANT_EXT, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_SOURCE0_RGB_EXT, GL_SOURCE1_RGB_EXT, GL_TEXTURE0_ARB, glx::glActiveTextureARB, Color::green(), and Color::red().

Referenced by renderSphere_DOT3_VP().

02864 {
02865     float texenvConst[4];
02866     texenvConst[0] = ambientColor.red();
02867     texenvConst[1] = ambientColor.green();
02868     texenvConst[2] = ambientColor.blue();
02869     texenvConst[3] = ambientColor.alpha();
02870 
02871     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02872 
02873     // The primary color contains the light direction in surface
02874     // space, and texture0 is a normal map.  The lighting is
02875     // calculated by computing the dot product.
02876     glx::glActiveTextureARB(GL_TEXTURE0_ARB);
02877     glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, texenvConst);
02878     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02879     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
02880     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
02881     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02882     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_CONSTANT_EXT);
02883     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
02884     glEnable(GL_TEXTURE_2D);
02885 }

static void setupTexenvGlossMapAlpha  )  [static]
 

Definition at line 2888 of file render.cpp.

References GL_COMBINE_EXT, GL_COMBINE_RGB_EXT, GL_OPERAND0_RGB_EXT, GL_OPERAND1_RGB_EXT, GL_PRIMARY_COLOR_EXT, GL_SOURCE0_RGB_EXT, and GL_SOURCE1_RGB_EXT.

Referenced by renderSphere_DOT3_VP().

02889 {
02890     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
02891     glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
02892     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
02893     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
02894     glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
02895     glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_ALPHA);
02896 
02897 }

static void ShadowTextureEval float  u,
float  v,
float  w,
unsigned char *  pixel
[static]
 

Definition at line 220 of file render.cpp.

References sqrt().

Referenced by Renderer::init().

00222 {
00223     float r = (float) sqrt(u * u + v * v);
00224 
00225     // Leave some white pixels around the edges to the shadow doesn't
00226     // 'leak'.  We'll also set the maximum mip map level for this texture to 3
00227     // so we don't have problems with the edge texels at high mip map levels.
00228     int pixVal = r < 15.0f / 16.0f ? 0 : 255;
00229     pixel[0] = pixVal;
00230     pixel[1] = pixVal;
00231     pixel[2] = pixVal;
00232 }

static void StarTextureEval float  u,
float  v,
float  w,
unsigned char *  pixel
[static]
 

Definition at line 189 of file render.cpp.

References sqrt().

Referenced by Renderer::init().

00191 {
00192     float r = 1 - (float) sqrt(u * u + v * v);
00193     if (r < 0)
00194         r = 0;
00195     else if (r < 0.5f)
00196         r = 2.0f * r;
00197     else 
00198         r = 1;
00199 
00200     int pixVal = (int) (r * 255.99f);
00201     pixel[0] = pixVal;
00202     pixel[1] = pixVal;
00203     pixel[2] = pixVal;
00204 }

static void texGenPlane GLenum  coord,
GLenum  mode,
const Vec4f plane
[static]
 

Definition at line 3959 of file render.cpp.

Referenced by renderShadowedModelDefault().

03960 {
03961     float f[4];
03962     f[0] = plane.x; f[1] = plane.y; f[2] = plane.z; f[3] = plane.w;
03963     glTexGenfv(coord, mode, f);
03964 }

void transformOrbits const PlanetarySystem system  ) 
 

Definition at line 1101 of file render.cpp.

References RotationElements::ascendingNode, Body::getRotationElements(), Body::getSystem(), glRotate(), RotationElements::obliquity, Quaternion< double >::xrotation(), and Quaternion< double >::yrotation().

Referenced by Renderer::renderForegroundOrbits().

01102 {
01103     if (system->getPrimaryBody())
01104     {
01105         const Body *body = system->getPrimaryBody();
01106         transformOrbits(body->getSystem());
01107         Quatd rotation =
01108             Quatd::yrotation(body->getRotationElements().ascendingNode) *
01109             Quatd::xrotation(body->getRotationElements().obliquity);
01110         glRotate(rotation);      
01111     } 
01112 }


Variable Documentation

bool buggyVertexProgramEmulation = true [static]
 

Definition at line 110 of file render.cpp.

Referenced by Renderer::init(), and renderSphere_Combiners_VP().

const int CometTailSlices = 16 [static]
 

Definition at line 5780 of file render.cpp.

Referenced by Renderer::renderCometTail().

CometTailVertex cometTailVertices[CometTailSlices *MaxCometTailPoints] [static]
 

Definition at line 5789 of file render.cpp.

Referenced by Renderer::renderCometTail().

bool commonDataInitialized = false [static]
 

Definition at line 87 of file render.cpp.

Referenced by Renderer::init().

SphericalCoordLabel* coordLabels = NULL [static]
 

Definition at line 125 of file render.cpp.

Referenced by Renderer::init(), and Renderer::renderCelestialSphere().

const float CoronaHeight = 0.2f [static]
 

Definition at line 108 of file render.cpp.

Referenced by Renderer::render(), and Renderer::renderStar().

const double DSO_DISTANCE_LIMIT = 1.8e9 [static]
 

Definition at line 54 of file render.cpp.

Referenced by DSORenderer::DSORenderer().

Texture* eclipseShadowTextures[4] [static]
 

Definition at line 102 of file render.cpp.

Referenced by Renderer::init(), and renderEclipseShadows().

Texture* glareTex = NULL [static]
 

Definition at line 94 of file render.cpp.

Referenced by Renderer::init(), Renderer::renderBodyAsParticle(), and Renderer::renderStars().

LODSphereMesh* lodSphere = NULL [static]
 

Definition at line 89 of file render.cpp.

Referenced by Renderer::init(), renderBumpMappedMesh(), renderClouds_GLSL(), renderEclipseShadows_Shaders(), Renderer::renderObject(), renderRingShadowsVS(), renderShadowedModelDefault(), renderShadowedModelVertexShader(), renderSmoothMesh(), renderSphere_Combiners(), renderSphere_Combiners_VP(), renderSphere_DOT3_VP(), renderSphere_FP_VP(), renderSphere_GLSL(), and renderSphereDefault().

const int MaxCometTailPoints = 20 [static]
 

Definition at line 5779 of file render.cpp.

Referenced by Renderer::renderCometTail().

const float MaxFarNearRatio = 2000.0f [static]
 

Definition at line 70 of file render.cpp.

Referenced by Renderer::render().

const float MaxScaledDiscStarSize = 8.0f [static]
 

Definition at line 74 of file render.cpp.

Referenced by Renderer::renderBodyAsParticle(), and Renderer::renderStars().

const int MaxSkyRings = 32 [static]
 

Definition at line 127 of file render.cpp.

Referenced by Renderer::Renderer().

const int MaxSkySlices = 180 [static]
 

Definition at line 128 of file render.cpp.

Referenced by Renderer::renderEllipsoidAtmosphere(), and Renderer::Renderer().

const float MinFeatureSizeForLabel = 20.0f [static]
 

Definition at line 83 of file render.cpp.

Referenced by Renderer::Renderer().

const float MinNearPlaneDistance = 0.0001f [static]
 

Definition at line 69 of file render.cpp.

Referenced by Renderer::render(), and Renderer::renderDeepSkyObjects().

const float MinOrbitSizeForLabel = 20.0f [static]
 

Definition at line 79 of file render.cpp.

Referenced by Renderer::Renderer().

const int MinSkySlices = 30 [static]
 

Definition at line 129 of file render.cpp.

Referenced by Renderer::renderEllipsoidAtmosphere().

int nCoordLabels = 32 [static]
 

Definition at line 124 of file render.cpp.

Referenced by Renderer::init(), and Renderer::renderCelestialSphere().

Texture* normalizationTex = NULL [static]
 

Definition at line 91 of file render.cpp.

Referenced by Renderer::init(), renderBumpMappedMesh(), and renderSmoothMesh().

Texture* penumbraFunctionTexture = NULL [static]
 

Definition at line 104 of file render.cpp.

Referenced by Renderer::init(), and renderEclipseShadows_Shaders().

const float PixelOffset = 0.125f [static]
 

Definition at line 63 of file render.cpp.

Referenced by Renderer::renderLabels(), Renderer::renderLocations(), and Renderer::renderSortedLabels().

const int REF_DISTANCE_TO_SCREEN = 400 [static]
 

Definition at line 55 of file render.cpp.

Referenced by DSORenderer::process().

const float RenderDistance = 50.0f [static]
 

Definition at line 72 of file render.cpp.

Referenced by StarRenderer::process().

Texture* shadowMaskTexture = NULL [static]
 

Definition at line 103 of file render.cpp.

Referenced by Renderer::init(), and renderEclipseShadows().

Texture* shadowTex = NULL [static]
 

Definition at line 95 of file render.cpp.

Referenced by Renderer::init(), renderEclipseShadows(), and renderRings().

const float ShadowTextureScale = 15.0f / 16.0f [static]
 

Definition at line 100 of file render.cpp.

Referenced by renderRings().

const float STAR_DISTANCE_LIMIT = 1.0e6f [static]
 

Definition at line 53 of file render.cpp.

Referenced by StarRenderer::StarRenderer().

Texture* starTex = NULL [static]
 

Definition at line 93 of file render.cpp.

Referenced by Renderer::init(), Renderer::render(), Renderer::renderBodyAsParticle(), and Renderer::renderStars().

const int StarVertexListSize = 1024 [static]
 

Definition at line 59 of file render.cpp.

const float X0_SOL = astro::AUtoKilometers(5.0f) [static]
 

Definition at line 57 of file render.cpp.

Referenced by Renderer::renderCometTail().


Generated on Sat Jan 14 22:31:09 2006 for Celestia by  doxygen 1.4.1