From 77f599885dade4930fb01baca22db6e2ae0c9f20 Mon Sep 17 00:00:00 2001 From: victorfisac Date: Fri, 10 Jun 2016 00:59:48 +0200 Subject: Fixed GLSL 100 shaders texture() doesn't exist in glsl 100, it must use texture2D(). --- examples/resources/shaders/glsl100/bloom.fs | 2 +- examples/resources/shaders/glsl100/grayscale.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/bloom.fs b/examples/resources/shaders/glsl100/bloom.fs index 280d2fb6..128736f2 100644 --- a/examples/resources/shaders/glsl100/bloom.fs +++ b/examples/resources/shaders/glsl100/bloom.fs @@ -26,7 +26,7 @@ void main() } // Texel color fetching from texture sampler - vec4 texelColor = texture(texture0, fragTexCoord); + vec4 texelColor = texture2D(texture0, fragTexCoord); // Calculate final fragment color if (texelColor.r < 0.3) tc = sum*sum*0.012 + texelColor; diff --git a/examples/resources/shaders/glsl100/grayscale.fs b/examples/resources/shaders/glsl100/grayscale.fs index f92ec335..cf857488 100644 --- a/examples/resources/shaders/glsl100/grayscale.fs +++ b/examples/resources/shaders/glsl100/grayscale.fs @@ -15,7 +15,7 @@ uniform vec4 fragTintColor; void main() { // Texel color fetching from texture sampler - vec4 texelColor = texture(texture0, fragTexCoord)*fragTintColor*fragColor; + vec4 texelColor = texture2D(texture0, fragTexCoord)*fragTintColor*fragColor; // Convert texel color to grayscale using NTSC conversion weights float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); -- cgit v1.2.3 From e913de58c73ff82fbcd8f23b8cb1fd1a88664164 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 21 Jun 2016 13:45:35 +0200 Subject: Added distortion shader for testing --- examples/resources/shaders/base.vs | 26 ++++++++++++++ examples/resources/shaders/distortion.fs | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 examples/resources/shaders/base.vs create mode 100644 examples/resources/shaders/distortion.fs (limited to 'examples/resources') diff --git a/examples/resources/shaders/base.vs b/examples/resources/shaders/base.vs new file mode 100644 index 00000000..638cb8ae --- /dev/null +++ b/examples/resources/shaders/base.vs @@ -0,0 +1,26 @@ +#version 330 + +// Input vertex attributes +in vec3 vertexPosition; +in vec2 vertexTexCoord; +in vec3 vertexNormal; +in vec4 vertexColor; + +// Input uniform values +uniform mat4 mvpMatrix; + +// Output vertex attributes (to fragment shader) +out vec2 fragTexCoord; +out vec4 fragColor; + +// NOTE: Add here your custom variables + +void main() +{ + // Send vertex attributes to fragment shader + fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + + // Calculate final vertex position + gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); +} \ No newline at end of file diff --git a/examples/resources/shaders/distortion.fs b/examples/resources/shaders/distortion.fs new file mode 100644 index 00000000..cd5951fe --- /dev/null +++ b/examples/resources/shaders/distortion.fs @@ -0,0 +1,59 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; + +// Input uniform values +uniform sampler2D texture0; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables +const vec2 LeftLensCenter = vec2(0.2863248, 0.5); +const vec2 RightLensCenter = vec2(0.7136753, 0.5); +const vec2 LeftScreenCenter = vec2(0.25, 0.5); +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); + +/* +// Another set of default values +ChromaAbCorrection = {1.0, 0.0, 1.0, 0} +DistortionK = {1.0, 0.22, 0.24, 0} +Scale = {0.25, 0.5*AspectRatio, 0, 0} +ScaleIn = {4.0, 2/AspectRatio, 0, 0} +Left Screen Center = {0.25, 0.5, 0, 0} +Left Lens Center = {0.287994117, 0.5, 0, 0} +Right Screen Center = {0.75, 0.5, 0, 0} +Right Lens Center = {0.712005913, 0.5, 0, 0} +*/ + +// Scales input texture coordinates for distortion. +vec2 HmdWarp(vec2 in01, vec2 LensCenter) +{ + vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + + return LensCenter + Scale*rvector; +} + +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 = gl_FragCoord.x < 540 ? LeftLensCenter : RightLensCenter; + vec2 ScreenCenter = gl_FragCoord.x < 540 ? 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); + } +} -- cgit v1.2.3 From 4ff85c2ac257eb5494626dae30e79c5f48430609 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 26 Jun 2016 10:22:17 +0200 Subject: Added notes about chromatic aberration --- examples/resources/shaders/distortion.fs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'examples/resources') diff --git a/examples/resources/shaders/distortion.fs b/examples/resources/shaders/distortion.fs index cd5951fe..79bc5fa1 100644 --- a/examples/resources/shaders/distortion.fs +++ b/examples/resources/shaders/distortion.fs @@ -56,4 +56,14 @@ void main() //tc.x = gl_FragCoord.x < 640 ? (2.0 * tc.x) : (2.0 * (tc.x - 0.5)); 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); + finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); + */ } -- cgit v1.2.3 From c4922c9e8854f9c936b28c3f8b00162b407ae503 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 27 Jun 2016 18:32:56 +0200 Subject: Reorganize shaders to respective folders --- examples/resources/shaders/base.vs | 26 ---- examples/resources/shaders/distortion.fs | 69 ---------- examples/resources/shaders/glsl100/distortion.fs | 68 ++++++++++ examples/resources/shaders/glsl330/distortion.fs | 69 ++++++++++ examples/resources/shaders/standard.fs | 155 ----------------------- examples/resources/shaders/standard.vs | 23 ---- 6 files changed, 137 insertions(+), 273 deletions(-) delete mode 100644 examples/resources/shaders/base.vs delete mode 100644 examples/resources/shaders/distortion.fs create mode 100644 examples/resources/shaders/glsl100/distortion.fs create mode 100644 examples/resources/shaders/glsl330/distortion.fs delete mode 100644 examples/resources/shaders/standard.fs delete mode 100644 examples/resources/shaders/standard.vs (limited to 'examples/resources') diff --git a/examples/resources/shaders/base.vs b/examples/resources/shaders/base.vs deleted file mode 100644 index 638cb8ae..00000000 --- a/examples/resources/shaders/base.vs +++ /dev/null @@ -1,26 +0,0 @@ -#version 330 - -// Input vertex attributes -in vec3 vertexPosition; -in vec2 vertexTexCoord; -in vec3 vertexNormal; -in vec4 vertexColor; - -// Input uniform values -uniform mat4 mvpMatrix; - -// Output vertex attributes (to fragment shader) -out vec2 fragTexCoord; -out vec4 fragColor; - -// NOTE: Add here your custom variables - -void main() -{ - // Send vertex attributes to fragment shader - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - - // Calculate final vertex position - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file diff --git a/examples/resources/shaders/distortion.fs b/examples/resources/shaders/distortion.fs deleted file mode 100644 index 79bc5fa1..00000000 --- a/examples/resources/shaders/distortion.fs +++ /dev/null @@ -1,69 +0,0 @@ -#version 330 - -// Input vertex attributes (from vertex shader) -in vec2 fragTexCoord; - -// Input uniform values -uniform sampler2D texture0; - -// Output fragment color -out vec4 finalColor; - -// NOTE: Add here your custom variables -const vec2 LeftLensCenter = vec2(0.2863248, 0.5); -const vec2 RightLensCenter = vec2(0.7136753, 0.5); -const vec2 LeftScreenCenter = vec2(0.25, 0.5); -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); - -/* -// Another set of default values -ChromaAbCorrection = {1.0, 0.0, 1.0, 0} -DistortionK = {1.0, 0.22, 0.24, 0} -Scale = {0.25, 0.5*AspectRatio, 0, 0} -ScaleIn = {4.0, 2/AspectRatio, 0, 0} -Left Screen Center = {0.25, 0.5, 0, 0} -Left Lens Center = {0.287994117, 0.5, 0, 0} -Right Screen Center = {0.75, 0.5, 0, 0} -Right Lens Center = {0.712005913, 0.5, 0, 0} -*/ - -// Scales input texture coordinates for distortion. -vec2 HmdWarp(vec2 in01, vec2 LensCenter) -{ - vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] - float rSq = theta.x*theta.x + theta.y*theta.y; - vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); - - return LensCenter + Scale*rvector; -} - -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 = gl_FragCoord.x < 540 ? LeftLensCenter : RightLensCenter; - vec2 ScreenCenter = gl_FragCoord.x < 540 ? 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); - } - - /* - // 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); - finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); - */ -} diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs new file mode 100644 index 00000000..3a1a45d3 --- /dev/null +++ b/examples/resources/shaders/glsl100/distortion.fs @@ -0,0 +1,68 @@ +#version 100 + +precision mediump float; + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; + +// Input uniform values +uniform sampler2D texture0; + +// NOTE: Add here your custom variables +const vec2 LeftLensCenter = vec2(0.2863248, 0.5); +const vec2 RightLensCenter = vec2(0.7136753, 0.5); +const vec2 LeftScreenCenter = vec2(0.25, 0.5); +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); + +/* +// Another set of default values +ChromaAbCorrection = {1.0, 0.0, 1.0, 0} +DistortionK = {1.0, 0.22, 0.24, 0} +Scale = {0.25, 0.5*AspectRatio, 0, 0} +ScaleIn = {4.0, 2/AspectRatio, 0, 0} +Left Screen Center = {0.25, 0.5, 0, 0} +Left Lens Center = {0.287994117, 0.5, 0, 0} +Right Screen Center = {0.75, 0.5, 0, 0} +Right Lens Center = {0.712005913, 0.5, 0, 0} +*/ + +// Scales input texture coordinates for distortion. +vec2 HmdWarp(vec2 in01, vec2 LensCenter) +{ + vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + + return LensCenter + Scale*rvector; +} + +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 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); + } + + /* + // 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); + finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); + */ +} diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs new file mode 100644 index 00000000..e43f8451 --- /dev/null +++ b/examples/resources/shaders/glsl330/distortion.fs @@ -0,0 +1,69 @@ +#version 330 + +// Input vertex attributes (from vertex shader) +in vec2 fragTexCoord; + +// Input uniform values +uniform sampler2D texture0; + +// Output fragment color +out vec4 finalColor; + +// NOTE: Add here your custom variables +const vec2 LeftLensCenter = vec2(0.2863248, 0.5); +const vec2 RightLensCenter = vec2(0.7136753, 0.5); +const vec2 LeftScreenCenter = vec2(0.25, 0.5); +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); + +/* +// Another set of default values +ChromaAbCorrection = {1.0, 0.0, 1.0, 0} +DistortionK = {1.0, 0.22, 0.24, 0} +Scale = {0.25, 0.5*AspectRatio, 0, 0} +ScaleIn = {4.0, 2/AspectRatio, 0, 0} +Left Screen Center = {0.25, 0.5, 0, 0} +Left Lens Center = {0.287994117, 0.5, 0, 0} +Right Screen Center = {0.75, 0.5, 0, 0} +Right Lens Center = {0.712005913, 0.5, 0, 0} +*/ + +// Scales input texture coordinates for distortion. +vec2 HmdWarp(vec2 in01, vec2 LensCenter) +{ + vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + + return LensCenter + Scale*rvector; +} + +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 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); + } + + /* + // 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); + finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); + */ +} diff --git a/examples/resources/shaders/standard.fs b/examples/resources/shaders/standard.fs deleted file mode 100644 index e5a6d1bc..00000000 --- a/examples/resources/shaders/standard.fs +++ /dev/null @@ -1,155 +0,0 @@ -#version 330 - -in vec3 fragPosition; -in vec2 fragTexCoord; -in vec4 fragColor; -in vec3 fragNormal; - -out vec4 finalColor; - -uniform sampler2D texture0; -uniform sampler2D texture1; -uniform sampler2D texture2; - -uniform vec4 colAmbient; -uniform vec4 colDiffuse; -uniform vec4 colSpecular; -uniform float glossiness; - -uniform int useNormal; -uniform int useSpecular; - -uniform mat4 modelMatrix; -uniform vec3 viewDir; - -struct Light { - int enabled; - int type; - vec3 position; - vec3 direction; - vec4 diffuse; - float intensity; - float radius; - float coneAngle; -}; - -const int maxLights = 8; -uniform int lightsCount; -uniform Light lights[maxLights]; - -vec3 CalcPointLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 surfaceToLight = l.position - surfacePos; - - // Diffuse shading - float brightness = clamp(dot(n, surfaceToLight)/(length(surfaceToLight)*length(n)), 0, 1); - float diff = 1.0/dot(surfaceToLight/l.radius, surfaceToLight/l.radius)*brightness*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(-l.direction + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (diff*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcDirectionalLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Specular shading - float spec = 0.0; - if (diff > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - // Combine results - return (diff*l.intensity*l.diffuse.rgb + spec*colSpecular.rgb); -} - -vec3 CalcSpotLight(Light l, vec3 n, vec3 v, float s) -{ - vec3 surfacePos = vec3(modelMatrix*vec4(fragPosition, 1)); - vec3 lightToSurface = normalize(surfacePos - l.position); - vec3 lightDir = normalize(-l.direction); - - // Diffuse shading - float diff = clamp(dot(n, lightDir), 0.0, 1.0)*l.intensity; - - // Spot attenuation - float attenuation = clamp(dot(n, lightToSurface), 0.0, 1.0); - attenuation = dot(lightToSurface, -lightDir); - - float lightToSurfaceAngle = degrees(acos(attenuation)); - if (lightToSurfaceAngle > l.coneAngle) attenuation = 0.0; - - float falloff = (l.coneAngle - lightToSurfaceAngle)/l.coneAngle; - - // Combine diffuse and attenuation - float diffAttenuation = diff*attenuation; - - // Specular shading - float spec = 0.0; - if (diffAttenuation > 0.0) - { - vec3 h = normalize(lightDir + v); - spec = pow(dot(n, h), 3 + glossiness)*s; - } - - return (falloff*(diffAttenuation*l.diffuse.rgb + spec*colSpecular.rgb)); -} - -void main() -{ - // Calculate fragment normal in screen space - // NOTE: important to multiply model matrix by fragment normal to apply model transformation (rotation and scale) - mat3 normalMatrix = transpose(inverse(mat3(modelMatrix))); - vec3 normal = normalize(normalMatrix*fragNormal); - - // Normalize normal and view direction vectors - vec3 n = normalize(normal); - vec3 v = normalize(viewDir); - - // Calculate diffuse texture color fetching - vec4 texelColor = texture(texture0, fragTexCoord); - vec3 lighting = colAmbient.rgb; - - // Calculate normal texture color fetching or set to maximum normal value by default - if (useNormal == 1) - { - n *= texture(texture1, fragTexCoord).rgb; - n = normalize(n); - } - - // Calculate specular texture color fetching or set to maximum specular value by default - float spec = 1.0; - if (useSpecular == 1) spec *= normalize(texture(texture2, fragTexCoord).r); - - for (int i = 0; i < lightsCount; i++) - { - // Check if light is enabled - if (lights[i].enabled == 1) - { - // Calculate lighting based on light type - switch (lights[i].type) - { - case 0: lighting += CalcPointLight(lights[i], n, v, spec); break; - case 1: lighting += CalcDirectionalLight(lights[i], n, v, spec); break; - case 2: lighting += CalcSpotLight(lights[i], n, v, spec); break; - default: break; - } - } - } - - // Calculate final fragment color - finalColor = vec4(texelColor.rgb*lighting*colDiffuse.rgb, texelColor.a*colDiffuse.a); -} diff --git a/examples/resources/shaders/standard.vs b/examples/resources/shaders/standard.vs deleted file mode 100644 index fc0a5ff4..00000000 --- a/examples/resources/shaders/standard.vs +++ /dev/null @@ -1,23 +0,0 @@ -#version 330 - -in vec3 vertexPosition; -in vec3 vertexNormal; -in vec2 vertexTexCoord; -in vec4 vertexColor; - -out vec3 fragPosition; -out vec2 fragTexCoord; -out vec4 fragColor; -out vec3 fragNormal; - -uniform mat4 mvpMatrix; - -void main() -{ - fragPosition = vertexPosition; - fragTexCoord = vertexTexCoord; - fragColor = vertexColor; - fragNormal = vertexNormal; - - gl_Position = mvpMatrix*vec4(vertexPosition, 1.0); -} \ No newline at end of file -- cgit v1.2.3 From 5a4eb34c39e404fdd5804299111477a10dd3895d Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 27 Jun 2016 18:59:03 +0200 Subject: Corrected issue on distortion shader --- examples/resources/shaders/glsl100/distortion.fs | 10 +++------- examples/resources/shaders/glsl330/distortion.fs | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'examples/resources') 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); */ } -- cgit v1.2.3 From 6fbf6a1c234ab7db9b975109c3c2138f83684442 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 27 Jun 2016 19:18:53 +0200 Subject: Redesigned distortion shader, added chromatic aberration --- examples/resources/shaders/glsl100/distortion.fs | 51 ++++++++++++----------- examples/resources/shaders/glsl330/distortion.fs | 53 ++++++++++++------------ 2 files changed, 53 insertions(+), 51 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs index 19e6656a..d7b687bf 100644 --- a/examples/resources/shaders/glsl100/distortion.fs +++ b/examples/resources/shaders/glsl100/distortion.fs @@ -29,36 +29,37 @@ Right Screen Center = {0.75, 0.5, 0, 0} Right Lens Center = {0.712005913, 0.5, 0, 0} */ -// Scales input texture coordinates for distortion. -vec2 HmdWarp(vec2 in01, vec2 LensCenter) -{ - vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] - float rSq = theta.x*theta.x + theta.y*theta.y; - vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); - - return LensCenter + Scale*rvector; -} - 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 < 0.5 ? LeftLensCenter : RightLensCenter; vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; + + // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) + vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + //vec2 tc = LensCenter + Scale*theta1; + + // Detect whether blue texture coordinates are out of range since these will scaled out the furthest + vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); + vec2 tcBlue = LensCenter + Scale*thetaBlue; - vec2 tc = HmdWarp(fragTexCoord, LensCenter); + if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + else + { + // Do blue texture lookup + float blue = texture2D(texture0, tcBlue).b; - 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 gl_FragColor = 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); - finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); - */ + // Do green lookup (no scaling) + vec2 tcGreen = LensCenter + Scale*theta1; + float green = texture2D(texture0, tcGreen).g; + + // Do red scale and lookup + vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); + vec2 tcRed = LensCenter + Scale*thetaRed; + float red = texture2D(texture0, tcRed).r; + + gl_FragColor = vec4(red, green, blue, 1.0); + } } diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs index c8777c18..4cd9937f 100644 --- a/examples/resources/shaders/glsl330/distortion.fs +++ b/examples/resources/shaders/glsl330/distortion.fs @@ -17,7 +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); +const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); /* // Another set of default values @@ -31,37 +31,38 @@ Right Screen Center = {0.75, 0.5, 0, 0} Right Lens Center = {0.712005913, 0.5, 0, 0} */ -// Scales input texture coordinates for distortion. -vec2 HmdWarp(vec2 in01, vec2 LensCenter) -{ - vec2 theta = (in01 - LensCenter)*ScaleIn; // Scales to [-1, 1] - float rSq = theta.x*theta.x + theta.y*theta.y; - vec2 rvector = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); - - return LensCenter + Scale*rvector; -} - 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 < 0.5 ? LeftLensCenter : RightLensCenter; vec2 ScreenCenter = fragTexCoord.x < 0.5 ? LeftScreenCenter : RightScreenCenter; + + // Scales input texture coordinates for distortion: vec2 HmdWarp(vec2 fragTexCoord, vec2 LensCenter) + vec2 theta = (fragTexCoord - LensCenter)*ScaleIn; // Scales to [-1, 1] + float rSq = theta.x*theta.x + theta.y*theta.y; + vec2 theta1 = theta*(HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z*rSq*rSq + HmdWarpParam.w*rSq*rSq*rSq); + //vec2 tc = LensCenter + Scale*theta1; + + // Detect whether blue texture coordinates are out of range since these will scaled out the furthest + vec2 thetaBlue = theta1*(ChromaAbParam.z + ChromaAbParam.w*rSq); + vec2 tcBlue = LensCenter + Scale*thetaBlue; - vec2 tc = HmdWarp(fragTexCoord, LensCenter); + if (any(bvec2(clamp(tcBlue, ScreenCenter - vec2(0.25, 0.5), ScreenCenter + vec2(0.25, 0.5)) - tcBlue))) finalColor = vec4(0.0, 0.0, 0.0, 1.0); + else + { + // Do blue texture lookup + float blue = texture(texture0, tcBlue).b; - 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 - ChromaAbCorrection.x); - vec4 gValue = texture2D(texture0, fragTexCoord - ChromaAbCorrection.y); - vec4 bValue = texture2D(texture0, fragTexCoord - ChromaAbCorrection.z); + // Do green lookup (no scaling) + vec2 tcGreen = LensCenter + Scale*theta1; + float green = texture(texture0, tcGreen).g; + + // Do red scale and lookup + vec2 thetaRed = theta1*(ChromaAbParam.x + ChromaAbParam.y*rSq); + vec2 tcRed = LensCenter + Scale*thetaRed; + float red = texture(texture0, tcRed).r; - finalColor = vec4(rValue.r, gValue.g, bValue.b, 1.0); - */ + finalColor = vec4(red, green, blue, 1.0); + } } + -- cgit v1.2.3 From be61d2f8c1d3ce4579b4e74557fb4773624bf00c Mon Sep 17 00:00:00 2001 From: raysan5 Date: Mon, 27 Jun 2016 20:09:10 +0200 Subject: Added missing parameter --- examples/resources/shaders/glsl100/distortion.fs | 1 + 1 file changed, 1 insertion(+) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs index d7b687bf..a0a6cc18 100644 --- a/examples/resources/shaders/glsl100/distortion.fs +++ b/examples/resources/shaders/glsl100/distortion.fs @@ -16,6 +16,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 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); /* // Another set of default values -- cgit v1.2.3 From ee72654b557202a673f042484c83d3020ae618b8 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 4 Jul 2016 01:29:23 +0200 Subject: Redesigned stereo rendering mechanism Now it's easier for the user! Just init Oculus device and get stereo rendering! --- examples/resources/shaders/glsl330/distortion.fs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs index 4cd9937f..62856341 100644 --- a/examples/resources/shaders/glsl330/distortion.fs +++ b/examples/resources/shaders/glsl330/distortion.fs @@ -10,12 +10,13 @@ uniform sampler2D texture0; out vec4 finalColor; // NOTE: Add here your custom variables -const vec2 LeftLensCenter = vec2(0.2863248, 0.5); -const vec2 RightLensCenter = vec2(0.7136753, 0.5); +const vec2 LeftLensCenter = vec2(0.288, 0.5); +const vec2 RightLensCenter = vec2(0.712, 0.5); const vec2 LeftScreenCenter = vec2(0.25, 0.5); 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); +uniform vec2 Scale = vec2(0.25, 0.45); //vec2(0.1469278, 0.2350845); +uniform vec2 ScaleIn = vec2(4, 2.2222); + const vec4 HmdWarpParam = vec4(1, 0.22, 0.24, 0); const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); -- cgit v1.2.3 From 884e13ac2faea7ea91af1fa5a4c1cfaf44dfb4af Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 8 Jul 2016 20:32:06 +0200 Subject: Updated VR support -IN PROGRESS- - Embedded VR distortion shader - Ready to support multiple VR devices - Fallback to VR Simulator if device not ready - Support mono rendering over stereo rendering --- examples/resources/shaders/glsl100/distortion.fs | 20 ++++---------------- examples/resources/shaders/glsl330/distortion.fs | 21 ++++----------------- 2 files changed, 8 insertions(+), 33 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs index a0a6cc18..f19c88ae 100644 --- a/examples/resources/shaders/glsl100/distortion.fs +++ b/examples/resources/shaders/glsl100/distortion.fs @@ -8,28 +8,16 @@ varying vec2 fragTexCoord; // Input uniform values uniform sampler2D texture0; -// NOTE: Add here your custom variables +// NOTE: Default parameters for Oculus Rift device const vec2 LeftLensCenter = vec2(0.2863248, 0.5); const vec2 RightLensCenter = vec2(0.7136753, 0.5); const vec2 LeftScreenCenter = vec2(0.25, 0.5); 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 vec2 Scale = vec2(0.25, 0.45); +const vec2 ScaleIn = vec2(4.0, 2.2222); +const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); -/* -// Another set of default values -ChromaAbCorrection = {1.0, 0.0, 1.0, 0} -DistortionK = {1.0, 0.22, 0.24, 0} -Scale = {0.25, 0.5*AspectRatio, 0, 0} -ScaleIn = {4.0, 2/AspectRatio, 0, 0} -Left Screen Center = {0.25, 0.5, 0, 0} -Left Lens Center = {0.287994117, 0.5, 0, 0} -Right Screen Center = {0.75, 0.5, 0, 0} -Right Lens Center = {0.712005913, 0.5, 0, 0} -*/ - void main() { // The following two variables need to be set per eye diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs index 62856341..635b86ac 100644 --- a/examples/resources/shaders/glsl330/distortion.fs +++ b/examples/resources/shaders/glsl330/distortion.fs @@ -9,29 +9,16 @@ uniform sampler2D texture0; // Output fragment color out vec4 finalColor; -// NOTE: Add here your custom variables +// NOTE: Default parameters for Oculus Rift device const vec2 LeftLensCenter = vec2(0.288, 0.5); const vec2 RightLensCenter = vec2(0.712, 0.5); const vec2 LeftScreenCenter = vec2(0.25, 0.5); const vec2 RightScreenCenter = vec2(0.75, 0.5); -uniform vec2 Scale = vec2(0.25, 0.45); //vec2(0.1469278, 0.2350845); -uniform vec2 ScaleIn = vec2(4, 2.2222); - -const vec4 HmdWarpParam = vec4(1, 0.22, 0.24, 0); +const vec2 Scale = vec2(0.25, 0.45); +const vec2 ScaleIn = vec2(4.0, 2.2222); +const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); -/* -// Another set of default values -ChromaAbCorrection = {1.0, 0.0, 1.0, 0} -DistortionK = {1.0, 0.22, 0.24, 0} -Scale = {0.25, 0.5*AspectRatio, 0, 0} -ScaleIn = {4.0, 2/AspectRatio, 0, 0} -Left Screen Center = {0.25, 0.5, 0, 0} -Left Lens Center = {0.287994117, 0.5, 0, 0} -Right Screen Center = {0.75, 0.5, 0, 0} -Right Lens Center = {0.712005913, 0.5, 0, 0} -*/ - void main() { // The following two variables need to be set per eye -- cgit v1.2.3 From d587cc0e36a45798bad7ff1c01d7ba84723d011e Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 10 Jul 2016 20:07:54 +0200 Subject: Setup values for Oculus Rift DK2 Oculus Rift CV1 default values seem not to be available... --- examples/resources/shaders/glsl100/distortion.fs | 4 ++-- examples/resources/shaders/glsl330/distortion.fs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/distortion.fs b/examples/resources/shaders/glsl100/distortion.fs index f19c88ae..50116ce0 100644 --- a/examples/resources/shaders/glsl100/distortion.fs +++ b/examples/resources/shaders/glsl100/distortion.fs @@ -8,13 +8,13 @@ varying vec2 fragTexCoord; // Input uniform values uniform sampler2D texture0; -// NOTE: Default parameters for Oculus Rift device +// NOTE: Default parameters for Oculus Rift DK2 device const vec2 LeftLensCenter = vec2(0.2863248, 0.5); const vec2 RightLensCenter = vec2(0.7136753, 0.5); const vec2 LeftScreenCenter = vec2(0.25, 0.5); const vec2 RightScreenCenter = vec2(0.75, 0.5); const vec2 Scale = vec2(0.25, 0.45); -const vec2 ScaleIn = vec2(4.0, 2.2222); +const vec2 ScaleIn = vec2(4.0, 2.5); const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); diff --git a/examples/resources/shaders/glsl330/distortion.fs b/examples/resources/shaders/glsl330/distortion.fs index 635b86ac..cb4be8fc 100644 --- a/examples/resources/shaders/glsl330/distortion.fs +++ b/examples/resources/shaders/glsl330/distortion.fs @@ -9,13 +9,13 @@ uniform sampler2D texture0; // Output fragment color out vec4 finalColor; -// NOTE: Default parameters for Oculus Rift device -const vec2 LeftLensCenter = vec2(0.288, 0.5); -const vec2 RightLensCenter = vec2(0.712, 0.5); +// NOTE: Default parameters for Oculus Rift DK2 device +const vec2 LeftLensCenter = vec2(0.2863248, 0.5); +const vec2 RightLensCenter = vec2(0.7136753, 0.5); const vec2 LeftScreenCenter = vec2(0.25, 0.5); const vec2 RightScreenCenter = vec2(0.75, 0.5); const vec2 Scale = vec2(0.25, 0.45); -const vec2 ScaleIn = vec2(4.0, 2.2222); +const vec2 ScaleIn = vec2(4.0, 2.5); const vec4 HmdWarpParam = vec4(1.0, 0.22, 0.24, 0.0); const vec4 ChromaAbParam = vec4(0.996, -0.004, 1.014, 0.0); -- cgit v1.2.3 From 3876f19d6a385001a4238ec27bcf3d7643dd190f Mon Sep 17 00:00:00 2001 From: raysan5 Date: Tue, 12 Jul 2016 01:54:47 +0200 Subject: Corrected some issues on OpenGL ES --- examples/resources/shaders/glsl100/grayscale.fs | 4 ++-- examples/resources/shaders/glsl100/swirl.fs | 8 ++++---- examples/resources/shaders/glsl330/swirl.fs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'examples/resources') diff --git a/examples/resources/shaders/glsl100/grayscale.fs b/examples/resources/shaders/glsl100/grayscale.fs index cf857488..15174ea5 100644 --- a/examples/resources/shaders/glsl100/grayscale.fs +++ b/examples/resources/shaders/glsl100/grayscale.fs @@ -8,14 +8,14 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables void main() { // Texel color fetching from texture sampler - vec4 texelColor = texture2D(texture0, fragTexCoord)*fragTintColor*fragColor; + vec4 texelColor = texture2D(texture0, fragTexCoord)*colDiffuse*fragColor; // Convert texel color to grayscale using NTSC conversion weights float gray = dot(texelColor.rgb, vec3(0.299, 0.587, 0.114)); diff --git a/examples/resources/shaders/glsl100/swirl.fs b/examples/resources/shaders/glsl100/swirl.fs index 0d6d24f2..ca7668b2 100644 --- a/examples/resources/shaders/glsl100/swirl.fs +++ b/examples/resources/shaders/glsl100/swirl.fs @@ -8,7 +8,7 @@ varying vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // NOTE: Add here your custom variables @@ -18,7 +18,7 @@ const float renderHeight = 480.0; // Use uniforms instead... float radius = 250.0; float angle = 0.8; -uniform vec2 center = vec2(200.0, 200.0); +uniform vec2 center; void main() { @@ -39,7 +39,7 @@ void main() } tc += center; - vec3 color = texture2D(texture0, tc/texSize).rgb; + vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; - gl_FragColor = vec4(color, 1.0);; + gl_FragColor = vec4(color.rgb, 1.0);; } \ No newline at end of file diff --git a/examples/resources/shaders/glsl330/swirl.fs b/examples/resources/shaders/glsl330/swirl.fs index 80c16cc9..5d238ac9 100644 --- a/examples/resources/shaders/glsl330/swirl.fs +++ b/examples/resources/shaders/glsl330/swirl.fs @@ -6,7 +6,7 @@ in vec4 fragColor; // Input uniform values uniform sampler2D texture0; -uniform vec4 fragTintColor; +uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; @@ -40,7 +40,7 @@ void main() } tc += center; - vec3 color = texture(texture0, tc/texSize).rgb; + vec4 color = texture2D(texture0, tc/texSize)*colDiffuse*fragColor;; - finalColor = vec4(color, 1.0);; + finalColor = vec4(color.rgb, 1.0);; } \ No newline at end of file -- cgit v1.2.3