Skip to content
This repository was archived by the owner on Jun 14, 2025. It is now read-only.

Commit 2758dd4

Browse files
committed
[critic] vendor issues with shaders
1 parent d768f47 commit 2758dd4

File tree

3 files changed

+31
-33
lines changed

3 files changed

+31
-33
lines changed

build/agk.exe

0 Bytes
Binary file not shown.

build/data/gpu/processing.post.frag

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,40 @@ const mat3 XYZtoRGB = mat3(
1919
-0.4985314f, 0.0415560f, 1.0572252f
2020
);
2121

22-
uniform struct {
23-
bool uEnabled;
24-
float uAverageLuminance;
25-
float uExposure;
26-
float uWhite;
27-
} uHDR;
22+
uniform mat4 uInversePerspectiveView;
23+
uniform mat4 uPreviousPerspectiveView;
2824

2925
uniform struct {
30-
bool uEnabled;
31-
float uIntensity;
32-
bool uCameraRotated;
33-
mat4 uInversePerspectiveView;
34-
mat4 uPreviousPerspectiveView;
35-
} uMotionBlur;
26+
/* HDR */
27+
bool uHDREnabled;
28+
float uHDRAverageLuminance;
29+
float uHDRExposure;
30+
31+
/* Motion Blur */
32+
bool uMotionBlurEnabled;
33+
bool uMotionBlurCameraRotated;
34+
float uMotionBlurIntensity;
35+
} uEffects;
3636

3737
void main() {
3838
vec2 size = textureSize(uTexture, 0);
3939
vec2 fragCoord = gl_FragCoord.xy / size;
4040
vec4 sum = vec4(0.0f);
4141

42-
if (uMotionBlur.uEnabled && uMotionBlur.uCameraRotated) {
42+
if (uEffects.uMotionBlurEnabled && uEffects.uMotionBlurCameraRotated) {
4343
vec4 h = vec4(fragCoord.x * 2 - 1, (1.0f - fragCoord.y) * 2 - 1, texture(uDepthSampler, fragCoord).r / 1.0f, 1.0f);
44-
vec4 d = uMotionBlur.uInversePerspectiveView * h;
44+
vec4 d = uInversePerspectiveView * h;
4545
vec4 w = d / d.w;
4646

4747
vec4 currPos = h;
48-
vec4 prevPos = uMotionBlur.uPreviousPerspectiveView * w;
48+
vec4 prevPos = uPreviousPerspectiveView * w;
4949
prevPos = prevPos / prevPos.w;
5050

5151
vec2 velocity = currPos.xy - prevPos.xy;
5252
float numSamples = 20;
5353

5454
float distToCenter = length(gl_FragCoord.x - (size.x / 2)) / size.x;
55-
float dynmaicIntensity = clamp(length(velocity) * 0.1f, 0.0f, uMotionBlur.uIntensity * 0.1f);
55+
float dynmaicIntensity = clamp(length(velocity) * 0.1f, 0.0f, uEffects.uMotionBlurIntensity * 0.1f);
5656

5757
for (float index = 0; index < numSamples; index++) {
5858
vec2 nearestTexCoord = fragCoord + (vec2(((index / (numSamples - 1.0f)) - 0.5f) * (dynmaicIntensity) * distToCenter, 0.0f));
@@ -69,16 +69,16 @@ void main() {
6969
sum = texture(uTexture, fragCoord);
7070
}
7171

72-
if (uHDR.uEnabled) {
72+
if (uEffects.uHDREnabled) {
7373
float white = 0.928f;
74-
float exposure = uHDR.uExposure;
74+
float exposure = uEffects.uHDRExposure;
7575

7676
vec3 xyzCol = RGBtoXYZ * vec3(sum);
7777
float xyzSum = xyzCol.x + xyzCol.y + xyzCol.z;
7878
vec3 xyYCol = vec3(0.0f);
7979
if (xyzSum > 0.0f) xyYCol = vec3(xyzCol.x / xyzSum, xyzCol.y / xyzSum, xyzCol.y);
8080

81-
float l = (exposure * xyYCol.z) / uHDR.uAverageLuminance;
81+
float l = (exposure * xyYCol.z) / uEffects.uHDRAverageLuminance;
8282
l = (l * (1 + l / (white * white))) / (1.0f + l);
8383

8484
xyzCol.x = (l * xyYCol.x) / (xyYCol.y);

src/world/renderer/renderer.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ void renderer::process_post_processing() {
106106
this->framebuffer_post_processing.invoke(0, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
107107

108108
agk::app.p_sky->on_render();
109-
this->process_terrain();
110-
this->process_environment();
111-
this->process_sky();
109+
//this->process_terrain();
110+
//this->process_environment();
112111

113112
/* Revoke all buffers from frame. */
114113
this->framebuffer_post_processing.revoke(GL_COLOR_BUFFER_BIT);
@@ -168,21 +167,21 @@ void renderer::process_post_processing() {
168167

169168
this->shape_post_processing.invoke();
170169
this->shape_post_processing.p_program->set_uniform_bool("uSkyPostProcessing", false);
171-
this->shape_post_processing.p_program->set_uniform_bool("uHDR.uEnabled", agk::app.setting.enable_hdr.get_value());
170+
this->shape_post_processing.p_program->set_uniform_bool("uEffects.uHDREnabled", agk::app.setting.enable_hdr.get_value());
172171

173172
if (agk::app.setting.enable_hdr.get_value()) {
174-
this->shape_post_processing.p_program->set_uniform_float("uHDR.uExposure", agk::app.setting.hdr_exposure.get_value());
175-
this->shape_post_processing.p_program->set_uniform_float("uHDR.uAverageLuminance", ave_lum);
173+
this->shape_post_processing.p_program->set_uniform_float("uEffects.uHDRExposure", agk::app.setting.hdr_exposure.get_value());
174+
this->shape_post_processing.p_program->set_uniform_float("uEffects.uHDRAverageLuminance", ave_lum);
176175
this->previous_average_luminosity = ave_lum;
177176
}
178177

179-
this->shape_post_processing.p_program->set_uniform_bool("uMotionBlur.uEnabled", agk::app.setting.enable_motion_blur.get_value());
178+
this->shape_post_processing.p_program->set_uniform_bool("uEffects.uMotionBlurEnabled", agk::app.setting.enable_motion_blur.get_value());
180179
if (agk::app.setting.enable_motion_blur.get_value()) {
181180
// @TODO Should make the HDR luminance calc better.
182181

183182
this->mat4x4_inverse_perspective_view = glm::inverse(this->mat4x4_perspective_view);
184-
this->shape_post_processing.p_program->set_uniform_mat4("uMotionBlur.uInversePerspectiveView", &this->mat4x4_inverse_perspective_view[0][0]);
185-
this->shape_post_processing.p_program->set_uniform_mat4("uMotionBlur.uPreviousPerspectiveView", &this->mat4x4_previous_perspective_view[0][0]);
183+
this->shape_post_processing.p_program->set_uniform_mat4("uInversePerspectiveView", &this->mat4x4_inverse_perspective_view[0][0]);
184+
this->shape_post_processing.p_program->set_uniform_mat4("uPreviousPerspectiveView", &this->mat4x4_previous_perspective_view[0][0]);
186185
this->mat4x4_previous_perspective_view = this->mat4x4_perspective_view;
187186

188187
auto p_camera {agk::app.p_curr_camera};
@@ -193,11 +192,11 @@ void renderer::process_post_processing() {
193192
this->camera_motion_delta.x = yaw - this->camera_motion_delta.x;
194193
this->camera_motion_delta.y = pitch - this->camera_motion_delta.y;
195194
float acc {(this->camera_motion_delta.x * this->camera_motion_delta.x + this->camera_motion_delta.y * this->camera_motion_delta.y)};
196-
this->shape_post_processing.p_program->set_uniform_bool("uMotionBlur.uCameraRotated", acc != 0.0f);
195+
this->shape_post_processing.p_program->set_uniform_bool("uEffects.uMotionBlurCameraRotated", acc != 0.0f);
197196
this->camera_motion_delta.x = yaw;
198197
this->camera_motion_delta.y = pitch;
199198

200-
this->shape_post_processing.p_program->set_uniform_float("uMotionBlur.uIntensity", agk::app.setting.motion_blur_intensity.get_value());
199+
this->shape_post_processing.p_program->set_uniform_float("uEffects.uMotionBlurIntensity", agk::app.setting.motion_blur_intensity.get_value());
201200
}
202201

203202
this->shape_post_processing.draw({0, 0, agk::app.screen_width, agk::app.screen_height}, {.0f, 0.0f, 1.0f, 1.0f});
@@ -345,10 +344,9 @@ void renderer::on_render() {
345344

346345
case false: {
347346
agk::app.p_sky->on_render();
348-
this->process_terrain();
349-
this->process_environment();
347+
//this->process_terrain();
348+
//this->process_environment();
350349
this->process_editor();
351-
this->process_sky();
352350
break;
353351
}
354352
}

0 commit comments

Comments
 (0)