diff --git a/TODO b/TODO index aee4b50..668f270 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ Technology Preview 2 : -- Create a StandardPreviewClass (with renderer, updateData, changeView, getColor, choices and toggles). - Replace terrain canvas editor by full sculpting editor. => Add a generation dialog, with fixed resolution. => Store local terrain modifications in fully dynamic canvas. @@ -10,11 +9,9 @@ Technology Preview 2 : => Fix artifacts on aerial perspective (mostly when sun is near horizon) => Fix blue appearance at night - Finalize lighting refactoring - => Restore water filtering => Restore cloud lighting - => Restore and improve skydome lighting - Hide Preetham's model. -- Find a proper model for night sky (maybe Shirley). + => Implement weather effect in Bruneton's model. - Improve textures (current model is greatly incorrect). => Separate models (basic texture and covering texture). => Covering texture height should inpact terrain height. @@ -22,10 +19,11 @@ Technology Preview 2 : - Clouds should keep distance to ground. - Fix rendering when inside a cloud layer, with other upper or lower layers. - Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)). -- Top-down previews and explorer renderings should be camera independant. - Translations. Technlogy Preview 3 : +- Find a proper model for night sky (maybe Shirley). +- Create a StandardPreviewClass in C-lib (with renderer, updateData, changeView, getColor, choices and toggles). - Fully move layer management from BaseForm to BaseFormLayer. - Start vegetation system. - Add tone-mapping and exposure control to final image. @@ -64,7 +62,6 @@ Technology Preview 4 : => Interrupt chunk rendering when quitting dialog => Don't display the water if it's below all ground => Try to overcome the near frustum cutting - => Disable specular lighting (dependant on camera location) => Add toggles (for water...) => Max texture size should depend on GPU memory available - Interrupt preview chunk renderings that will be discarded at commit, or that are no more visible. diff --git a/gui_qt/formrender.cpp b/gui_qt/formrender.cpp index a7d35bc..63d5e9f 100644 --- a/gui_qt/formrender.cpp +++ b/gui_qt/formrender.cpp @@ -15,6 +15,7 @@ public: _renderer = rendererCreate(); _renderer->applyTextures = _applyTextures; _renderer->getCameraLocation = _getCameraLocation; + lightingManagerDisableSpecularity(_renderer->lighting); _textures = texturesCreateDefinition(); diff --git a/gui_qt/widgetexplorer.cpp b/gui_qt/widgetexplorer.cpp index 6081fa3..4d48b9c 100644 --- a/gui_qt/widgetexplorer.cpp +++ b/gui_qt/widgetexplorer.cpp @@ -76,6 +76,7 @@ WidgetExplorer::WidgetExplorer(QWidget *parent, CameraDefinition* camera): _renderer->customData[2] = _base_camera; _renderer->applyTextures = _applyTextures; _renderer->getCameraLocation = _getCameraLocation; + lightingManagerDisableSpecularity(_renderer->lighting); _inited = false; _updated = false; diff --git a/lib_paysages/terrain/preview.c b/lib_paysages/terrain/preview.c index 65067c9..da3484c 100644 --- a/lib_paysages/terrain/preview.c +++ b/lib_paysages/terrain/preview.c @@ -34,7 +34,7 @@ static void _getLightingStatus(Renderer* renderer, LightStatus* status, Vector3 light.direction.z = 1.0; light.direction = v3Normalize(light.direction); light.altered = 1; - light.reflection = 1.0; + light.reflection = 0.0; lightingPushLight(status, &light); light.color.r = 0.2; diff --git a/lib_paysages/tools/lighting.c b/lib_paysages/tools/lighting.c index c543950..fa241b6 100644 --- a/lib_paysages/tools/lighting.c +++ b/lib_paysages/tools/lighting.c @@ -16,6 +16,7 @@ typedef struct struct LightingManager { + int specularity_enabled; int callbacks_count; LightFilterCallback callbacks[MAX_CALLBACK_COUNT]; }; @@ -35,6 +36,7 @@ LightingManager* lightingManagerCreate() result = malloc(sizeof(LightingManager)); result->callbacks_count = 0; + result->specularity_enabled = 1; return result; } @@ -65,6 +67,11 @@ void lightingManagerRegisterFilter(LightingManager* filter, FuncLightingAlterLig } } +void lightingManagerDisableSpecularity(LightingManager* manager) +{ + manager->specularity_enabled = 0; +} + LightStatus* lightingCreateStatus(LightingManager* manager, Vector3 location, Vector3 eye) { LightStatus* result; @@ -104,6 +111,11 @@ void lightingPushLight(LightStatus* status, LightDefinition* light) } } + if (!status->manager->specularity_enabled) + { + final.reflection = 0.0; + } + status->lights[status->light_count++] = final; } } diff --git a/lib_paysages/tools/lighting.h b/lib_paysages/tools/lighting.h index 901f7e1..79ae140 100644 --- a/lib_paysages/tools/lighting.h +++ b/lib_paysages/tools/lighting.h @@ -32,6 +32,7 @@ typedef struct LightStatus LightStatus; LightingManager* lightingManagerCreate(); void lightingManagerDelete(LightingManager* filter); void lightingManagerRegisterFilter(LightingManager* filter, FuncLightingAlterLight callback, void* data); +void lightingManagerDisableSpecularity(LightingManager* manager); LightStatus* lightingCreateStatus(LightingManager* manager, Vector3 location, Vector3 eye); void lightingDeleteStatus(LightStatus* status); diff --git a/lib_paysages/water/render.c b/lib_paysages/water/render.c index b05c6cc..830de27 100644 --- a/lib_paysages/water/render.c +++ b/lib_paysages/water/render.c @@ -93,9 +93,9 @@ static inline Vector3 _refractRay(Vector3 incoming, Vector3 normal) } } -static inline void _applyFoam(WaterDefinition* definition, Vector3 location, Vector3 normal, double detail, SurfaceMaterial* material) +static inline Color _getFoamMask(Renderer* renderer, WaterDefinition* definition, Vector3 location, Vector3 normal, double detail) { - Color result = definition->foam_material.base; + Color result; double foam_factor, normal_diff, location_offset; location_offset = 2.0 * detail; @@ -135,12 +135,12 @@ static inline void _applyFoam(WaterDefinition* definition, Vector3 location, Vec if (foam_factor <= 1.0 - definition->foam_coverage) { - return; + return COLOR_TRANSPARENT; } foam_factor = (foam_factor - (1.0 - definition->foam_coverage)) * definition->foam_coverage; - material->reflection = foam_factor * definition->foam_material.reflection + (1.0 - foam_factor) * material->reflection; - material->shininess = foam_factor * definition->foam_material.shininess + (1.0 - foam_factor) * material->shininess; + /* TODO Re-use base lighting status */ + result = renderer->applyLightingToSurface(renderer, location, normal, &definition->foam_material); /* TODO This should be configurable */ if (foam_factor > 0.2) @@ -151,7 +151,8 @@ static inline void _applyFoam(WaterDefinition* definition, Vector3 location, Vec { result.a = 0.8 * (foam_factor / 0.2); } - colorMask(&material->base, &result); + + return result; } static int _alterLight(Renderer* renderer, LightDefinition* light, Vector3 at) @@ -215,7 +216,7 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z) WaterResult result; RayCastingResult refracted; Vector3 location, normal, look_direction; - Color color; + Color color, foam; double detail, depth; location.x = x; @@ -273,7 +274,8 @@ static WaterResult _realGetResult(Renderer* renderer, double x, double z) color.b += result.reflected.b * definition->reflection + result.refracted.b * definition->transparency; /* Merge with foam */ -// _applyFoam(definition, location, normal, detail, &material); + foam = _getFoamMask(renderer, definition, location, normal, detail); + colorMask(&color, &foam); /* Bring color to the camera */ color = renderer->applyMediumTraversal(renderer, location, color);