diff --git a/TODO b/TODO index ec86dfd..434c9f2 100644 --- a/TODO +++ b/TODO @@ -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. diff --git a/gui_qt/widgetheightmap.cpp b/gui_qt/widgetheightmap.cpp index 0e11201..50f1e17 100644 --- a/gui_qt/widgetheightmap.cpp +++ b/gui_qt/widgetheightmap.cpp @@ -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); } } diff --git a/lib_paysages/atmosphere/bruneton.c b/lib_paysages/atmosphere/bruneton.c index 824730d..885992d 100644 --- a/lib_paysages/atmosphere/bruneton.c +++ b/lib_paysages/atmosphere/bruneton.c @@ -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) diff --git a/lib_paysages/atmosphere/preview.c b/lib_paysages/atmosphere/preview.c index 89f9502..1b09359 100644 --- a/lib_paysages/atmosphere/preview.c +++ b/lib_paysages/atmosphere/preview.c @@ -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; diff --git a/lib_paysages/lighting.c b/lib_paysages/lighting.c index 8cdbea0..590c0dd 100644 --- a/lib_paysages/lighting.c +++ b/lib_paysages/lighting.c @@ -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 { diff --git a/lib_paysages/terrain/painting.c b/lib_paysages/terrain/painting.c index 975e401..2edd9e0 100644 --- a/lib_paysages/terrain/painting.c +++ b/lib_paysages/terrain/painting.c @@ -6,6 +6,7 @@ #include #include +#include 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) { } diff --git a/lib_paysages/terrain/private.h b/lib_paysages/terrain/private.h index 3c54205..2439925 100644 --- a/lib_paysages/terrain/private.h +++ b/lib_paysages/terrain/private.h @@ -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 diff --git a/lib_paysages/terrain/public.h b/lib_paysages/terrain/public.h index 63c4332..dd9c9a0 100644 --- a/lib_paysages/terrain/public.h +++ b/lib_paysages/terrain/public.h @@ -4,7 +4,6 @@ #include "../shared/types.h" #include "../noise.h" #include "../lighting.h" -#include "private.h" #ifdef __cplusplus extern "C" {