Skip to content

Commit

Permalink
tools: dropped supporting spherical-harmonics-based lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
NicSavichev committed Jan 15, 2024
1 parent bb2ed74 commit d9498fb
Show file tree
Hide file tree
Showing 33 changed files with 4 additions and 1,152 deletions.
3 changes: 0 additions & 3 deletions prog/tools/AssetViewer/av_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ extern TEXTUREID load_land_micro_details(const DataBlock &micro);
static inline void updateLight(bool update_var_before = false)
{
ISceneLightService *ltSrv = EDITORCORE->queryEditorInterface<ISceneLightService>();
ltSrv->calcDefaultSHLighting();

if (update_var_before)
ltSrv->updateShaderVars();
Expand Down Expand Up @@ -1075,8 +1074,6 @@ void load_settings(DataBlock &blk, AssetLightData *ald, const AssetLightData *al
ald->rdbgUseChrome = blk.getBool("rdbgUseChrome", ald_def->rdbgUseChrome);

DataBlock appBlk(::get_app().getWorkspace().getAppPath());
ltSrv->installSHLightingProvider(NULL,
appBlk.getBlockByNameEx("projectDefaults")->getBlockByNameEx("l2d")->getBool("make_sun_lt", false));

updateLight();
detectRenderDebug();
Expand Down
21 changes: 0 additions & 21 deletions prog/tools/AssetViewer/av_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,16 @@
#include <libTools/staticGeom/geomObject.h>
#include <libTools/util/strUtil.h>

#include <math/dag_mathAng.h>


#define SUN_DIRECTION_ZENITH (PI / 4.0)
#define SUN_DIRECTION_AZIMUTH PI
#define SUN_COLOR E3DCOLOR(255, 255, 220, 255)
#define SUN_BRIGHTNESS 2500.0
#define SKY_COLOR E3DCOLOR(160, 180, 220, 255)
#define EARTH_COLOR E3DCOLOR(45, 45, 55, 255)


SH3Lighting olSh3Light;


void init_geom_object_lighting()
{
olSh3Light.clear();

GeomObject::setLightAngles(SUN_DIRECTION_ZENITH, SUN_DIRECTION_AZIMUTH);
GeomObject::setAmbientLight(SKY_COLOR, 1, EARTH_COLOR, 1);
GeomObject::setDirectLight(SUN_COLOR, 1);

Point3 dir = ::sph_ang_to_dir(Point2(SUN_DIRECTION_AZIMUTH, SUN_DIRECTION_ZENITH));
real cosSunHalfAngle = cosf(DegToRad(2.5));

Color4 lightColor = color4(SUN_COLOR) * SUN_BRIGHTNESS;

::add_hemisphere_sphharm(olSh3Light.sh, dir, cosSunHalfAngle, color3(lightColor));

for (int i = 0; i < SPHHARM_NUM3; ++i)
olSh3Light.sh[i] /= 8.0;

::rotate_sphharm(olSh3Light.sh, olSh3Light.sh, -TMatrix::IDENT);
}
4 changes: 0 additions & 4 deletions prog/tools/AssetViewer/av_util.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#pragma once


#include <math/dag_SHlight.h>

extern SH3Lighting olSh3Light;

void init_geom_object_lighting();
2 changes: 0 additions & 2 deletions prog/tools/dagUtils/dagConvInst/dag_convinst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <generic/dag_smallTab.h>
#include <util/dag_string.h>
#include <math/dag_math3d.h>
#include <math/dag_SHmath.h>
#include <3d/dag_materialData.h>
#include <math/dag_SHlight.h>
#include <libTools/dagFileRW/dagFileFormat.h>
#include <libTools/util/strUtil.h>
#include <debug/dag_debug.h>
Expand Down
15 changes: 0 additions & 15 deletions prog/tools/dagUtils/dagMatRemap/mat_remap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <generic/dag_smallTab.h>
#include <util/dag_string.h>
#include <math/dag_math3d.h>
#include <math/dag_SHmath.h>
#include <3d/dag_materialData.h>
#include <math/dag_SHlight.h>
#include <libTools/dagFileRW/dagFileFormat.h>
#include <libTools/util/strUtil.h>
#include <debug/dag_debug.h>
Expand All @@ -29,19 +27,6 @@ static DagColor dagcolor(const IPoint3 &i) { return DagColor(i[0], i[1], i[2]);

int _cdecl main(int argc, char **argv)
{
/*for (int i = 0; i < 10; ++i)
{
SH3Lighting lighting;
lighting.clear();
float cosa = cos(DegToRad(i*i+1));
add_hemisphere_sphharm(lighting.sh, Point3(0,1,0), cosa,
Color3(1,1,1)*2500*0.66666);
//cos(DegToRad(2.5))
Color3 color = lighting.getDiffuseLighting(Point3(0,1,0));
printf("color cosa = %g %g (%g/%g = %g)\n",
cosa, (1-cosa)*(1-cosa), color.r, PI*(1-cosa)*2500, color.r/(PI*(1-cosa)*2500));
}*/

if (argc < 3)
{
::show_usage();
Expand Down
2 changes: 0 additions & 2 deletions prog/tools/dagUtils/dagOptMat/mat_remap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include <generic/dag_smallTab.h>
#include <util/dag_string.h>
#include <math/dag_math3d.h>
#include <math/dag_SHmath.h>
#include <3d/dag_materialData.h>
#include <math/dag_SHlight.h>
#include <libTools/dagFileRW/dagFileFormat.h>
#include <libTools/util/strUtil.h>
#include <debug/dag_debug.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <EditorCore/ec_ObjectCreator.h>

#include <3d/dag_drv3d.h>
#include <math/dag_SHlight.h>
#include <3d/dag_render.h>
#include <render/dag_cur_view.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <EditorCore/ec_ObjectCreator.h>

#include <3d/dag_drv3d.h>
#include <math/dag_SHlight.h>
#include <3d/dag_render.h>

#include <shaders/dag_dynSceneRes.h>
Expand Down
50 changes: 0 additions & 50 deletions prog/tools/libTools/sceneBuilder/nsb_StdTonemapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include <ioSys/dag_dataBlock.h>
#include <sceneBuilder/nsb_StdTonemapper.h>
#include <libTools/util/sHmathUtil.h>
#include <debug/dag_debug.h>


Expand Down Expand Up @@ -134,52 +133,3 @@ void StaticSceneBuilder::Splitter::load(const DataBlock &blk, bool init_def)
optimizeForVertexCache = blk.getBool("optimizeForVertexCache", optimizeForVertexCache);
buildShadowSD = blk.getBool("buildShadowSD", buildShadowSD);
}

void StaticSceneBuilder::StdTonemapper::mapSphHarm(Color3 sh[SPHHARM_NUM3]) const
{
// gamma-correct resulting diffuse lighting =)
Color3 ish[SPHHARM_NUM3];

memcpy(ish, sh, sizeof(ish));

ish[SPHHARM_00] *= PI;

ish[SPHHARM_1m1] *= 2.094395f;
ish[SPHHARM_10] *= 2.094395f;
ish[SPHHARM_1p1] *= 2.094395f;

ish[SPHHARM_2m2] *= 0.785398f;
ish[SPHHARM_2m1] *= 0.785398f;
ish[SPHHARM_20] *= 0.785398f;
ish[SPHHARM_2p1] *= 0.785398f;
ish[SPHHARM_2p2] *= 0.785398f;

class GammaTransformCB : public SH3Color3TransformCB
{
public:
const StdTonemapper &m;

GammaTransformCB(const StdTonemapper &_m) : m(_m) {}
Color3 transform(const Color3 &c)
{
Color4 c2 = Color4(c.r, c.g, c.b, 1.0);
c2.clamp0();
c2 = m.mapColor(c2);
return Color3(c2.r, c2.g, c2.b);
}
} cb(*this);

transform_sphharm(ish, sh, cb);

sh[SPHHARM_00] /= PI;

sh[SPHHARM_1m1] /= 2.094395f;
sh[SPHHARM_10] /= 2.094395f;
sh[SPHHARM_1p1] /= 2.094395f;

sh[SPHHARM_2m2] /= 0.785398f;
sh[SPHHARM_2m1] /= 0.785398f;
sh[SPHHARM_20] /= 0.785398f;
sh[SPHHARM_2p1] /= 0.785398f;
sh[SPHHARM_2p2] /= 0.785398f;
}
12 changes: 0 additions & 12 deletions prog/tools/libTools/shaderResBuilder/dynSceneResSrc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <libTools/dagFileRW/normalizeNodeTm.h>
#include <shaders/dag_shaderMesh.h>
#include <math/dag_mesh.h>
#include <math/dag_SHmath.h>
#include <math/dag_boundingSphere.h>
#include <generic/dag_tabUtils.h>
#include <generic/dag_initOnDemand.h>
Expand Down Expand Up @@ -120,17 +119,6 @@ void DynamicRenderableSceneLodsResSrc::splitRealTwoSided(Mesh &m, Bitarray &is_m
split_real_two_sided(m, is_material_real_two_sided_array, side_channel_id);
}

struct PrtSamples
{
struct Sample
{
float prtWeights[SPHHARM_NUM3];
Point3 pt;
};
float ledge;
SmallTab<Sample, TmpmemAlloc> samples;
};

class HasAOChanCB : public ShaderChannelsEnumCB
{
public:
Expand Down
1 change: 0 additions & 1 deletion prog/tools/libTools/staticGeom/geomObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <libTools/shaderResBuilder/matSubst.h>
#include <libTools/util/prepareBillboardMesh.h>
#include <libTools/util/progressInd.h>
#include <libTools/util/sHmathUtil.h>
#include <sceneBuilder/nsb_StdTonemapper.h>

#include <shaders/dag_shaders.h>
Expand Down
1 change: 0 additions & 1 deletion prog/tools/libTools/util/jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Sources =
hash.cpp
hashSaveCb.cpp
undosys.cpp
sHmathUtil.cpp
conProgressIndicator.cpp
fileUtils.cpp
conLogWriter.cpp
Expand Down
81 changes: 0 additions & 81 deletions prog/tools/libTools/util/sHmathUtil.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions prog/tools/sceneTools/daEditorX/HeightmapLand/hmlPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

#include "Brushes/hmlBrush.h"

#include <math/dag_SHlight.h>

#include <math/dag_adjpow2.h>
#include <image/dag_tga.h>
#include <image/dag_texPixel.h>
Expand Down
11 changes: 0 additions & 11 deletions prog/tools/sceneTools/daEditorX/StaticGeom/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include <coolConsole/coolConsole.h>

#include <math/dag_SHmath.h>

#include <shaders/dag_shaders.h>
// #include <texConverter/TextureConverterDlg.h>
#include <debug/dag_debug.h>
Expand Down Expand Up @@ -535,15 +533,6 @@ void StaticGeometryPlugin::unregistered()
}


void StaticGeometryPlugin::onLightingSettingsChanged()
{
ISceneLightService *ltService = DAGORED2->queryEditorInterface<ISceneLightService>();

if (!ltService || !ltService->calcSHLighting(sh3Light))
sh3Light.clear();
}


// back-loop
void set_cached_debug_lines_wtm(const TMatrix &tm) { dagRender->setLinesTm(tm); }

Expand Down
5 changes: 1 addition & 4 deletions prog/tools/sceneTools/daEditorX/StaticGeom/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <de3_occluderGeomProvider.h>
#include <de3_collisionPreview.h>

#include <math/dag_SHlight.h>
#include <de3_fileTracker.h>


Expand Down Expand Up @@ -112,7 +111,7 @@ class StaticGeometryPlugin : public IGenEditorPlugin,

// ILightingChangeClient
virtual void onLightingChanged() {}
virtual void onLightingSettingsChanged();
void onLightingSettingsChanged() override {}

// IFileChangedNotify
virtual void onFileChanged(int file_name_id);
Expand All @@ -134,8 +133,6 @@ class StaticGeometryPlugin : public IGenEditorPlugin,
bool loadingFailed;
collisionpreview::Collision collision;

SH3Lighting sh3Light;

String StaticGeometryPlugin::getPluginFilePath(const char *fileName);

void loadGeometry();
Expand Down
1 change: 0 additions & 1 deletion prog/tools/sceneTools/daEditorX/binSceneView/strmlevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

class DataBlock;
class LandMeshRenderer;
class SH3LightingManager;
class RendInstShadowsManager;
class DynamicRenderableSceneInstance;
class AcesResource;
Expand Down
1 change: 0 additions & 1 deletion prog/tools/sceneTools/daEditorX/de_ProjectSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <osApiWrappers/dag_files.h>
#include <libTools/util/strUtil.h>
#include <ioSys/dag_dataBlock.h>
#include <math/dag_SHlight.h>
#include <libTools/dtx/dtxHeader.h>
#include <workCycle/dag_gameSettings.h>
#include <debug/dag_debug.h>
Expand Down
Loading

0 comments on commit d9498fb

Please sign in to comment.