Skip to content

Commit

Permalink
Gi rendering (#516)
Browse files Browse the repository at this point in the history
* GI probes initial

* beautify debug view

* probe irradiance

* GI lighting with probes

* hacks cleanup

* probe caching initial

* performance: FREE_BIT

* probe lighting cleanup

#510

* probe hash-map: colision resolver

#510

* avoid ultra-dark spits in woods

* GI in progress: probe-gbuffer

* probe lighting in progress

* rework probes allocation

* updates to rt-scene

* improved integration; fix overflow in probes atlas

* improve probe distribution; tune lighting

* move probesLighting data into 11-bit float image

* multibounce initial

TODO: fix r/w race in probesLightingPrev

* probes in progress; fix race in lighting pass

* use sky irradiance as fallback, if we hvae no probes

* probe integration in progress

* improve bad-probe rejection

* fixup

* fix z-fighting in probes

* GI: check gpu limits

* generalize GI vs nonGI ambient

* more light in forrest
  • Loading branch information
Try authored Sep 14, 2023
1 parent e70d386 commit 8350b04
Show file tree
Hide file tree
Showing 39 changed files with 1,822 additions and 179 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ Rendering distance is not customizable.
| `-g1` | assume a Gothic 1 installation |
| `-g2` | assume a Gothic 2 installation |
| `-rt <boolean>` | explicitly enable or disable ray-query |
| `-gi <boolean>` | explicitly enable or disable ray-traced global illumination |
| `-ms <boolean>` | explicitly enable or disable meshlets |
| `-window` | windowed debugging mode (not to be used for playing) |
5 changes: 5 additions & 0 deletions game/commandline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ CommandLine::CommandLine(int argc, const char** argv) {
if(i<argc)
isRQuery = (std::string_view(argv[i])!="0" && std::string_view(argv[i])!="false");
}
else if(arg=="-gi") {
++i;
if(i<argc)
isGi = (std::string_view(argv[i])!="0" && std::string_view(argv[i])!="false");
}
else if(arg=="-ms") {
++i;
if(i<argc)
Expand Down
2 changes: 2 additions & 0 deletions game/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CommandLine {
bool isValidationMode() const { return isDebug; }
bool isWindowMode() const { return isWindow; }
bool isRayQuery() const { return isRQuery; }
bool isRtGi() const { return isGi; }
bool isMeshShading() const { return isMeshSh; }
bool doStartMenu() const { return !noMenu; }
bool doForceG1() const { return forceG1; }
Expand All @@ -52,6 +53,7 @@ class CommandLine {
bool isRQuery = true;
bool isMeshSh = true;
#endif
bool isGi = false;
bool forceG1 = false;
bool forceG2 = false;
};
Expand Down
19 changes: 12 additions & 7 deletions game/gothic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,25 @@ Gothic::Gothic() {
showFpsCounter = systemPackIniFile->getI("DEBUG","Show_FPS_Counter");
hideFocus = systemPackIniFile->getI("PARAMETERS","HideFocus");

if(Resources::device().properties().raytracing.rayQuery)
opts.doRayQuery = CommandLine::inst().isRayQuery();

if(hasMeshShader())
opts.doMeshShading = CommandLine::inst().isMeshShading();

#ifndef NDEBUG
setMarvinEnabled(true);
setFRate(true);
#else
setMarvinEnabled(CommandLine::inst().isDevMode());
#endif

auto& gpu = Resources::device().properties();
if(gpu.raytracing.rayQuery) {
opts.doRayQuery = CommandLine::inst().isRayQuery();
if(gpu.tex2d.maxSize>=4096 && gpu.hasStorageFormat(R11G11B10UF) && gpu.hasStorageFormat(R16)) {
opts.doRtGi = CommandLine::inst().isRtGi();
}
}

if(hasMeshShader()) {
opts.doMeshShading = CommandLine::inst().isMeshShading();
}

wrldDef = CommandLine::inst().wrldDef;

baseIniFile.reset(new IniFile(nestedPath({u"system",u"Gothic.ini"},Dir::FT_File)));
Expand All @@ -77,7 +83,6 @@ Gothic::Gothic() {
defaults->set("SKY_OUTDOOR", "zMoonSize", 400);
defaults->set("SKY_OUTDOOR", "zMoonAlpha", 255);

auto& gpu = Resources::device().properties();
defaults->set("RENDERER_D3D", "zFogRadial", 1); // sunshafts
defaults->set("ENGINE", "zEnvMappingEnabled", 1); // reflections
defaults->set("ENGINE", "zCloudShadowScale", gpu.type==Tempest::DeviceType::Discrete); // ssao
Expand Down
3 changes: 3 additions & 0 deletions game/gothic.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Gothic final {

struct Options {
bool doRayQuery = false;
bool doRtGi = false;
bool doMeshShading = false;
};

Expand Down Expand Up @@ -109,6 +110,8 @@ class Gothic final {
bool doClock() const { return showTime; }
void setClock(bool t) { showTime = t; }

Tempest::Signal<void()> toggleGi;

LoadState checkLoading() const;
bool finishLoading();
void startLoad(std::string_view banner, const std::function<std::unique_ptr<GameSession>(std::unique_ptr<GameSession>&&)> f);
Expand Down
7 changes: 5 additions & 2 deletions game/graphics/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ static Tempest::Color toColor(glm::u8vec4 v) {
Material::Material(const phoenix::material& m, bool enableAlphaTest) {
tex = Resources::loadTexture(m.texture);
if(tex==nullptr) {
if(!m.texture.empty())
tex = Resources::loadTexture("DEFAULT.TGA"); else
if(!m.texture.empty()) {
tex = Resources::loadTexture("DEFAULT.TGA");
} else {
tex = Resources::loadTexture(toColor(m.color));
enableAlphaTest &= (m.color.a!=255);
}
}

loadFrames(m);
Expand Down
Loading

0 comments on commit 8350b04

Please sign in to comment.