Experimenting with additive blending in particleEntity.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@880 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
ce7270caa3
commit
cd9d2260de
@ -824,7 +824,7 @@ BOOL global_testForVAR;
|
||||
OOLog(kOOLogFileNotLoaded, @"ERROR no basefile for entity %@");
|
||||
}
|
||||
}
|
||||
glShadeModel(GL_SMOOTH);
|
||||
if (!is_smooth_shaded) glShadeModel(GL_SMOOTH);
|
||||
checkGLErrors([NSString stringWithFormat:@"Entity after drawing %@", self]);
|
||||
|
||||
NS_HANDLER
|
||||
|
@ -37,6 +37,30 @@ MA 02110-1301, USA.
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.ParticleEntity"
|
||||
|
||||
|
||||
#ifndef ADDITIVE_BLENDING
|
||||
#define ADDITIVE_BLENDING 1
|
||||
#endif
|
||||
|
||||
#if ADDITIVE_BLENDING
|
||||
static inline void BeginAdditiveBlending(void)
|
||||
{
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
}
|
||||
|
||||
|
||||
static inline void EndAdditiveBlending(void)
|
||||
{
|
||||
glPopAttrib();
|
||||
}
|
||||
#else
|
||||
#define BeginAdditiveBlending() do {} while (0)
|
||||
#define EndAdditiveBlending() do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
@implementation ParticleEntity
|
||||
@ -1257,7 +1281,13 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
- (void) updateExhaust2:(double) delta_t
|
||||
{
|
||||
GLfloat ex_emissive[4] = {0.6, 0.8, 1.0, 0.9}; // pale blue
|
||||
#if ADDITIVE_BLENDING
|
||||
#define OVERALL_ALPHA 0.3f
|
||||
#else
|
||||
#define OVERALL_ALPHA 1.0f
|
||||
#endif
|
||||
|
||||
GLfloat ex_emissive[4] = {0.6, 0.8, 1.0, 0.9 * OVERALL_ALPHA}; // pale blue
|
||||
GLfloat s1[8] = { 0.0, 0.707, 1.0, 0.707, 0.0, -0.707, -1.0, -0.707};
|
||||
GLfloat c1[8] = { 1.0, 0.707, 0.0, -0.707, -1.0, -0.707, 0.0, 0.707};
|
||||
ShipEntity *ship =(ShipEntity *)[universe entityForUniversalID:owner];
|
||||
@ -1341,7 +1371,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
int i;
|
||||
float r1;
|
||||
//
|
||||
ex_emissive[3] = flare_factor; // fade alpha towards rear of exhaust
|
||||
ex_emissive[3] = flare_factor * OVERALL_ALPHA; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = red_factor; // diminish red part towards rear of exhaust
|
||||
verts[iv++] = f03.position.x + b03.x;// + zero.k.x * flare_factor * 4.0;
|
||||
@ -1352,7 +1382,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
exhaustBaseColors[ci++] = ex_emissive[2];
|
||||
exhaustBaseColors[ci++] = ex_emissive[3];
|
||||
//
|
||||
ex_emissive[3] = 0.9 * flare_factor; // fade alpha towards rear of exhaust
|
||||
ex_emissive[3] = 0.9 * flare_factor * OVERALL_ALPHA; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = 0.9 * green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = 0.9 * red_factor; // diminish red part towards rear of exhaust
|
||||
Vector k1 = f01.k;
|
||||
@ -1376,7 +1406,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
exhaustBaseColors[ci++] = ex_emissive[3];
|
||||
}
|
||||
//
|
||||
ex_emissive[3] = 0.6 * flare_factor; // fade alpha towards rear of exhaust
|
||||
ex_emissive[3] = 0.6 * flare_factor * OVERALL_ALPHA; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = 0.6 * green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = 0.6 * red_factor; // diminish red part towards rear of exhaust
|
||||
k1 = f03.k;
|
||||
@ -1396,7 +1426,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
exhaustBaseColors[ci++] = ex_emissive[3];
|
||||
}
|
||||
//
|
||||
ex_emissive[3] = 0.4 * flare_factor; // fade alpha towards rear of exhaust
|
||||
ex_emissive[3] = 0.4 * flare_factor * OVERALL_ALPHA; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = 0.4 * green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = 0.4 * red_factor; // diminish red part towards rear of exhaust
|
||||
k1 = f06.k;
|
||||
@ -1416,7 +1446,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
exhaustBaseColors[ci++] = ex_emissive[3];
|
||||
}
|
||||
//
|
||||
ex_emissive[3] = 0.2 * flare_factor; // fade alpha towards rear of exhaust
|
||||
ex_emissive[3] = 0.2 * flare_factor * OVERALL_ALPHA; // fade alpha towards rear of exhaust
|
||||
ex_emissive[1] = 0.2 * green_factor; // diminish green part towards rear of exhaust
|
||||
ex_emissive[0] = 0.2 * red_factor; // diminish red part towards rear of exhaust
|
||||
k1 = f08.k;
|
||||
@ -1640,11 +1670,12 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
glColor4fv( color_fv);
|
||||
|
||||
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color_fv);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
viewdir = [universe viewDir];
|
||||
@ -1739,6 +1770,8 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
break;
|
||||
}
|
||||
glEnd();
|
||||
|
||||
EndAdditiveBlending();
|
||||
}
|
||||
|
||||
- (void) drawLaser
|
||||
@ -1754,6 +1787,8 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glColor4fv(color_fv);
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glVertex3f(0.25, 0.0, 0.0);
|
||||
@ -1768,6 +1803,8 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
|
||||
|
||||
glEnd();
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
|
||||
@ -1794,6 +1831,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glDisable( GL_CULL_FACE); // face culling
|
||||
glShadeModel( GL_SMOOTH);
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer( 3, GL_FLOAT, 0, verts);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
@ -1809,6 +1848,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glDrawElements( GL_QUAD_STRIP, 18, GL_UNSIGNED_INT, qstrip3);
|
||||
glDrawElements( GL_TRIANGLE_FAN, 10, GL_UNSIGNED_INT, tfan2);
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glEnable( GL_CULL_FACE); // face culling
|
||||
glEnable( GL_TEXTURE_2D);
|
||||
}
|
||||
@ -1826,6 +1867,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
//NSLog(@"... drawing hyppering inner_radius:%.1f alpha:%.2f", ring_inner_radius, aleph);
|
||||
|
||||
// movies:
|
||||
@ -1841,6 +1884,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
}
|
||||
glEnd();
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
glPopMatrix();
|
||||
}
|
||||
@ -1854,6 +1899,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glDisable(GL_CULL_FACE); // face culling
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
int step = 4;
|
||||
|
||||
glColor4fv( color_fv);
|
||||
@ -1865,6 +1912,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
|
||||
// NSLog(@"DEBUG ENERGY BOMB radius: %.3f, expansion: %.3f, color: [ %.3f, %.3f, %.3f, %.3f]", collision_radius, velocity.z, color_fv[0], color_fv[1], color_fv[2], alpha);
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glEnable(GL_CULL_FACE); // face culling
|
||||
}
|
||||
|
||||
@ -1877,6 +1926,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glPushMatrix();
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -1885,6 +1936,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
}
|
||||
glEnd();
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
@ -1898,6 +1951,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
glBindTexture(GL_TEXTURE_2D, texName);
|
||||
glPushMatrix();
|
||||
|
||||
BeginAdditiveBlending();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
for (i = 0; i < n_vertices; i++)
|
||||
{
|
||||
@ -1906,6 +1961,8 @@ GLuint tfan2[10] = { 33, 25, 26, 27, 28, 29, 30, 31, 32, 25}; // final fan 64..7
|
||||
}
|
||||
glEnd();
|
||||
|
||||
EndAdditiveBlending();
|
||||
|
||||
glPopMatrix();
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
@ -625,6 +625,8 @@ GLuint max_texture_dimension = 512; // conservative start
|
||||
|
||||
void fillSquareImageDataWithBlur(unsigned char * imageBuffer, int width, int nplanes)
|
||||
{
|
||||
OOLog(@"texture.generatingBlur", @"Genrating blur - %u pixels wide, %u planes.", width, nplanes);
|
||||
|
||||
int x, y;
|
||||
int r = width / 2;
|
||||
float r1 = 1.0 / r;
|
||||
|
Loading…
x
Reference in New Issue
Block a user