aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-06-27 18:59:03 +0200
committerraysan5 <raysan5@gmail.com>2016-06-27 18:59:03 +0200
commit5a4eb34c39e404fdd5804299111477a10dd3895d (patch)
tree601f859aa4dc0551519dc20c8ae44a33d0b58cda /examples
parentc4922c9e8854f9c936b28c3f8b00162b407ae503 (diff)
downloadraylib-5a4eb34c39e404fdd5804299111477a10dd3895d.tar.gz
raylib-5a4eb34c39e404fdd5804299111477a10dd3895d.zip
Corrected issue on distortion shader
Diffstat (limited to 'examples')
-rw-r--r--examples/core_oculus_rift.c4
-rw-r--r--examples/resources/shaders/glsl100/distortion.fs10
-rw-r--r--examples/resources/shaders/glsl330/distortion.fs22
3 files changed, 16 insertions, 20 deletions
diff --git a/examples/core_oculus_rift.c b/examples/core_oculus_rift.c
index 4fe35607..95b89106 100644
--- a/examples/core_oculus_rift.c
+++ b/examples/core_oculus_rift.c
@@ -63,11 +63,13 @@ int main()
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);
DrawGrid(10, 1.0f);
-
+
DrawDefaultBuffers(); // Process internal dynamic buffers
}
End3dMode();
+
+ DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs
index 3a1a45d3..19e6656a 100644
--- a/examples/resources/shaders/glsl100/distortion.fs
+++ b/examples/resources/shaders/glsl100/distortion.fs
@@ -44,17 +44,13 @@ void main()
// SOURCE: http://www.mtbs3d.com/phpbb/viewtopic.php?f=140&t=17081
// The following two variables need to be set per eye
- vec2 LensCenter = fragTexCoord.x < 540 ? LeftLensCenter : RightLensCenter;
- vec2 ScreenCenter = fragTexCoord.x < 540 ? LeftScreenCenter : RightScreenCenter;
+ vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
+ vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
vec2 tc = HmdWarp(fragTexCoord, LensCenter);
if (any(bvec2(clamp(tc,ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)) - tc))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
- else
- {
- //tc.x = gl_FragCoord.x < 640 ? (2.0 * tc.x) : (2.0 * (tc.x - 0.5));
- gl_FragColor = texture2D(texture0, tc);
- }
+ else gl_FragColor = texture2D(texture0, tc);
/*
// Chromatic aberration is caused when a lens can't focus every color to the same focal point.
diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs
index e43f8451..c8777c18 100644
--- a/examples/resources/shaders/glsl330/distortion.fs
+++ b/examples/resources/shaders/glsl330/distortion.fs
@@ -17,6 +17,7 @@ const vec2 RightScreenCenter = vec2(0.75, 0.5);
const vec2 Scale = vec2(0.25, 0.45); //vec2(0.1469278, 0.2350845);
const vec2 ScaleIn = vec2(4, 2.2222);
const vec4 HmdWarpParam = vec4(1, 0.22, 0.24, 0);
+const vec4 ChromaAbCorrection = vec4(0.99599999, -0.0040000002, 1.0140001, 0.0);
/*
// Another set of default values
@@ -45,25 +46,22 @@ void main()
// SOURCE: http://www.mtbs3d.com/phpbb/viewtopic.php?f=140&t=17081
// The following two variables need to be set per eye
- vec2 LensCenter = fragTexCoord.x < 540 ? LeftLensCenter : RightLensCenter;
- vec2 ScreenCenter = fragTexCoord.x < 540 ? LeftScreenCenter : RightScreenCenter;
+ vec2 LensCenter = fragTexCoord.x < 0.5 ? LeftLensCenter : RightLensCenter;
+ vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter;
vec2 tc = HmdWarp(fragTexCoord, LensCenter);
- if (any(bvec2(clamp(tc,ScreenCenter-vec2(0.25,0.5), ScreenCenter+vec2(0.25,0.5)) - tc))) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
- else
- {
- //tc.x = gl_FragCoord.x < 640 ? (2.0 * tc.x) : (2.0 * (tc.x - 0.5));
- finalColor = texture2D(texture0, tc);
- }
+ if (any(bvec2(clamp(tc, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tc))) finalColor = vec4(0.0, 0.0, 0.0, 1.0);
+ else finalColor = texture2D(texture0, tc);
- /*
// Chromatic aberration is caused when a lens can't focus every color to the same focal point.
// A simple way to fake this effect, and render it as a quick full-screen post-process,
// is to apply an offset to each color channel in a fragment shader.
- vec4 rValue = texture2D(texture0, fragTexCoord - rOffset);
- vec4 gValue = texture2D(texture0, fragTexCoord - gOffset);
- vec4 bValue = texture2D(texture0, fragTexCoord - bOffset);
+ /*
+ vec4 rValue = texture2D(texture0, fragTexCoord - ChromaAbCorrection.x);
+ vec4 gValue = texture2D(texture0, fragTexCoord - ChromaAbCorrection.y);
+ vec4 bValue = texture2D(texture0, fragTexCoord - ChromaAbCorrection.z);
+
finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0);
*/
}