Skip to content

Commit

Permalink
[Examples/FullDemo] Fixed the edge blend shader for OpenGL ES
Browse files Browse the repository at this point in the history
- "Optimized" vertex position computation by forcing the order of operations
  - The shaders should now be guaranteed to do `mat * (mat * vec)` instead of a potential `(mat * mat) * vec`, which would result in more operations
  - Although no profiling has been made, the shader compilers may already optimize it; however, it's not exactly harmful doing it explicitly
  • Loading branch information
Razakhel committed Oct 12, 2024
1 parent 513dda6 commit 189a819
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion examples/audioDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ int main() {
microphone.openDevice(recoverFormat(isCaptureStereo, captureBitDepth), 16000, 1.f, captureDevice);
});
#else
overlayAudio.addLabel("Output & input devices cannot be changed with Emscripten");
overlayAudio.addLabel("Output & input devices cannot be changed with Emscripten\n"
"Reload the page if you changed them externally");
#endif

overlayAudio.addSlider("Listener gain", [&listener] (float val) noexcept {
Expand Down
8 changes: 5 additions & 3 deletions examples/fullDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ int main() {
// Canny

// Note that in an ordinary Canny edge detection process, the input of the gradient information computing pass (here Sobel)
// should be applied a gaussian blur to attempt removing high frequencies (small details). It's not made here to avoid
// computing another blur, as one is already done further below
// should be applied a gaussian blur to attempt removing high frequencies (small details). It's not done here to avoid
// computing another blur, as one already is further below

auto& canny = renderGraph.addRenderProcess<Raz::CannyFilterRenderProcess>();
canny.setInputGradientBuffer(gradientBuffer);
Expand All @@ -114,7 +114,7 @@ int main() {
uniform sampler2D uniColorBuffer;
uniform sampler2D uniEdgeBuffer;
uniform float uniBlendFactor = 0.0;
uniform float uniBlendFactor;
layout(location = 0) out vec4 fragColor;
Expand All @@ -128,6 +128,8 @@ int main() {
fragColor = vec4(finalColor, 1.0);
}
)"));
edgeBlend.getProgram().setAttribute(0.f, "uniBlendFactor");
edgeBlend.getProgram().sendAttributes();
edgeBlend.addReadTexture(colorBuffer, "uniColorBuffer");
edgeBlend.addReadTexture(edgeBuffer, "uniEdgeBuffer");
edgeBlend.addWriteColorTexture(edgeBlendBuffer, 0);
Expand Down
2 changes: 1 addition & 1 deletion shaders/common.vert
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ void main() {
vec3 bitangent = cross(normal, tangent);
vertMeshInfo.vertTBNMatrix = mat3(tangent, bitangent, normal);

gl_Position = uniViewProjectionMat * uniModelMat * vec4(vertPosition, 1.0);
gl_Position = uniViewProjectionMat * (uniModelMat * vec4(vertPosition, 1.0));
}
2 changes: 1 addition & 1 deletion src/RaZ/Render/BloomRenderProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ constexpr std::string_view finalSource = R"(
} // namespace

BloomRenderProcess::BloomRenderProcess(RenderGraph& renderGraph) : RenderProcess(renderGraph) {
// Based on Fabrice "froyok" Piquet's bloom, itself based on the one used in Unreal Engine 4/Call of Duty: Advanced Warfare
// Based on Froyok's bloom, itself based on the one used in Unreal Engine 4/Call of Duty: Advanced Warfare
// See: https://www.froyok.fr/blog/2021-12-ue4-custom-bloom/

//////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/RaZ/Render/Cubemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ constexpr std::string_view vertSource = R"(
void main() {
fragTexcoords = vertPosition;
vec4 pos = uniProjectionMat * mat4(mat3(uniViewMat)) * vec4(vertPosition, 1.0);
vec4 pos = uniProjectionMat * (mat4(mat3(uniViewMat)) * vec4(vertPosition, 1.0));
gl_Position = pos.xyww;
}
)";
Expand Down

0 comments on commit 189a819

Please sign in to comment.