forked from wang-bin/QtAV
-
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.
result color is wrong, shader seems right. may be some mistakes in c++ code
- Loading branch information
Showing
3 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<RCC> | ||
<qresource prefix="/shaders"> | ||
<file>yuv_rgb.f.glsl</file> | ||
</qresource> | ||
</RCC> |
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,36 @@ | ||
#ifdef GL_ES | ||
// Set default precision to medium | ||
precision mediump int; | ||
precision mediump float; | ||
#else | ||
#define highp | ||
#define mediump | ||
#define lowp | ||
#endif | ||
|
||
// u_TextureN: yuv. use array? | ||
uniform sampler2D u_Texture0; | ||
uniform sampler2D u_Texture1; | ||
uniform sampler2D u_Texture2; | ||
varying lowp vec2 v_TexCoords; | ||
|
||
//http://en.wikipedia.org/wiki/YUV calculation used | ||
//http://www.fourcc.org/fccyvrgb.php | ||
//GLSL: col first | ||
// use bt601 | ||
const mat4 colorMatrix = mat4(1, 1, 1, 0, | ||
0, -0.344, 1.773, 0, | ||
1.403, -0.714, 0, 0, | ||
0, 0, 0, 1) | ||
* mat4(1, 0, 0, 0, | ||
0, 1, 0, 0, | ||
0, 0, 1, 0, | ||
0, -0.5, -0.5, 1); | ||
void main() | ||
{ | ||
gl_FragColor = clamp(colorMatrix* vec4(texture2D(u_Texture0, v_TexCoords).r, | ||
texture2D(u_Texture1, v_TexCoords).r, | ||
texture2D(u_Texture2, v_TexCoords).r, | ||
1) | ||
, 0.0, 1.0); | ||
} |