Skip to content

Commit

Permalink
Added screenshots for volumes & alpha testing to gallery and renamed …
Browse files Browse the repository at this point in the history
…render options
  • Loading branch information
knightcrawler25 committed Jan 16, 2022
1 parent 6e42c6a commit 9aee489
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 33 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A physically based path tracer that runs in a GLSL fragment shader.

![Jinx](./screenshots/Jinx.jpg)

![WW2](./screenshots/ww2.jpg)
![Tropical Island](./screenshots/Tropical_Island.jpg)

Features
--------
Expand All @@ -18,8 +18,9 @@ Features
- Multiple importance sampling (between BSDF and lights)
- Tile rendering
- OpenImageDenoise
- Stochastic alpha testing
- MagicaVoxel style homogeneous volumes
- GLTF/GLB support (In progress)
- Homogeneous volumes (In progress)

Build Instructions
--------
Expand All @@ -32,7 +33,9 @@ https://drive.google.com/file/d/1UFMMoVb5uB7WIvCeHOfQ2dCQSxNMXluB/view

Gallery
--------
![Slum](./screenshots/Slum.jpg)
![Monster](./screenshots/Monster.jpg)
--------
![WW2](./screenshots/ww2.jpg)
--------
![RenderMan Swatch](./screenshots/Renderman_swatch.jpg)
--------
Expand Down
Binary file added screenshots/Monster.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/Slum.jpg
Binary file not shown.
Binary file added screenshots/Tropical_Island.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/rank3police_color_corrected.png
Binary file not shown.
10 changes: 5 additions & 5 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void LoadScene(std::string sceneName)
if (!scene->envMap && !envMaps.empty())
{
scene->AddEnvMap(envMaps[envMapIdx]);
renderOptions.useEnvMap = scene->lights.empty() ? true : false;
renderOptions.enableEnvMap = scene->lights.empty() ? true : false;
renderOptions.envMapIntensity = 1.5f;
}

Expand Down Expand Up @@ -355,13 +355,13 @@ void MainLoop(void* arg)

if (ImGui::CollapsingHeader("Environment"))
{
reloadShaders |= ImGui::Checkbox("Enable Uniform Light", &renderOptions.useUniformLight);
reloadShaders |= ImGui::Checkbox("Enable Uniform Light", &renderOptions.enableUniformLight);

Vec3 uniformLightCol = Vec3::Pow(renderOptions.uniformLightCol, 1.0 / 2.2);
optionsChanged |= ImGui::ColorEdit3("Uniform Light Color (Gamma Corrected)", (float*)(&uniformLightCol), 0);
renderOptions.uniformLightCol = Vec3::Pow(uniformLightCol, 2.2);

reloadShaders |= ImGui::Checkbox("Enable Environment Map", &renderOptions.useEnvMap);
reloadShaders |= ImGui::Checkbox("Enable Environment Map", &renderOptions.enableEnvMap);
optionsChanged |= ImGui::SliderFloat("Enviornment Map Intensity", &renderOptions.envMapIntensity, 0.1f, 10.0f);
optionsChanged |= ImGui::SliderFloat("Enviornment Map Rotation", &renderOptions.envMapRot, 0.0f, 360.0f);
reloadShaders |= ImGui::Checkbox("Hide Emitters", &renderOptions.hideEmitters);
Expand All @@ -376,8 +376,8 @@ void MainLoop(void* arg)

if (renderOptions.enableTonemap)
{
ImGui::Checkbox("Use ACES", &renderOptions.useAces);
if (renderOptions.useAces)
ImGui::Checkbox("Enable ACES", &renderOptions.enableAces);
if (renderOptions.enableAces)
ImGui::Checkbox("Simple ACES Fit", &renderOptions.simpleAcesFit);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ namespace GLSLPT
std::string pathtraceDefines = "";
std::string tonemapDefines = "";

if (scene->renderOptions.useEnvMap && scene->envMap != nullptr)
if (scene->renderOptions.enableEnvMap && scene->envMap != nullptr)
pathtraceDefines += "#define OPT_ENVMAP\n";

if (!scene->lights.empty())
Expand All @@ -413,7 +413,7 @@ namespace GLSLPT
pathtraceDefines += "#define OPT_RR_DEPTH " + std::to_string(scene->renderOptions.RRDepth) + "\n";
}

if (scene->renderOptions.useUniformLight)
if (scene->renderOptions.enableUniformLight)
pathtraceDefines += "#define OPT_UNIFORM_LIGHT\n";

if (scene->renderOptions.openglNormalMap)
Expand Down Expand Up @@ -773,7 +773,7 @@ namespace GLSLPT
glUniform1f(glGetUniformLocation(shaderObject, "camera.fov"), scene->camera->fov);
glUniform1f(glGetUniformLocation(shaderObject, "camera.focalDist"), scene->camera->focalDist);
glUniform1f(glGetUniformLocation(shaderObject, "camera.aperture"), scene->camera->aperture);
glUniform1i(glGetUniformLocation(shaderObject, "useEnvMap"), scene->envMap == nullptr ? false : scene->renderOptions.useEnvMap);
glUniform1i(glGetUniformLocation(shaderObject, "enableEnvMap"), scene->envMap == nullptr ? false : scene->renderOptions.enableEnvMap);
glUniform1f(glGetUniformLocation(shaderObject, "envMapIntensity"), scene->renderOptions.envMapIntensity);
glUniform1f(glGetUniformLocation(shaderObject, "envMapRot"), scene->renderOptions.envMapRot / 360.0f);
glUniform1i(glGetUniformLocation(shaderObject, "maxDepth"), scene->renderOptions.maxDepth);
Expand All @@ -792,7 +792,7 @@ namespace GLSLPT
glUniform1f(glGetUniformLocation(shaderObject, "camera.fov"), scene->camera->fov);
glUniform1f(glGetUniformLocation(shaderObject, "camera.focalDist"), scene->camera->focalDist);
glUniform1f(glGetUniformLocation(shaderObject, "camera.aperture"), scene->camera->aperture);
glUniform1i(glGetUniformLocation(shaderObject, "useEnvMap"), scene->envMap == nullptr ? false : scene->renderOptions.useEnvMap);
glUniform1i(glGetUniformLocation(shaderObject, "enableEnvMap"), scene->envMap == nullptr ? false : scene->renderOptions.enableEnvMap);
glUniform1f(glGetUniformLocation(shaderObject, "envMapIntensity"), scene->renderOptions.envMapIntensity);
glUniform1f(glGetUniformLocation(shaderObject, "envMapRot"), scene->renderOptions.envMapRot / 360.0f);
glUniform1i(glGetUniformLocation(shaderObject, "maxDepth"), scene->dirty ? 2 : scene->renderOptions.maxDepth);
Expand All @@ -805,7 +805,7 @@ namespace GLSLPT
shaderObject = tonemapShader->getObject();
glUniform1f(glGetUniformLocation(shaderObject, "invSampleCounter"), 1.0f / (sampleCounter));
glUniform1i(glGetUniformLocation(shaderObject, "enableTonemap"), scene->renderOptions.enableTonemap);
glUniform1i(glGetUniformLocation(shaderObject, "useAces"), scene->renderOptions.useAces);
glUniform1i(glGetUniformLocation(shaderObject, "enableAces"), scene->renderOptions.enableAces);
glUniform1i(glGetUniformLocation(shaderObject, "simpleAcesFit"), scene->renderOptions.simpleAcesFit);
glUniform3f(glGetUniformLocation(shaderObject, "backgroundCol"), scene->renderOptions.backgroundCol.x, scene->renderOptions.backgroundCol.y, scene->renderOptions.backgroundCol.z);
tonemapShader->StopUsing();
Expand Down
12 changes: 6 additions & 6 deletions src/core/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ namespace GLSLPT
enableRR = true;
enableDenoiser = false;
enableTonemap = true;
useAces = false;
enableAces = false;
openglNormalMap = true;
useEnvMap = false;
useUniformLight = false;
enableEnvMap = false;
enableUniformLight = false;
hideEmitters = false;
enableBackground = false;
transparentBackground = false;
Expand All @@ -83,11 +83,11 @@ namespace GLSLPT
bool enableRR;
bool enableDenoiser;
bool enableTonemap;
bool useAces;
bool enableAces;
bool simpleAcesFit;
bool openglNormalMap;
bool useEnvMap;
bool useUniformLight;
bool enableEnvMap;
bool enableUniformLight;
bool hideEmitters;
bool enableBackground;
bool transparentBackground;
Expand Down
24 changes: 16 additions & 8 deletions src/loaders/Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace GLSLPT
{
char envMap[200] = "none";
char enableRR[10] = "none";
char useAces[10] = "none";
char enableAces[10] = "none";
char openglNormalMap[10] = "none";
char hideEmitters[10] = "none";
char transparentBackground[10] = "none";
Expand All @@ -267,6 +267,7 @@ namespace GLSLPT
char enableTonemap[10] = "none";
char enableRoughnessMollification[10] = "none";
char enableVolumeMIS[10] = "none";
char enableUniformLight[10] = "none";

while (fgets(line, kMaxLineLength, file))
{
Expand All @@ -285,7 +286,7 @@ namespace GLSLPT
sscanf(line, " enablerr %s", enableRR);
sscanf(line, " rrdepth %i", &renderOptions.RRDepth);
sscanf(line, " enabletonemap %s", enableTonemap);
sscanf(line, " useaces %s", useAces);
sscanf(line, " enableaces %s", enableAces);
sscanf(line, " texarraywidth %i", &renderOptions.texArrayWidth);
sscanf(line, " texarrayheight %i", &renderOptions.texArrayHeight);
sscanf(line, " openglnormalmap %s", openglNormalMap);
Expand All @@ -298,20 +299,22 @@ namespace GLSLPT
sscanf(line, " enableroughnessmollification %s", enableRoughnessMollification);
sscanf(line, " roughnessmollificationamt %f", &renderOptions.roughnessMollificationAmt);
sscanf(line, " enablevolumemis %s", enableVolumeMIS);
sscanf(line, " enableuniformlight %s", enableUniformLight);
sscanf(line, " uniformlightcolor %f %f %f", &renderOptions.uniformLightCol.x, &renderOptions.uniformLightCol.y, &renderOptions.uniformLightCol.z);
}

if (strcmp(envMap, "none") != 0)
{
scene->AddEnvMap(path + envMap);
renderOptions.useEnvMap = true;
renderOptions.enableEnvMap = true;
}
else
renderOptions.useEnvMap = false;
renderOptions.enableEnvMap = false;

if (strcmp(useAces, "false") == 0)
renderOptions.useAces = false;
else if (strcmp(useAces, "true") == 0)
renderOptions.useAces = true;
if (strcmp(enableAces, "false") == 0)
renderOptions.enableAces = false;
else if (strcmp(enableAces, "true") == 0)
renderOptions.enableAces = true;

if (strcmp(enableRR, "false") == 0)
renderOptions.enableRR = false;
Expand Down Expand Up @@ -358,6 +361,11 @@ namespace GLSLPT
else if (strcmp(enableVolumeMIS, "true") == 0)
renderOptions.enableVolumeMIS = true;

if (strcmp(enableUniformLight, "false") == 0)
renderOptions.enableUniformLight = false;
else if (strcmp(enableUniformLight, "true") == 0)
renderOptions.enableUniformLight = true;

if (!renderOptions.independentRenderSize)
renderOptions.windowResolution = renderOptions.renderResolution;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shaders/common/globals.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define TWO_PI 6.28318530717958648
#define INV_TWO_PI 0.15915494309189533
#define INV_4_PI 0.07957747154594766
#define EPS 0.001
#define EPS 0.0001
#define INF 1000000.0

#define QUAD_LIGHT 0
Expand Down
4 changes: 2 additions & 2 deletions src/shaders/tonemap.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ in vec2 TexCoords;
uniform sampler2D pathTraceTexture;
uniform float invSampleCounter;
uniform bool enableTonemap;
uniform bool useAces;
uniform bool enableAces;
uniform bool simpleAcesFit;
uniform vec3 backgroundCol;

Expand Down Expand Up @@ -102,7 +102,7 @@ void main()

if (enableTonemap)
{
if (useAces)
if (enableAces)
{
if (simpleAcesFit)
color = ACES(color);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ajaxTestScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace GLSLPT
renderOptions.tileHeight = 128;
renderOptions.tileWidth = 128;
renderOptions.envMapIntensity = 5.0f;
renderOptions.useEnvMap = true;
renderOptions.enableEnvMap = true;
scene->AddCamera(Vec3(0.0f, 0.125f, -0.45f), Vec3(0.0f, 0.125f, 0.0f), 60.0f);

int mesh_id = scene->AddMesh("./assets/ajax/ajax.obj");
Expand Down
2 changes: 1 addition & 1 deletion src/tests/boyTestScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace GLSLPT
renderOptions.tileWidth = 144;
renderOptions.envMapIntensity = 1.0f;
renderOptions.renderResolution = iVec2(1280, 720);
renderOptions.useEnvMap = false;
renderOptions.enableEnvMap = false;
scene->AddCamera(Vec3(0.3f, 0.11f, 0.0f), Vec3(0.2f, 0.095f, 0.0f), 60.0f);
scene->camera->aperture = 1e-6f;
scene->camera->focalDist = 0.262f;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/cornellTestScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace GLSLPT
renderOptions.tileHeight = 200;
renderOptions.tileWidth = 200;
renderOptions.envMapIntensity = 1.0f;
renderOptions.useEnvMap = true;
renderOptions.enableEnvMap = true;
renderOptions.renderResolution.x = 800;
renderOptions.renderResolution.y = 800;
scene->AddCamera(Vec3(0.276f, 0.275f, -0.75f), Vec3(0.276f, 0.275f, 0), 40.0f);
Expand Down

0 comments on commit 9aee489

Please sign in to comment.