-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SpaVec/alt-algo#3
Alternative algorithm for separate x y corrections
- Loading branch information
Showing
4 changed files
with
65 additions
and
16 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,36 @@ | ||
#ifdef GL_ES | ||
precision highp float; | ||
#endif | ||
|
||
uniform vec3 uLensS; | ||
uniform vec2 uLensF; | ||
uniform vec2 uFov; | ||
|
||
uniform sampler2D uSampler; | ||
|
||
varying vec3 vPosition; | ||
varying vec2 vTextureCoord; | ||
|
||
vec2 GLCoord2TextureCoord(vec2 glCoord) { | ||
return glCoord * vec2(1.0, -1.0)/ 2.0 + vec2(0.5, 0.5); | ||
} | ||
|
||
void main(void){ | ||
float scale = uLensS.z; | ||
vec3 vPos = vPosition; | ||
float Fx = uLensF.x; | ||
float Fy = uLensF.y; | ||
|
||
vec2 vMapping = vPos.xy; | ||
vMapping.x = vMapping.x + ((pow(vPos.y, 2.0)/scale)*vPos.x/scale)*-Fx; | ||
vMapping.y = vMapping.y + ((pow(vPos.x, 2.0)/scale)*vPos.y/scale)*-Fy; | ||
vMapping = vMapping * uLensS.xy; | ||
|
||
vMapping = GLCoord2TextureCoord(vMapping/scale); | ||
|
||
vec4 texture = texture2D(uSampler, vMapping); | ||
if(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){ | ||
texture = vec4(0.0, 0.0, 0.0, 1.0); | ||
} | ||
gl_FragColor = texture; | ||
} |