Skip to content

Commit 237c105

Browse files
committed
Chapter 11
1 parent e7f39a9 commit 237c105

File tree

14 files changed

+1299
-70
lines changed

14 files changed

+1299
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This [online book](bookcontents/) will introduce the main concepts required to w
66

77
We will use [LWJGL](http://www.lwjgl.org/) as the Java library which provides the required bindings to use Vulkan and any other required APIs. This book is the result of my self learning language, that I think it may help the community.
88

9-
![Sample screen shot](screen-shot.png)
9+
![Sample screen shot](./bookcontents/chapter-11/screen-shot.png)
1010

1111
## Book Code
1212

785 KB
Loading

bookcontents/chapter-11/chapter-11.md

Lines changed: 1266 additions & 1 deletion
Large diffs are not rendered by default.
File renamed without changes.
1.79 MB
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Pending

booksamples/chapter-11/resources/shaders/lighting_fragment.glsl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#version 450
2+
// CREDITS: Most of the functions here have been obtained from this link: https://learnopengl.com/PBR
3+
// developed by Joey de Vries, https://twitter.com/JoeyDeVriez, and licensed under the terms of the CC BY-NC 4.0,
4+
// https://creativecommons.org/licenses/by-nc/4.0/legalcode
25

36
const int MAX_LIGHTS = 10;
47
const float PI = 3.14159265359;
@@ -18,12 +21,10 @@ layout(set = 0, binding = 1) uniform sampler2D normalsSampler;
1821
layout(set = 0, binding = 2) uniform sampler2D pbrSampler;
1922
layout(set = 0, binding = 3) uniform sampler2D depthSampler;
2023
layout(set = 1, binding = 0) uniform UBO {
24+
vec4 ambientLightColor;
2125
uint count;
2226
Light lights[MAX_LIGHTS];
2327
} lights;
24-
layout(set = 1, binding = 1) uniform AmbientLightUniform {
25-
vec4 color;
26-
} ambientLight;
2728
layout(set = 2, binding = 0) uniform ProjUniform {
2829
mat4 invProjectionMatrix;
2930
} projUniform;
@@ -147,7 +148,7 @@ void main() {
147148
}
148149
}
149150

150-
vec3 ambient = ambientLight.color.rgb * albedo * ao;
151+
vec3 ambient = lights.ambientLightColor.rgb * albedo * ao;
151152

152153
outFragColor = vec4(pow(ambient + lightColor, vec3(0.4545)), 1.0);
153154
}
-108 Bytes
Binary file not shown.

booksamples/chapter-11/src/main/java/org/vulkanb/eng/graph/Render.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public void loadMeshes(MeshData[] meshDataList) {
7676
}
7777

7878
public void render(Window window, Scene scene) {
79+
if (window.getWidth() <= 0 && window.getHeight() <= 0) {
80+
return;
81+
}
7982
if (window.isResized() || swapChain.acquireNextImage()) {
8083
window.resetResized();
8184
resize(window, scene);

booksamples/chapter-11/src/main/java/org/vulkanb/eng/graph/geometry/GeometryRenderActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,5 @@ private void updateTextureDescriptorSet(Texture texture) {
331331
texture, textureSampler, 0);
332332
descriptorSetMap.put(textureFileName, textureDescriptorSet);
333333
}
334-
335334
}
336-
337-
}
335+
}

0 commit comments

Comments
 (0)