forked from gazebosim/gz-rendering
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metal] add cross-platform gamma adjustment for texture rendered into…
… QML - Adapt the GammaAdjust element from QtGraphicalEffects to work with Metal - Add shaders from Qt - Create a Vulkan supported version of the fragment shader - Generate a shader pack using qsb Signed-off-by: Rhys Mainwaring <[email protected]>
- Loading branch information
1 parent
be620c0
commit 7d40f42
Showing
8 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 440 | ||
|
||
layout(location = 0) in vec2 qt_TexCoord0; | ||
layout(location = 0) out vec4 fragColor; | ||
|
||
layout(std140, binding = 0) uniform buf { | ||
mat4 qt_Matrix; | ||
float qt_Opacity; | ||
float gamma; | ||
}; | ||
|
||
layout(binding = 1) uniform sampler2D source; | ||
|
||
void main() { | ||
|
||
// float rootGamma = 2.4; | ||
// float gamma = 1.0 / max(rootGamma, 0.0001); | ||
|
||
vec4 originalColor = texture(source, qt_TexCoord0); | ||
originalColor.rgb = originalColor.rgb / max(1.0/256.0, originalColor.a); | ||
vec3 adjustedColor = pow(originalColor.rgb, vec3(gamma)); | ||
fragColor = vec4(adjustedColor * originalColor.a, originalColor.a) * qt_Opacity; | ||
} |
Binary file not shown.
13 changes: 13 additions & 0 deletions
13
examples/simple_demo_qml_metal/shaders/+glslcore/gammaadjust.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#version 150 core | ||
in vec2 qt_TexCoord0; | ||
uniform float qt_Opacity; | ||
uniform sampler2D source; | ||
uniform float gamma; | ||
out vec4 fragColor; | ||
|
||
void main(void) { | ||
vec4 originalColor = texture(source, qt_TexCoord0.st); | ||
originalColor.rgb = originalColor.rgb / max(1.0/256.0, originalColor.a); | ||
vec3 adjustedColor = pow(originalColor.rgb, vec3(gamma)); | ||
fragColor = vec4(adjustedColor * originalColor.a, originalColor.a) * qt_Opacity; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
varying highp vec2 qt_TexCoord0; | ||
uniform highp float qt_Opacity; | ||
uniform lowp sampler2D source; | ||
uniform highp float gamma; | ||
void main(void) { | ||
highp vec4 originalColor = texture2D(source, qt_TexCoord0.st); | ||
originalColor.rgb = originalColor.rgb / max(1.0/256.0, originalColor.a); | ||
highp vec3 adjustedColor = pow(originalColor.rgb, vec3(gamma)); | ||
gl_FragColor = vec4(adjustedColor * originalColor.a, originalColor.a) * qt_Opacity; | ||
} |