Cleanup; fixed a bug in default shader with normal mapping; less harsh shadows on shaderless new planets.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2950 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2010-01-09 20:18:21 +00:00
parent 458fa19a7a
commit f1393d68b5
5 changed files with 13 additions and 60 deletions

View File

@ -80,7 +80,7 @@ uniform sampler2D uNormalMap;
const float kHarshShadowFactor = 0.3;
const vec3 kTerminatorThreshold = vec3(0.08);
#else
const float kHarshShadowFactor = 0.01;
const float kHarshShadowFactor = 0.05;
const vec3 kTerminatorThreshold = vec3(0.1, 0.105, 0.12);
#endif

View File

@ -1,7 +1,6 @@
// No vNormal, because normal is always 0,0,1 in tangent space.
varying vec3 vEyeVector;
varying vec2 vTexCoords;
varying vec3 vLight0Vector;
varying vec3 vLight1Vector;
varying vec3 vCoords;
@ -11,7 +10,6 @@ void main(void)
vCoords = gl_Vertex.xyz;
// Build tangent basis.
// vec3 normal = normalize(gl_NormalMatrix * vCoords);
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 binormal = cross(normal, gl_NormalMatrix * vec3(0, 1, 0));
vec3 tangent = -cross(normal, binormal);
@ -20,9 +18,6 @@ void main(void)
vec3 eyeVector = -vec3(gl_ModelViewMatrix * gl_Vertex);
vEyeVector = eyeVector * TBN;
vec3 light0Vector = gl_LightSource[0].position.xyz + eyeVector;
vLight0Vector = light0Vector * TBN;
vec3 light1Vector = gl_LightSource[1].position.xyz + eyeVector;
vLight1Vector = light1Vector * TBN;

View File

@ -258,7 +258,7 @@ void main(void)
// Get normal
#if OOSTD_NORMAL_MAP
vec3 normal = texture2D(uNormalMap, texCoord).rgb - 0.5;
vec3 normal = normalize(texture2D(uNormalMap, texCoord).rgb - 0.5);
#else
const vec3 normal = vec3(0.0, 0.0, 1.0);
#endif

View File

@ -26,7 +26,6 @@ MA 02110-1301, USA.
#if NEW_PLANETS
#define SHADY_PLANETS !NO_SHADERS
#define NEW_ATMOSPHERE 0
#import "OOPlanetDrawable.h"
@ -77,6 +76,8 @@ MA 02110-1301, USA.
self = [self init];
if (self == nil) return nil;
scanClass = CLASS_NO_DRAW;
// Load random seed override.
NSString *seedStr = [dict oo_stringForKey:@"seed"];
if (seedStr != nil)
@ -99,8 +100,6 @@ MA 02110-1301, USA.
_shuttleLaunchInterval = 3600.0 / (double)_shuttlesOnGround; // All are launched in one hour.
_lastLaunchTime = 30.0 - _shuttleLaunchInterval; // debug - launch 30s after player enters universe FIXME: is 0 the correct non-debug value?
scanClass = CLASS_NO_DRAW;
int percent_land = [planetInfo oo_intForKey:@"percent_land" defaultValue:24 + (gen_rnd_number() % 48)];
[planetInfo setObject:[NSNumber numberWithFloat:0.01 * percent_land] forKey:@"land_fraction"];
@ -129,11 +128,13 @@ MA 02110-1301, USA.
else
#else
// differentiate between normal planets and moons.
if (atmosphere) _atmosphereDrawable = [[OOPlanetDrawable atmosphereWithRadius:collision_radius + ATMOSPHERE_DEPTH] retain];
#endif
if (atmosphere)
{
_materialParameters = [planetInfo dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"land_fraction", @"land_color", @"sea_color", @"polar_land_color", @"polar_sea_color", @"noise_map_seed", @"economy", nil]];
_atmosphereDrawable = [[OOPlanetDrawable atmosphereWithRadius:collision_radius + ATMOSPHERE_DEPTH] retain];
}
#endif
_materialParameters = [planetInfo dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"land_fraction", @"land_color", @"sea_color", @"polar_land_color", @"polar_sea_color", @"noise_map_seed", @"economy", nil]];
[_materialParameters retain];
NSString *textureName = [dict oo_stringForKey:@"texture"];
@ -473,38 +474,6 @@ static OOColor *ColorWithHSBColor(Vector c)
{
BOOL isMoon = _atmosphereDrawable == nil;
#if !SHADY_PLANETS
if (textureName != nil)
{
[_planetDrawable setTextureName:textureName];
}
else
{
OOTexture *texture = nil;
OOSingleTextureMaterial *material = nil
if (isMoon)
{
texture = [OOPlanetTextureGenerator planetTextureWithInfo:_materialParameters];
material = [[OOSingleTextureMaterial alloc] initWithName:@"dynamic" texture:texture configuration:nil];
}
else
{
OOTexture *atmosphere = nil;
[OOPlanetTextureGenerator generatePlanetTexture:&texture
andAtmosphere:&atmosphere
withInfo:_materialParameters];
material = [[OOSingleTextureMaterial alloc] initWithName:@"dynamic" texture:atmosphere configuration:nil];
[_atmosphereDrawable setMaterial:material];
[material release];
material = [[OOSingleTextureMaterial alloc] initWithName:@"dynamic" texture:texture configuration:nil];
}
[_planetDrawable setMaterial:material];
[material release];
}
#else
OOTexture *diffuseMap = nil;
OOTexture *normalMap = nil;
NSDictionary *macros = nil;
@ -563,7 +532,6 @@ static OOColor *ColorWithHSBColor(Vector c)
material = [[OOSingleTextureMaterial alloc] initWithName:textureName texture:diffuseMap configuration:nil];
}
[_planetDrawable setMaterial:material];
#endif
}

View File

@ -24,7 +24,7 @@
*/
#define DEBUG_DUMP ( 0 && !defined(NDEBUG))
#define DEBUG_DUMP ( 1 && !defined(NDEBUG))
#define DEBUG_DUMP_RAW ( 0 && DEBUG_DUMP)
// Hermite interpolation provides continuous normals, at a cost of about 35 % slower rendering.
@ -275,7 +275,7 @@ enum
- (NSString *) descriptionComponents
{
return [NSString stringWithFormat:@"seed: %u,%u", _seed.high, _seed.low];
return [NSString stringWithFormat:@"seed: %u,%u land: %g", _seed.high, _seed.low, _landFraction];
}
@ -498,16 +498,8 @@ enum
}
else
{
/* Terrain shading
was: _powf(norm.z, 3.2). Changing exponent to 3 makes very
little difference, other than being faster.
FIXME: need to work out a decent way to scale this with texture
size, so overall darkness is constant. Should probably be based
on normalScale.
-- Ahruman
*/
shade = norm.z * norm.z * norm.z;
// Terrain shading - lambertian lighting from straight above.
shade = norm.z;
/* We don't want terrain shading in the sea. The alpha channel
of color is a measure of "seaishness" for the specular map,
@ -525,8 +517,6 @@ enum
if (generateAtmosphere)
{
//
//TODO: sort out CloudMix
if (NO)
{