paysages : Addes texture transparency at borders.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@318 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
3bd7e91659
commit
468b3628e5
4 changed files with 34 additions and 11 deletions
4
TODO
4
TODO
|
@ -1,5 +1,6 @@
|
|||
Technology Preview 2 :
|
||||
- Interface for textures thickness and slope_range.
|
||||
- Replace zone ranges with curves.
|
||||
- Interface for textures thickness, slope_range and thickness_transparency.
|
||||
- Render tab previews should not rerender when changing render options.
|
||||
- Compute shadows only once for all textures at a same location.
|
||||
=> Add an intermediary light status (two pass lighting).
|
||||
|
@ -36,6 +37,7 @@ Technology Preview 3 :
|
|||
- Multi threaded first pass.
|
||||
- Fix potential holes in land rendering.
|
||||
- Progressive final render.
|
||||
- If we can't remove clouds artifacts, blur them.
|
||||
|
||||
Release Candidate :
|
||||
- Polish all features and UI.
|
||||
|
|
|
@ -161,6 +161,7 @@ void autoGenRealisticLandscape(int seed)
|
|||
texture->material.shininess = 3.0;
|
||||
texture->thickness = 0.001;
|
||||
texture->slope_range = 0.001;
|
||||
texture->thickness_transparency = 0.0;
|
||||
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
||||
zoneAddHeightRangeQuick(texture->zone, 1.0, -1.0, 0.0, 3.0, 15.0);
|
||||
zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 0.1, 0.7);
|
||||
|
@ -176,6 +177,7 @@ void autoGenRealisticLandscape(int seed)
|
|||
texture->material.shininess = 2.0;
|
||||
texture->thickness = 0.02;
|
||||
texture->slope_range = 0.03;
|
||||
texture->thickness_transparency = 0.005;
|
||||
texture = texturesGetLayer(&textures, texturesAddLayer(&textures));
|
||||
zoneAddHeightRangeQuick(texture->zone, 1.0, 4.0, 5.0, 100.0, 100.0);
|
||||
zoneAddSlopeRangeQuick(texture->zone, 1.0, 0.0, 0.0, 0.2, 1.0);
|
||||
|
@ -190,6 +192,7 @@ void autoGenRealisticLandscape(int seed)
|
|||
texture->material.shininess = 0.6;
|
||||
texture->thickness = 0.05;
|
||||
texture->slope_range = 0.3;
|
||||
texture->thickness_transparency = 0.015;
|
||||
scenerySetTextures(&textures);
|
||||
texturesDeleteDefinition(&textures);
|
||||
|
||||
|
|
|
@ -15,6 +15,15 @@
|
|||
|
||||
static TextureLayerDefinition _NULL_LAYER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 location;
|
||||
Vector3 normal;
|
||||
double thickness;
|
||||
Color color;
|
||||
double thickness_transparency;
|
||||
} TextureResult;
|
||||
|
||||
void texturesInit()
|
||||
{
|
||||
_NULL_LAYER = texturesLayerCreateDefinition();
|
||||
|
@ -39,6 +48,7 @@ void texturesSave(PackStream* stream, TexturesDefinition* definition)
|
|||
materialSave(stream, &definition->textures[i].material);
|
||||
packWriteDouble(stream, &definition->textures[i].thickness);
|
||||
packWriteDouble(stream, &definition->textures[i].slope_range);
|
||||
packWriteDouble(stream, &definition->textures[i].thickness_transparency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,6 +74,7 @@ void texturesLoad(PackStream* stream, TexturesDefinition* definition)
|
|||
materialLoad(stream, &layer->material);
|
||||
packReadDouble(stream, &definition->textures[i].thickness);
|
||||
packReadDouble(stream, &definition->textures[i].slope_range);
|
||||
packReadDouble(stream, &definition->textures[i].thickness_transparency);
|
||||
}
|
||||
|
||||
texturesValidateDefinition(definition);
|
||||
|
@ -126,6 +137,7 @@ TextureLayerDefinition texturesLayerCreateDefinition()
|
|||
result.material.shininess = 0.0;
|
||||
result.thickness = 0.0;
|
||||
result.slope_range = 0.001;
|
||||
result.thickness_transparency = 0.0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -143,6 +155,7 @@ void texturesLayerCopyDefinition(TextureLayerDefinition* source, TextureLayerDef
|
|||
destination->bump_scaling = source->bump_scaling;
|
||||
destination->thickness = source->thickness;
|
||||
destination->slope_range = source->slope_range;
|
||||
destination->thickness_transparency = source->thickness_transparency;
|
||||
noiseCopy(source->bump_noise, destination->bump_noise);
|
||||
zoneCopy(source->zone, destination->zone);
|
||||
}
|
||||
|
@ -293,6 +306,7 @@ static inline TextureResult _getTerrainResult(Renderer* renderer, double x, doub
|
|||
result.location = center;
|
||||
result.color = COLOR_GREEN;
|
||||
result.thickness = -100.0;
|
||||
result.thickness_transparency = 0.0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -339,6 +353,7 @@ static inline TextureResult _getLayerResult(TextureLayerDefinition* definition,
|
|||
}
|
||||
|
||||
result_center.color = renderer->applyLightingToSurface(renderer, result_center.location, result_center.normal, definition->material);
|
||||
result_center.thickness_transparency = definition->thickness_transparency;
|
||||
|
||||
return result_center;
|
||||
}
|
||||
|
@ -358,6 +373,7 @@ Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, doubl
|
|||
{
|
||||
TextureResult results[TEXTURES_MAX_LAYERS + 1];
|
||||
Color result;
|
||||
double thickness, last_height;
|
||||
int i;
|
||||
|
||||
/* TODO Do not compute layers fully covered */
|
||||
|
@ -375,9 +391,18 @@ Color texturesGetColor(TexturesDefinition* definition, Renderer* renderer, doubl
|
|||
qsort(results, definition->nbtextures + 1, sizeof(TextureResult), _cmpResults);
|
||||
|
||||
result = results[0].color;
|
||||
for (i = 0; i < definition->nbtextures; i++)
|
||||
last_height = results[0].thickness;
|
||||
for (i = 1; i <= definition->nbtextures; i++)
|
||||
{
|
||||
colorMask(&result, &results[i + 1].color);
|
||||
thickness = results[i].thickness - last_height;
|
||||
last_height = results[i].thickness;
|
||||
|
||||
if (thickness < results[i].thickness_transparency)
|
||||
{
|
||||
results[i].color.a = thickness / results[i].thickness_transparency;
|
||||
}
|
||||
|
||||
colorMask(&result, &results[i].color);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -22,6 +22,7 @@ typedef struct
|
|||
SurfaceMaterial material;
|
||||
double thickness;
|
||||
double slope_range;
|
||||
double thickness_transparency;
|
||||
} TextureLayerDefinition;
|
||||
|
||||
typedef struct
|
||||
|
@ -30,14 +31,6 @@ typedef struct
|
|||
TextureLayerDefinition textures[TEXTURES_MAX_LAYERS];
|
||||
} TexturesDefinition;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Vector3 location;
|
||||
Vector3 normal;
|
||||
double thickness;
|
||||
Color color;
|
||||
} TextureResult;
|
||||
|
||||
void texturesInit();
|
||||
void texturesQuit();
|
||||
void texturesSave(PackStream* stream, TexturesDefinition* definition);
|
||||
|
|
Loading…
Reference in a new issue