diff options
| author | Ray <raysan5@gmail.com> | 2015-09-03 01:49:58 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2015-09-03 01:49:58 +0200 |
| commit | 77558eec0caf0736fa36c96b5807d928317d3dd7 (patch) | |
| tree | 860d9e77d27729fa2572aa8207d77f8def083ccd /examples/resources | |
| parent | 858ccb350dab317483bf58a5852f88df0a49a7b2 (diff) | |
| parent | d05acb1b6878b101ecbde0aeb3aa1bcf80b960af (diff) | |
| download | raylib-1.3.0.tar.gz raylib-1.3.0.zip | |
Merge pull request #28 from raysan5/develop1.3.0-installer1.3.0
Integrating Develop branch
Diffstat (limited to 'examples/resources')
| -rw-r--r-- | examples/resources/shaders/base.vs | 14 | ||||
| -rw-r--r-- | examples/resources/shaders/bloom.fs | 42 | ||||
| -rw-r--r-- | examples/resources/shaders/grayscale.fs | 17 | ||||
| -rw-r--r-- | examples/resources/shaders/shapes_base.vs (renamed from examples/resources/shaders/custom.vs) | 7 | ||||
| -rw-r--r-- | examples/resources/shaders/shapes_grayscale.fs (renamed from examples/resources/shaders/custom.fs) | 11 | ||||
| -rw-r--r-- | examples/resources/shaders/swirl.fs | 41 |
6 files changed, 111 insertions, 21 deletions
diff --git a/examples/resources/shaders/base.vs b/examples/resources/shaders/base.vs index 78e543b7..59eae0a0 100644 --- a/examples/resources/shaders/base.vs +++ b/examples/resources/shaders/base.vs @@ -1,19 +1,19 @@ -#version 110 +#version 330 -attribute vec3 vertexPosition; -attribute vec2 vertexTexCoord; -attribute vec4 vertexColor; +in vec3 vertexPosition; +in vec2 vertexTexCoord; +in vec3 vertexNormal; + +out vec2 fragTexCoord; uniform mat4 projectionMatrix; uniform mat4 modelviewMatrix; -varying vec2 fragTexCoord; -varying vec4 fragColor; +// NOTE: Add here your custom variables void main() { fragTexCoord = vertexTexCoord; - fragColor = vertexColor; gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0); }
\ No newline at end of file diff --git a/examples/resources/shaders/bloom.fs b/examples/resources/shaders/bloom.fs new file mode 100644 index 00000000..f9cebe18 --- /dev/null +++ b/examples/resources/shaders/bloom.fs @@ -0,0 +1,42 @@ +#version 330 + +in vec2 fragTexCoord; + +out vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 tintColor; + +// NOTE: Add here your custom variables + +void main() +{ + vec4 sum = vec4(0); + vec4 tc = vec4(0); + + for (int i = -4; i < 4; i++) + { + for (int j = -3; j < 3; j++) + { + sum += texture2D(texture0, fragTexCoord + vec2(j, i)*0.004) * 0.25; + } + } + + if (texture2D(texture0, fragTexCoord).r < 0.3) + { + tc = sum*sum*0.012 + texture2D(texture0, fragTexCoord); + } + else + { + if (texture2D(texture0, fragTexCoord).r < 0.5) + { + tc = sum*sum*0.009 + texture2D(texture0, fragTexCoord); + } + else + { + tc = sum*sum*0.0075 + texture2D(texture0, fragTexCoord); + } + } + + fragColor = tc; +}
\ No newline at end of file diff --git a/examples/resources/shaders/grayscale.fs b/examples/resources/shaders/grayscale.fs index 1b778871..38337e00 100644 --- a/examples/resources/shaders/grayscale.fs +++ b/examples/resources/shaders/grayscale.fs @@ -1,15 +1,20 @@ -#version 110 +#version 330 + +in vec2 fragTexCoord; + +out vec4 fragColor; uniform sampler2D texture0; -varying vec2 fragTexCoord; -varying vec4 fragColor; +uniform vec4 tintColor; + +// NOTE: Add here your custom variables void main() { - vec4 base = texture2D(texture0, fragTexCoord)*fragColor; - + vec4 base = texture2D(texture0, fragTexCoord)*tintColor; + // Convert to grayscale using NTSC conversion weights float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); - gl_FragColor = vec4(gray, gray, gray, base.a); + fragColor = vec4(gray, gray, gray, tintColor.a); }
\ No newline at end of file diff --git a/examples/resources/shaders/custom.vs b/examples/resources/shaders/shapes_base.vs index 629c954d..78e543b7 100644 --- a/examples/resources/shaders/custom.vs +++ b/examples/resources/shaders/shapes_base.vs @@ -1,16 +1,19 @@ -#version 330 +#version 110 attribute vec3 vertexPosition; attribute vec2 vertexTexCoord; -attribute vec3 vertexNormal; +attribute vec4 vertexColor; uniform mat4 projectionMatrix; uniform mat4 modelviewMatrix; varying vec2 fragTexCoord; +varying vec4 fragColor; void main() { fragTexCoord = vertexTexCoord; + fragColor = vertexColor; + gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0); }
\ No newline at end of file diff --git a/examples/resources/shaders/custom.fs b/examples/resources/shaders/shapes_grayscale.fs index 1e53933b..1b778871 100644 --- a/examples/resources/shaders/custom.fs +++ b/examples/resources/shaders/shapes_grayscale.fs @@ -1,16 +1,15 @@ -#version 330 +#version 110 uniform sampler2D texture0; varying vec2 fragTexCoord; - -uniform vec4 tintColor; +varying vec4 fragColor; void main() { - vec4 base = texture2D(texture0, fragTexCoord)*tintColor; - + vec4 base = texture2D(texture0, fragTexCoord)*fragColor; + // Convert to grayscale using NTSC conversion weights float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114)); - gl_FragColor = vec4(gray, gray, gray, tintColor.a); + gl_FragColor = vec4(gray, gray, gray, base.a); }
\ No newline at end of file diff --git a/examples/resources/shaders/swirl.fs b/examples/resources/shaders/swirl.fs new file mode 100644 index 00000000..ba26cc05 --- /dev/null +++ b/examples/resources/shaders/swirl.fs @@ -0,0 +1,41 @@ +#version 330 + +in vec2 fragTexCoord; + +out vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 tintColor; + +// NOTE: Add here your custom variables + +const float renderWidth = 800; // HARDCODED for example! +const float renderHeight = 480; // Use uniforms instead... + +float radius = 250.0; +float angle = 0.8; + +uniform vec2 center = vec2(200, 200); + +void main (void) +{ + vec2 texSize = vec2(renderWidth, renderHeight); + vec2 tc = fragTexCoord*texSize; + tc -= center; + float dist = length(tc); + + if (dist < radius) + { + float percent = (radius - dist)/radius; + float theta = percent*percent*angle*8.0; + float s = sin(theta); + float c = cos(theta); + + tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c))); + } + + tc += center; + vec3 color = texture2D(texture0, tc/texSize).rgb; + + fragColor = vec4(color, 1.0);; +}
\ No newline at end of file |
