paysages : WIP.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@492 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2013-01-10 21:21:56 +00:00 committed by ThunderK
parent f1fcd70582
commit b816ab1105
8 changed files with 36 additions and 17 deletions

2
TODO
View file

@ -10,7 +10,7 @@ Technology Preview 2 :
=> Apply model to atmosphere (aerial perspective)
=> Find a proper model for night sky (maybe Shirley)
- Clouds should keep distance to ground.
- Implement Bruneton's scattering model.
- Add fresnel effect to specular lighting.
- Add clouds to explorer with 3d textures.
- Start using OpenCL to optimize rendering.
- Rethink the quality settings and detail smoothing in the distance.

View file

@ -116,7 +116,7 @@ void WidgetHeightMap::mousePressEvent(QMouseEvent* event)
}
}
void WidgetHeightMap::mouseReleaseEvent(QMouseEvent* event)
void WidgetHeightMap::mouseReleaseEvent(QMouseEvent*)
{
_last_brush_action = 0;
}
@ -365,7 +365,7 @@ void WidgetHeightMap::updateVertexInfo()
vertex->point.x = 80.0 * (double)x / (double)(rx - 1) - 40.0;
vertex->point.z = 80.0 * (double)z / (double)(rz - 1) - 40.0;
vertex->point.y = _renderer.terrain->getHeight(&_renderer, vertex->point.x, vertex->point.z);
}
}

View file

@ -613,9 +613,9 @@ static Color _inscatterS(double r, double mu, double muS, double nu, int first,
double pm1 = _phaseFunctionM(nu1);
Color ray1 = _texture4D(deltaSR, r, w.z, muS, nu1);
Color mie1 = _texture4D(deltaSM, r, w.z, muS, nu1);
raymie1.r += ray1.r * pr1 + mie1.r + pm1;
raymie1.g += ray1.g * pr1 + mie1.g + pm1;
raymie1.b += ray1.b * pr1 + mie1.b + pm1;
raymie1.r += ray1.r * pr1 + mie1.r * pm1;
raymie1.g += ray1.g * pr1 + mie1.g * pm1;
raymie1.b += ray1.b * pr1 + mie1.b * pm1;
}
else
{
@ -949,9 +949,9 @@ static Color _groundColor(Color base, Vector3 x, double t, Vector3 v, Vector3 s,
/* light reflected at x0 (=(R[L0]+R[L*])/T(x,x0)) */
Color groundColor;
groundColor.r = base.r * (max(muS, 0.0) * sunLight.r + groundSkyLight.r) * ISun / M_PI;
groundColor.g = base.g * (max(muS, 0.0) * sunLight.g + groundSkyLight.g) * ISun / M_PI;
groundColor.b = base.b * (max(muS, 0.0) * sunLight.b + groundSkyLight.b) * ISun / M_PI;
groundColor.r = base.r * 0.2 * (max(muS, 0.0) * sunLight.r + groundSkyLight.r) * ISun / M_PI;
groundColor.g = base.g * 0.2 * (max(muS, 0.0) * sunLight.g + groundSkyLight.g) * ISun / M_PI;
groundColor.b = base.b * 0.2 * (max(muS, 0.0) * sunLight.b + groundSkyLight.b) * ISun / M_PI;
/* water specular color due to sunLight */
/*if (reflectance.w > 0.0)

View file

@ -120,7 +120,7 @@ static inline int _checkHit(Vector3 eye, Vector3 direction, Vector3* hit, Vector
Color atmosphereGetPreview(Renderer* renderer, double x, double y, double heading)
{
Vector3 eye = {0.0, 8.0, 0.0};
Vector3 eye = {0.0, 7.0, 0.0};
Vector3 direction = {x, y, -1.0};
Vector3 hit, normal;
Matrix4 rotation;
@ -167,7 +167,7 @@ Renderer atmosphereCreatePreviewRenderer()
Renderer result = rendererCreate();
result.camera_location.x = 0.0;
result.camera_location.y = 8.0;
result.camera_location.y = 7.0;
result.camera_location.z = 0.0;
result.getLightStatus = _getLightStatus;

View file

@ -162,8 +162,6 @@ static Color _applyDirectLight(LightDefinition* definition, Renderer* renderer,
normal = v3Normalize(normal);
diffuse = v3Dot(direction_inv, normal);
/*diffuse = pow(diffuse * 0.5 + 0.5, 2.0);*/
diffuse = diffuse * 0.5 + 0.5;
if (diffuse > 0.0)
{
if (material.shininess > 0.0 && definition->reflection > 0.0)
@ -174,13 +172,12 @@ static Color _applyDirectLight(LightDefinition* definition, Renderer* renderer,
specular = v3Dot(reflect, view);
if (specular > 0.0)
{
specular = pow(specular, material.shininess);
specular = pow(specular, material.shininess) * material.reflection;
}
else
{
specular = 0.0;
}
specular *= material.reflection;
}
else
{

View file

@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
TerrainHeightMap* terrainHeightMapCreate()
{
@ -62,7 +63,7 @@ static void _setFixedCount(TerrainHeightMap* heightmap, int new_count)
void terrainHeightmapCopy(TerrainHeightMap* source, TerrainHeightMap* destination)
{
int i, j;
int i;
_setFixedCount(destination, source->fixed_count);
@ -126,6 +127,22 @@ void terrainHeightmapLoad(PackStream* stream, TerrainHeightMap* heightmap)
heightmap->floating_used = 0;
}
static void _prepareBrushStroke(TerrainHeightMap* heightmap, TerrainBrush* brush)
{
double cx = brush->relative_x / TERRAIN_HEIGHTMAP_DETAIL;
double cz = brush->relative_z / TERRAIN_HEIGHTMAP_DETAIL;
double s = brush->smoothed_size + brush->hard_radius;
double sx = s / TERRAIN_HEIGHTMAP_DETAIL;
double sz = s / TERRAIN_HEIGHTMAP_DETAIL;
int x1 = (int)floor(cx - sx);
int x2 = (int)ceil(cx + sx);
int z1 = (int)floor(cz - sz);
int z2 = (int)ceil(cz + sz);
/* TODO Prepare floating data */
}
void terrainBrushElevation(TerrainHeightMap* heightmap, TerrainBrush* brush, double value)
{
}

View file

@ -22,4 +22,10 @@ struct TerrainHeightMap
TerrainHeightMapData floating_data;
};
TerrainHeightMap* terrainHeightMapCreate();
void terrainHeightmapDelete(TerrainHeightMap* heightmap);
void terrainHeightmapCopy(TerrainHeightMap* source, TerrainHeightMap* destination);
void terrainHeightmapSave(PackStream* stream, TerrainHeightMap* heightmap);
void terrainHeightmapLoad(PackStream* stream, TerrainHeightMap* heightmap);
#endif

View file

@ -4,7 +4,6 @@
#include "../shared/types.h"
#include "../noise.h"
#include "../lighting.h"
#include "private.h"
#ifdef __cplusplus
extern "C" {