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