Skip to content

Commit aec0798

Browse files
committed
-Refactor: New Enviroment Pass definition
1 parent 7fb7484 commit aec0798

File tree

21 files changed

+418
-57
lines changed

21 files changed

+418
-57
lines changed

examples/resources/scenes/sponza.xml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
<Material type="physical">
2424
<albedo r="0.5" g="0.5" b="0.5" />
25+
<roughness value="0.9"></roughness>
2526
<Textures>
2627
<albedo path="textures/Walls/Bricks_Diffuse.png" />
2728
<normals path="textures/Walls/Bricks_Normal.png" />
@@ -34,6 +35,7 @@
3435
<Filename value="meshes/arcs.obj" />
3536
<Material type="physical">
3637
<albedo r="0.5" g="0.5" b="0.5" />
38+
<roughness value="0.9"></roughness>
3739
<Textures>
3840
<albedo path="textures/Arches/Arches_Diffuse.png" />
3941
<!-- <normals path="textures/Arches/Arches_Normal.png" /> -->
@@ -44,7 +46,9 @@
4446
<Mesh type="file" name="Domes">
4547
<Filename value="meshes/boves.obj" />
4648
<Material type="physical">
49+
4750
<albedo r="0.5" g="0.5" b="0.5" />
51+
<roughness value="0.9"></roughness>
4852
<Textures>
4953
<albedo path="textures/Vaults/Ceiling_Diffuse.png" />
5054
<normals path="textures/Vaults/Ceiling_Normal.png" />
@@ -56,6 +60,7 @@
5660
<Filename value="meshes/columns2.obj" />
5761
<Material type="physical">
5862
<albedo r="0.5" g="0.5" b="0.5" />
63+
<roughness value="0.9"></roughness>
5964
<Textures>
6065
<albedo path="textures/Columns/Column_C_Diffuse.png" />
6166
<!-- <normals path="textures/Columns/Column_C_Normal.png" /> -->
@@ -67,6 +72,7 @@
6772
<Filename value="meshes/columnsBottom.obj" />
6873
<Material type="physical">
6974
<albedo r="0.5" g="0.5" b="0.5" />
75+
<roughness value="0.9"></roughness>
7076
<Textures>
7177
<albedo path="textures/Columns/Column_A_Diffuse.png" />
7278
<normals path="textures/Columns/Column_A_Normal.png" />
@@ -78,6 +84,7 @@
7884
<Filename value="meshes/columnsTop.obj" />
7985
<Material type="physical">
8086
<albedo r="0.5" g="0.5" b="0.5" />
87+
<roughness value="0.9"></roughness>
8188
<Textures>
8289
<albedo path="textures/Columns/Column_B_Diffuse.png" />
8390
<normals path="textures/Columns/Column_B_Normal.png" />
@@ -89,6 +96,7 @@
8996
<Filename value="meshes/doors.obj" />
9097
<Material type="physical">
9198
<albedo r="0.5" g="0.5" b="0.5" />
99+
<roughness value="0.9"></roughness>
92100
<Textures>
93101
<albedo path="textures/Doors/Details_Diffuse.png" />
94102
<normals path="textures/Doors/Details_Normal.png" />
@@ -100,6 +108,7 @@
100108
<Filename value="meshes/floor.obj" />
101109
<Material type="physical">
102110
<albedo r="0.5" g="0.5" b="0.5" />
111+
<roughness value="0.9"></roughness>
103112
<Textures>
104113
<albedo path="textures/Floor/Floor_Diffuse.png" />
105114
<normals path="textures/Floor/Floor_Normal.png" />
@@ -111,6 +120,7 @@
111120
<Filename value="meshes/fountains.obj" />
112121
<Material type="physical">
113122
<albedo r="0.5" g="0.5" b="0.5" />
123+
<roughness value="0.9"></roughness>
114124
<Textures>
115125
<albedo path="textures/Vase/Vase_Octagonal_Diffuse.png" />
116126
<normals path="textures/Vase/Vase_Octagonal_Normal.png" />
@@ -123,6 +133,7 @@
123133
<Filename value="meshes/lion.obj" />
124134
<Material type="physical">
125135
<albedo r="0.5" g="0.5" b="0.5" />
136+
<roughness value="0.9"></roughness>
126137
<Textures>
127138
<albedo path="textures/Lion/Lion_Head_Diffuse.png" />
128139
<normals path="textures/Lion/Lion_Head_Normal.png" />
@@ -134,6 +145,7 @@
134145
<Filename value="meshes/lionBase.obj" />
135146
<Material type="physical">
136147
<albedo r="0.5" g="0.5" b="0.5" />
148+
<roughness value="0.9"></roughness>
137149
<Textures>
138150
<albedo path="textures/Lion/Lion_Shield_Diffuse.png" />
139151
<normals path="textures/Lion/Lion_Shield_Normal.png" />
@@ -157,6 +169,7 @@
157169
<Mesh type="file" name="Roof">
158170
<Filename value="meshes/roof.obj" />
159171
<Material type="physical">
172+
<roughness value="0.9"></roughness>
160173
<Textures>
161174
<albedo path="textures/Roof/Roof_Diffuse.png" />
162175
<normals path="textures/Roof/Roof_Normal.png" />
@@ -231,6 +244,7 @@
231244
<rotate x="0.0" y="-225.0" z="0.0" />
232245
</Transform>
233246
<Material type="physical">
247+
234248
<roughness value="0.4"></roughness>
235249

236250
<Textures>
@@ -258,6 +272,104 @@
258272
<albedo r="0.5" g="0.5" b="0.5" />
259273
</Material>
260274
</Mesh>
275+
<Mesh type="file" name="Curtain 0">
276+
<Filename value="meshes/curtain1.obj" />
277+
278+
<Material type="physical">
279+
280+
<Textures>
281+
<albedo path="textures/Fabrics/Fabric_Curtain_Diffuse_Blue.png" />
282+
<normals path="textures/Fabrics/Fabric_Curtain_Normal.png" />
283+
<metalness path="textures/Fabrics/Fabric_Curtain_Metallic.png" />
284+
<roughness path="textures/Fabrics/Fabric_Curtain_Roughness.png" />
285+
</Textures>
286+
<albedo r="0.5" g="0.5" b="0.5" />
287+
</Material>
288+
</Mesh>
289+
<Mesh type="file" name="Curtain 1">
290+
<Filename value="meshes/curtain2.obj" />
291+
292+
<Material type="physical">
293+
294+
<Textures>
295+
<albedo path="textures/Fabrics/Fabric_Curtain_Diffuse_Red.png" />
296+
<normals path="textures/Fabrics/Fabric_Curtain_Normal.png" />
297+
<metalness path="textures/Fabrics/Fabric_Curtain_Metallic.png" />
298+
<roughness path="textures/Fabrics/Fabric_Curtain_Roughness.png" />
299+
</Textures>
300+
<albedo r="0.5" g="0.5" b="0.5" />
301+
</Material>
302+
</Mesh>
303+
<Mesh type="file" name="Curtain 2">
304+
<Filename value="meshes/curtain3.obj" />
305+
306+
<Material type="physical">
307+
308+
<Textures>
309+
<albedo path="textures/Fabrics/Fabric_Curtain_Diffuse_Green.png" />
310+
<normals path="textures/Fabrics/Fabric_Curtain_Normal.png" />
311+
<metalness path="textures/Fabrics/Fabric_Curtain_Metallic.png" />
312+
<roughness path="textures/Fabrics/Fabric_Curtain_Roughness.png" />
313+
</Textures>
314+
<albedo r="0.5" g="0.5" b="0.5" />
315+
</Material>
316+
</Mesh>
317+
<Mesh type="file" name="Round Curtain 0">
318+
<Filename value="meshes/topCurtain1.obj" />
319+
320+
<Material type="physical">
321+
322+
<Textures>
323+
<albedo path="textures/Fabrics/Fabric_Round_Diffuse_Blue.png" />
324+
<normals path="textures/Fabrics/Fabric_Round_Normal.png" />
325+
<metalness path="textures/Fabrics/Fabric_Round_Metallic.png" />
326+
<roughness path="textures/Fabrics/Fabric_Round_Roughness.png" />
327+
</Textures>
328+
<albedo r="0.5" g="0.5" b="0.5" />
329+
</Material>
330+
</Mesh>
331+
<Mesh type="file" name="Round Curtain 1">
332+
<Filename value="meshes/topCurtain2.obj" />
333+
334+
<Material type="physical">
335+
336+
<Textures>
337+
<albedo path="textures/Fabrics/Fabric_Round_Diffuse_Red.png" />
338+
<normals path="textures/Fabrics/Fabric_Round_Normal.png" />
339+
<metalness path="textures/Fabrics/Fabric_Round_Metallic.png" />
340+
<roughness path="textures/Fabrics/Fabric_Round_Roughness.png" />
341+
</Textures>
342+
<albedo r="0.5" g="0.5" b="0.5" />
343+
</Material>
344+
</Mesh>
345+
<Mesh type="file" name="Round Curtain 2">
346+
<Filename value="meshes/topCurtain3.obj" />
347+
348+
<Material type="physical">
349+
350+
<Textures>
351+
<albedo path="textures/Fabrics/Fabric_Round_Diffuse_Green.png" />
352+
<normals path="textures/Fabrics/Fabric_Round_Normal.png" />
353+
<metalness path="textures/Fabrics/Fabric_Round_Metallic.png" />
354+
<roughness path="textures/Fabrics/Fabric_Round_Roughness.png" />
355+
</Textures>
356+
<albedo r="0.5" g="0.5" b="0.5" />
357+
</Material>
358+
</Mesh>
359+
<!-- <Mesh type="file" name="Carpet">
360+
<Filename value="meshes/carpet.obj" />
361+
362+
<Material type="physical">
363+
364+
<Textures>
365+
<albedo path="textures/Fabrics/Fabric_Round_Diffuse_Green.png" />
366+
<normals path="textures/Fabrics/Fabric_Round_Normal.png" />
367+
<metalness path="textures/Fabrics/Fabric_Round_Metallic.png" />
368+
<roughness path="textures/Fabrics/Fabric_Round_Roughness.png" />
369+
</Textures>
370+
<albedo r="0.5" g="0.5" b="0.5" />
371+
</Material>
372+
</Mesh> -->
261373

262374
</Children>
263375
</Mesh>

include/engine/core/passes/composition_pass.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ class CompositionPass : public GraphicPass
130130

131131
void set_envmap_descriptor(Graphics::Image env, Graphics::Image irr);
132132

133-
void set_voxelization_descriptor(Graphics::Image voxel);
134-
135133
void update();
136134

137135
void cleanup();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
This file is part of Vulkan-Engine, a simple to use Vulkan based 3D library
3+
4+
MIT License
5+
6+
Copyright (c) 2023 Antonio Espinosa Garcia
7+
8+
*/
9+
#ifndef ENVIROMENT_PASS_H
10+
#define ENVIROMENT_PASS_H
11+
#include <engine/core/passes/pass.h>
12+
#include <engine/core/textures/textureHDR.h>
13+
14+
VULKAN_ENGINE_NAMESPACE_BEGIN
15+
16+
namespace Core {
17+
18+
class EnviromentPass : public GraphicPass
19+
{
20+
ColorFormatType m_format;
21+
Mesh* m_vignette;
22+
Graphics::DescriptorSet m_envDescriptorSet;
23+
Graphics::Buffer m_captureBuffer;
24+
Extent2D m_irradianceResolution;
25+
26+
public:
27+
EnviromentPass(Graphics::Device* ctx,
28+
ColorFormatType format,
29+
Extent2D extent,
30+
uint32_t irradianceResolution,
31+
Mesh* vignette)
32+
: BasePass(ctx, extent, 2, CUBEMAP_FACES, false)
33+
, m_vignette(vignette)
34+
, m_format(format)
35+
, m_irradianceResolution({irradianceResolution, irradianceResolution}) {
36+
}
37+
38+
void setup_attachments(std::vector<Graphics::AttachmentInfo>& attachments,
39+
std::vector<Graphics::SubPassDependency>& dependencies);
40+
41+
void create_framebuffer();
42+
43+
void setup_uniforms(std::vector<Graphics::Frame>& frames);
44+
45+
void setup_shader_passes();
46+
47+
void render(Graphics::Frame& currentFrame, Scene* const scene, uint32_t presentImageIndex = 0);
48+
49+
void update_uniforms(uint32_t frameIndex, Scene* const scene);
50+
51+
void cleanup();
52+
};
53+
54+
} // namespace Core
55+
VULKAN_ENGINE_NAMESPACE_END
56+
57+
#endif

include/engine/core/resource_manager.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ class ResourceManager
4141
static Core::PanoramaConverterPass* panoramaConverterPass;
4242
static Core::IrrandianceComputePass* irradianceComputePass;
4343
/*
44-
Fallback Resources
44+
Texture Resources
4545
*/
46-
static Core::Texture* FALLBACK_TEXTURE;
47-
static Core::Texture* FALLBACK_CUBEMAP;
48-
static Core::Texture* BLUE_NOISE_TEXTURE;
46+
static std::vector<Core::ITexture*> textureResources;
47+
static Core::Texture* FALLBACK_TEXTURE;
48+
static Core::Texture* FALLBACK_CUBEMAP;
4949
/*
5050
Vignette for RTT
5151
*/
@@ -93,7 +93,7 @@ class ResourceManager
9393
static void clean_scene(Core::Scene* const scene);
9494
};
9595

96-
} // namespace Systems
96+
} // namespace Core
9797

9898
VULKAN_ENGINE_NAMESPACE_END;
9999

include/engine/graphics/renderpass.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ namespace Graphics {
2121
Attachment info needed for Renderpasses and Framebuffers
2222
*/
2323
struct AttachmentInfo {
24+
//Image Info
2425
AttachmentType type = AttachmentType::COLOR_ATTACHMENT;
2526
ImageConfig imageConfig = {};
2627
SamplerConfig samplerConfig = {};
2728
ClearValue clearValue = {};
2829
bool isDefault = false;
29-
30+
31+
//Renderpass Info
3032
AttachmentLoadOp loadOp = ATTACHMENT_LOAD_OP_CLEAR;
3133
AttachmentStoreOp storeOp = ATTACHMENT_STORE_OP_STORE;
3234
AttachmentLoadOp stencilLoadOp = ATTACHMENT_LOAD_OP_DONT_CARE;

include/engine/systems/renderers/renderer.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class BaseRenderer
4646
{
4747
#pragma region Properties
4848
protected:
49+
/*Main properties*/
4950
Graphics::Device* m_device;
5051
std::vector<Graphics::Frame> m_frames;
5152
Core::IWindow* m_window;
@@ -54,9 +55,11 @@ class BaseRenderer
5455
/*Passes*/
5556
std::vector<Core::BasePass*> m_passes;
5657

58+
59+
/*Automatic deletion queue*/
5760
Graphics::Utils::DeletionQueue m_deletionQueue;
5861

59-
// Query
62+
/*Query*/
6063
uint32_t m_currentFrame = 0;
6164
bool m_initialized = false;
6265
bool m_updateFramebuffers = false;

resources/shaders/VXGI/voxelization.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void main(){
8787

8888
#extension GL_EXT_ray_tracing : enable
8989
#extension GL_EXT_ray_query : enable
90+
// #extension GL_EXT_shader_explicit_arithmetic_types : enable
9091

9192
#include light.glsl
9293
#include scene.glsl
@@ -218,7 +219,7 @@ void main() {
218219

219220
color += g_emisison;
220221

221-
vec3 ambient = scene.ambientIntensity * g_albedo;
222+
vec3 ambient = scene.ambientIntensity * scene.ambientColor * g_albedo;
222223
color +=ambient;
223224

224225
vec4 result = g_opacity * vec4(vec3(color), 1);

0 commit comments

Comments
 (0)