-
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc22ce1
commit 2374fe9
Showing
4 changed files
with
186 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
precision mediump float; | ||
|
||
varying vec2 vTextureCoord; | ||
precision highp float; | ||
in vec2 vTextureCoord; | ||
out vec4 finalColor; | ||
|
||
uniform sampler2D uSampler; | ||
uniform vec4 filterArea; | ||
uniform vec2 red; | ||
uniform vec2 green; | ||
uniform vec2 blue; | ||
uniform vec4 uInputSize; | ||
uniform vec2 uRed; | ||
uniform vec2 uGreen; | ||
uniform vec2 uBlue; | ||
|
||
void main(void) | ||
{ | ||
gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/filterArea.xy).r; | ||
gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/filterArea.xy).g; | ||
gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/filterArea.xy).b; | ||
gl_FragColor.a = texture2D(uSampler, vTextureCoord).a; | ||
float r = texture2D(uSampler, vTextureCoord + uRed/uInputSize.xy).r; | ||
float g = texture2D(uSampler, vTextureCoord + uGreen/uInputSize.xy).g; | ||
float b = texture2D(uSampler, vTextureCoord + uBlue/uInputSize.xy).b; | ||
float a = texture2D(uSampler, vTextureCoord).a; | ||
finalColor = vec4(r, g, b, a); | ||
} |
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,31 @@ | ||
struct RgbSplitUniforms { | ||
uRed: vec2<f32>, | ||
uGreen: vec2<f32>, | ||
uBlue: vec3<f32>, | ||
}; | ||
|
||
struct GlobalFilterUniforms { | ||
uInputSize:vec4<f32>, | ||
uInputPixel:vec4<f32>, | ||
uuInputClamp:vec4<f32>, | ||
uOutputFrame:vec4<f32>, | ||
uGlobalFrame:vec4<f32>, | ||
uOutputTexture:vec4<f32>, | ||
}; | ||
|
||
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms; | ||
|
||
@group(0) @binding(1) var uSampler: texture_2d<f32>; | ||
@group(1) @binding(0) var<uniform> rgbSplitUniforms : RgbSplitUniforms; | ||
|
||
@fragment | ||
fn mainFragment( | ||
@builtin(position) position: vec4<f32>, | ||
@location(0) uv : vec2<f32> | ||
) -> @location(0) vec4<f32> { | ||
let r = textureSample(uSampler, uSampler, vTextureCoord + rgbSplitUniforms.uRed/uInputSize.xy).r; | ||
let g = textureSample(uSampler, uSampler, vTextureCoord + rgbSplitUniforms.uGreen/uInputSize.xy).g; | ||
let b = textureSample(uSampler, uSampler, vTextureCoord + rgbSplitUniforms.uBlue/uInputSize.xy).b; | ||
let a = textureSample(uSampler, uSampler, vTextureCoord).a; | ||
return vec4<f32>(r, g, b, a); | ||
} |
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