Skip to content

Commit 8b4c4fd

Browse files
committed
v1.4.0
1 parent 6ae9cbd commit 8b4c4fd

32 files changed

+769
-312
lines changed

CMakeSettings.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
"name": "USE_MSVC_RUNTIME_LIBRARY_DLL",
2121
"value": "False",
2222
"type": "BOOL"
23-
},
24-
{
25-
"name": "SPDLOG_ENABLE_PCH",
26-
"value": "True",
27-
"type": "BOOL"
2823
}
2924
]
3025
},
@@ -48,11 +43,6 @@
4843
"name": "USE_MSVC_RUNTIME_LIBRARY_DLL",
4944
"value": "False",
5045
"type": "BOOL"
51-
},
52-
{
53-
"name": "SPDLOG_ENABLE_PCH",
54-
"value": "True",
55-
"type": "BOOL"
5646
}
5747
]
5848
},
@@ -76,10 +66,28 @@
7666
"name": "USE_MSVC_RUNTIME_LIBRARY_DLL",
7767
"value": "False",
7868
"type": "BOOL"
69+
}
70+
]
71+
},
72+
{
73+
"name": "x64-Console-Debug",
74+
"generator": "Ninja",
75+
"configurationType": "Debug",
76+
"inheritEnvironments": [ "msvc_x64_x64" ],
77+
"buildRoot": "${projectDir}\\out\\build\\${name}",
78+
"installRoot": "${projectDir}\\out\\install\\${name}",
79+
"cmakeCommandArgs": "",
80+
"buildCommandArgs": "",
81+
"ctestCommandArgs": "",
82+
"variables": [
83+
{
84+
"name": "WINDOW_APP",
85+
"value": "False",
86+
"type": "BOOL"
7987
},
8088
{
81-
"name": "SPDLOG_ENABLE_PCH",
82-
"value": "True",
89+
"name": "USE_MSVC_RUNTIME_LIBRARY_DLL",
90+
"value": "False",
8391
"type": "BOOL"
8492
}
8593
]

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div id="toc">
55
<ul style="list-style: none;">
66
<summary>
7-
<h1>PBR Visualiser 1.3.9</h1>
7+
<h1>PBR Visualiser 1.4.0</h1>
88
</summary>
99
</ul>
1010
</div>
@@ -36,17 +36,19 @@
3636

3737
## 📚 Used Libraries
3838
- 🎮 **OpenGL** - rendering engine
39-
- 🖱️ **ImGui** - UI handling (GUI mode)
40-
- 📐 **GLM** - mathematical operations
41-
- 🖼️ **GLI** - DDS file support
42-
- 🏞️ **GLFW** - window & input handling
43-
- 📜 **spdlog** - logging
44-
- 📂 **cgltf** - loading GLTF/GLB objects
45-
- 📂 **OpenFBX** - FBX file support
46-
- 📦 **tiny_obj_loader** - OBJ file support
47-
- 🖼️ **stbi_image** - image loading (HDR, JPG, PNG)
48-
- 💾 **stbi_image_write** - image saving
49-
- 🗂️ **tinyfiledialogs** - dialog windows
39+
- 🖱️ [**ImGui**](https://github.com/ocornut/imgui) - UI handling (GUI mode)
40+
- 📊 [**ImPlot**](https://github.com/epezent/implot) - charts and statistics data visualization
41+
- 📐 [**GLM**](https://github.com/g-truc/glm) - mathematical operations
42+
- 🖼️ [**GLI**](https://github.com/g-truc/gli) - DDS file support
43+
- 🏞️ [**GLFW**](https://github.com/glfw/glfw) - window & input handling
44+
- 📜 [**spdlog**](https://github.com/gabime/spdlog) - logging
45+
- 📂 [**cgltf**](https://github.com/jkuhlmann/cgltf) - loading GLTF/GLB objects
46+
- 📂 [**OpenFBX**](https://github.com/nem0/OpenFBX) - FBX file support
47+
- 📦 [**tiny_obj_loader**](https://github.com/tinyobjloader/tinyobjloader) - OBJ file support
48+
- 🖼️ [**stb_image**](https://github.com/nothings/stb) - image loading (HDR, JPG, PNG)
49+
- 💾 [**stb_image_write**](https://github.com/nothings/stb) - image saving
50+
- 🗂️ [**tinyfiledialogs**](https://sourceforge.net/projects/tinyfiledialogs/) - dialog windows
51+
- 🔤 [FreeType](https://github.com/freetype/freetype) - font rendering
5052

5153
## 🎨 Windowed Mode (GUI)
5254
- 🖥️ **User Interface**: **ImGui**
@@ -120,10 +122,11 @@ For more examples, see [Examples.md](./Examples.md).
120122
- 🔑 OpenSSL
121123
- 🛠️ CMake >= 3.21
122124
- 🖥️ Git
123-
- 🎮 OpenGL >= 4.5
125+
- 🎮 OpenGL >= 4.3
126+
- 💻 C++20 compatible compiler
124127

125128
**For Running:**
126-
- 🎮 OpenGL >= 4.5
129+
- 🎮 OpenGL >= 4.3
127130
- 📜 MSVCP140.dll
128131
- 📜 VCRUNTIME140.dll
129132
- 📜 VCRUNTIME140_1.dll

cmake/global_settings.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ set(GLFW_BUILD_TESTS OFF CACHE INTERNAL "Build the GLFW test programs")
1313
set(GLFW_BUILD_DOCS OFF CACHE INTERNAL "Build the GLFW documentation")
1414
set(GLFW_INSTALL OFF CACHE INTERNAL "Generate installation target")
1515
set(GLI_TEST_ENABLE OFF CACHE INTERNAL "Build the GLI test programs")
16-
set(GLM_ENABLE_CXX_20 ON CACHE INTERNAL "Enable c++20 for GLM")
16+
set(GLM_ENABLE_CXX_20 ON CACHE INTERNAL "Enable c++20 for GLM")
17+
18+
set(SPDLOG_ENABLE_PCH ON CACHE INTERNAL "Enable pch for spdlog")

git_images/screenshot1.png

-224 KB
Loading

git_images/screenshot2.png

90.1 KB
Loading

res/build_resources/imgui.ini

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ Size=400,400
44
Collapsed=0
55

66
[Window][PBR VISUALISER]
7-
Pos=18,8
8-
Size=402,1000
7+
Pos=18,2
8+
Size=402,1006
99
Collapsed=0
1010

1111
[Window][Camera]
1212
Pos=1500,44
13-
Size=368,137
13+
Size=368,112
1414
Collapsed=0
15-
DockId=0x00000002,0
15+
DockId=0x00000004,0
1616

1717
[Window][Skybox]
18-
Pos=1500,183
19-
Size=368,564
18+
Pos=1500,253
19+
Size=368,594
2020
Collapsed=0
2121
DockId=0x00000003,0
2222

@@ -105,8 +105,21 @@ Pos=847,502
105105
Size=300,71
106106
Collapsed=0
107107

108+
[Window][Statistics]
109+
Pos=429,679
110+
Size=357,325
111+
Collapsed=0
112+
113+
[Window][CameraController]
114+
Pos=1500,158
115+
Size=368,93
116+
Collapsed=0
117+
DockId=0x00000005,0
118+
108119
[Docking][Data]
109-
DockNode ID=0x00000001 Pos=1500,44 Size=368,703 Split=Y
110-
DockNode ID=0x00000002 Parent=0x00000001 SizeRef=304,114 Selected=0xAA49D574
111-
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=304,470 Selected=0x450B616F
120+
DockNode ID=0x00000001 Pos=1500,44 Size=368,803 Split=Y
121+
DockNode ID=0x00000002 Parent=0x00000001 SizeRef=304,228 Split=Y Selected=0xAA49D574
122+
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=368,123 Selected=0xAA49D574
123+
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=368,103 Selected=0xFAB689DB
124+
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=304,654 Selected=0x450B616F
112125

res/shader/basic.frag

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#version 450 core
1+
#version 430 core
22

33
#define M_PI 3.1415926535897932384626433832795
44

5-
#define POINT_LIGHTS 1
5+
//#define POINT_LIGHTS 1
66

77
const float MAX_REFLECTION_LOD = 4.0;
88

@@ -11,7 +11,7 @@ in VS_OUT {
1111
vec3 WorldPos;
1212
vec3 TangentViewPos;
1313
vec3 TangentWorldPos;
14-
vec3 TangentLightPositions[POINT_LIGHTS];
14+
//vec3 TangentLightPositions[POINT_LIGHTS];
1515
mat3 TBN;
1616
} fs_in;
1717

@@ -20,6 +20,8 @@ out vec4 FragColor;
2020
uniform samplerCube irradianceMap;
2121
uniform samplerCube prefilterMap;
2222
uniform sampler2D brdfLUT;
23+
uniform float skyboxExposure;
24+
uniform float skyboxColorIntensity;
2325

2426
uniform sampler2D albedoMap;
2527
uniform sampler2D normalMap;
@@ -34,8 +36,18 @@ uniform float colorIntensity;
3436

3537
uniform vec3 camPos;
3638

37-
uniform vec3 lightPositions[POINT_LIGHTS];
38-
uniform vec3 lightColors[POINT_LIGHTS];
39+
//uniform vec3 lightPositions[POINT_LIGHTS];
40+
//uniform vec3 lightColors[POINT_LIGHTS];
41+
42+
vec3 ApplyExposureAndIntensity(vec3 color, float e, float i)
43+
{
44+
vec3 ret = color;
45+
// Exposure
46+
ret = vec3(1.0) - exp(-ret * e);
47+
// Color Intensity
48+
ret *= i;
49+
return ret;
50+
}
3951

4052
vec3 GetNormalFromNormalMap(sampler2D map, vec2 coords)
4153
{
@@ -56,35 +68,35 @@ vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
5668
// depth of current layer
5769
float currentLayerDepth = 0.0;
5870
// the amount to shift the texture coordinates per layer (from vector P)
59-
vec2 P = viewDir.xy * height_scale;
71+
vec2 P = viewDir.xy / viewDir.z * height_scale;
6072
vec2 deltaTexCoords = P / numLayers;
6173

6274
// get initial values
6375
vec2 currentTexCoords = texCoords;
64-
float currentDepthMapValue = texture(displacementMap, texCoords).r;
76+
float currentDepthMapValue = texture(displacementMap, currentTexCoords).r;
6577

6678
while(currentLayerDepth < currentDepthMapValue)
6779
{
6880
// shift texture coordinates along direction of P
6981
currentTexCoords -= deltaTexCoords;
7082
// get depthmap value at current texture coordinates
71-
currentDepthMapValue = texture(displacementMap, texCoords).r;
83+
currentDepthMapValue = texture(displacementMap, currentTexCoords).r;
7284
// get depth of next layer
73-
currentLayerDepth += layerDepth;
85+
currentLayerDepth += layerDepth;
7486
}
7587

7688
// get texture coordinates before collision (reverse operations)
7789
vec2 prevTexCoords = currentTexCoords + deltaTexCoords;
7890

7991
// get depth after and before collision for linear interpolation
8092
float afterDepth = currentDepthMapValue - currentLayerDepth;
81-
float beforeDepth = texture(displacementMap, texCoords).r - currentLayerDepth + layerDepth;
93+
float beforeDepth = texture(displacementMap, prevTexCoords).r - currentLayerDepth + layerDepth;
8294

8395
// interpolation of texture coordinates
8496
float weight = afterDepth / (afterDepth - beforeDepth);
8597
vec2 finalTexCoords = prevTexCoords * weight + currentTexCoords * (1.0 - weight);
8698

87-
return finalTexCoords;
99+
return finalTexCoords;
88100
}
89101

90102
vec3 FresnelSchlick(float cosTheta, vec3 F0)
@@ -132,6 +144,16 @@ float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness)
132144
return ggx1 * ggx2;
133145
}
134146

147+
vec3 PrefilteredColor(vec3 R, float roughness)
148+
{
149+
return ApplyExposureAndIntensity(textureLod(prefilterMap, R, roughness * MAX_REFLECTION_LOD).rgb, skyboxExposure, skyboxColorIntensity);
150+
}
151+
152+
vec3 IrradianceColor(vec3 N)
153+
{
154+
return ApplyExposureAndIntensity(texture(irradianceMap, N).rgb, skyboxExposure, skyboxColorIntensity);
155+
}
156+
135157
void main()
136158
{
137159
vec3 viewDir = normalize(fs_in.TangentViewPos - fs_in.TangentWorldPos);
@@ -153,8 +175,6 @@ void main()
153175
float metallic = texture(metallicMap, texCoords).r;
154176
float roughness = texture(roughnessMap, texCoords).r;
155177
float ao = texture(aoMap, texCoords).r;
156-
/*
157-
*/
158178

159179
vec3 N = normalize(normal);
160180
vec3 V = normalize(camPos - fs_in.WorldPos);
@@ -163,19 +183,18 @@ void main()
163183
vec3 F0 = vec3(0.04);
164184
F0 = mix(F0, albedo, metallic);
165185

166-
vec3 Lo = vec3(0.0);
167-
//for(int i = 0; i < POINT_LIGHTS; ++i)
168-
for(int i = POINT_LIGHTS; i < POINT_LIGHTS; ++i)
186+
//vec3 Lo = vec3(0.0);
187+
/*for(int i = 0; i < POINT_LIGHTS; ++i)
169188
{
170189
vec3 L = normalize(lightPositions[i] - fs_in.WorldPos);
171190
//vec3 L = normalize(fs_in.TangentLightPositions[i] - fs_in.TangentWorldPos);
172191
vec3 H = normalize(V + L);
173-
192+
174193
float dist = length(lightPositions[i] - fs_in.WorldPos);
175194
//float dist = length(fs_in.TangentLightPositions[i] - fs_in.TangentWorldPos);
176195
float attenuation = 1.0 / (dist * dist);
177196
vec3 radiance = lightColors[i] * attenuation;
178-
197+
179198
// cook-torrance brdf
180199
float NDF = DistributionGGX(N, H, roughness);
181200
float G = GeometrySmith(N, V, L, roughness);
@@ -184,39 +203,43 @@ void main()
184203
vec3 kS = F;
185204
vec3 kD = vec3(1.0) - kS;
186205
kD *= 1.0 - metallic;
187-
206+
188207
vec3 numerator = NDF * G * F;
189208
float denominator = 4.0 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0);
190209
vec3 specular = numerator / max(denominator, 0.001);
191-
210+
192211
float NdotL = max(dot(N, L), 0.0);
193212
Lo += (kD * albedo / M_PI + specular) * radiance * NdotL;
194213
}
214+
*/
195215

196216
vec3 F = FresnelSchlickRoughness(max(dot(N, V), 0.0), F0, roughness);
197217

198218
vec3 kS = F;
199219
vec3 kD = 1.0 - kS;
200220
kD *= 1.0 - metallic;
201221

202-
vec3 irradiance = texture(irradianceMap, N).rgb;
222+
vec3 irradiance = IrradianceColor(N);
203223
vec3 diffuse = irradiance * albedo;
204224

205-
vec3 prefilteredColor = textureLod(prefilterMap, R, roughness * MAX_REFLECTION_LOD).rgb;
225+
vec3 prefilteredColor = PrefilteredColor(R, roughness);
206226
vec2 envBRDF = texture(brdfLUT, vec2(max(dot(N, V), 0.0), roughness)).rg;
207227
vec3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);
208228

209229
vec3 ambient = (kD * diffuse + specular) * ao;
210230

211-
vec3 color = ambient + Lo;
231+
//vec3 color = ambient + Lo;
232+
vec3 color = ambient;
212233

213234
// Exposure
214235
//color *= exposure;
215236
// Tonemapping Reinharda
216237
//color = color / (color + vec3(1.0));
217-
color = vec3(1.0) - exp(-color * exposure);
238+
//color = vec3(1.0) - exp(-color * exposure);
218239
// Color Intensity
219-
color *= colorIntensity;
240+
//color *= colorIntensity;
241+
242+
color = ApplyExposureAndIntensity(color, exposure, colorIntensity);
220243
// Gamma Correction
221244
color = pow(color, vec3(1.0/2.2));
222245

0 commit comments

Comments
 (0)