Fixed rendering problems when mixing nebulae and galaxies.
parent
a4612a54bc
commit
5b2dd75846
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <cassert>
|
||||
#include "celestia.h"
|
||||
#include <celmath/mathlib.h>
|
||||
#include <celmath/perlin.h>
|
||||
|
@ -18,6 +19,7 @@
|
|||
#include <celutil/debug.h>
|
||||
#include "gl.h"
|
||||
#include "vecgl.h"
|
||||
#include "texture.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -30,6 +32,8 @@ static GalacticForm* irregularForm = NULL;
|
|||
static GalacticForm** ellipticalForms = NULL;
|
||||
static void InitializeForms();
|
||||
|
||||
static Texture* galaxyTex = NULL;
|
||||
|
||||
struct GalaxyTypeName
|
||||
{
|
||||
const char* name;
|
||||
|
@ -57,6 +61,21 @@ static GalaxyTypeName GalaxyTypeNames[] =
|
|||
};
|
||||
|
||||
|
||||
static void GalaxyTextureEval(float u, float v, float w,
|
||||
unsigned char *pixel)
|
||||
{
|
||||
float r = 0.9f - (float) sqrt(u * u + v * v);
|
||||
if (r < 0)
|
||||
r = 0;
|
||||
|
||||
int pixVal = (int) (r * 255.99f);
|
||||
pixel[0] = 65;
|
||||
pixel[1] = 64;
|
||||
pixel[2] = 65;
|
||||
pixel[3] = pixVal;
|
||||
}
|
||||
|
||||
|
||||
Galaxy::Galaxy() :
|
||||
detail(1.0f),
|
||||
form(NULL)
|
||||
|
@ -151,6 +170,16 @@ void Galaxy::render(const Vec3f& offset,
|
|||
if (form == NULL)
|
||||
return;
|
||||
|
||||
if (galaxyTex == NULL)
|
||||
{
|
||||
galaxyTex = CreateProceduralTexture(128, 128, GL_RGBA,
|
||||
GalaxyTextureEval);
|
||||
galaxyTex->bindName();
|
||||
}
|
||||
assert(galaxyTex != NULL);
|
||||
|
||||
galaxyTex->bind();
|
||||
|
||||
Mat3f viewMat = viewerOrientation.toMatrix3();
|
||||
Vec3f v0 = Vec3f(-1, -1, 0) * viewMat;
|
||||
Vec3f v1 = Vec3f( 1, -1, 0) * viewMat;
|
||||
|
|
|
@ -76,7 +76,6 @@ static Texture* normalizationTex = NULL;
|
|||
|
||||
static Texture* starTex = NULL;
|
||||
static Texture* glareTex = NULL;
|
||||
static Texture* galaxyTex = NULL;
|
||||
static Texture* shadowTex = NULL;
|
||||
|
||||
static Texture* eclipseShadowTextures[4];
|
||||
|
@ -331,9 +330,6 @@ bool Renderer::init(GLContext* _context, int winWidth, int winHeight)
|
|||
starTex = CreateProceduralTexture(64, 64, GL_RGB, StarTextureEval);
|
||||
starTex->bindName();
|
||||
|
||||
galaxyTex = CreateProceduralTexture(128, 128, GL_RGBA, GlareTextureEval);
|
||||
galaxyTex->bindName();
|
||||
|
||||
glareTex = CreateJPEGTexture("textures/flare.jpg");
|
||||
if (glareTex == NULL)
|
||||
glareTex = CreateProceduralTexture(64, 64, GL_RGB, GlareTextureEval);
|
||||
|
@ -4092,7 +4088,6 @@ void Renderer::renderDeepSkyObjects(const DeepSkyCatalog& catalog,
|
|||
return;
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
galaxyTex->bind();
|
||||
|
||||
for (DeepSkyCatalog::const_iterator iter = catalog.begin();
|
||||
iter != catalog.end(); iter++)
|
||||
|
|
Loading…
Reference in New Issue