1 <?xml version="1.0" encoding="UTF-8"?>
3 XML Shader Spec v1.1 Test Shader by Screwtape
5 This shader is designed to exercise two corner-cases of the XML Shader Spec
6 v1.1, to give implementors a quick visual way to check their
9 - This shader draws a radial gradient centred on the (1,1) texture
10 coordinate, in each of the R, G, B channels, each in a subsequent shader
12 - If the host application sets up the orientation of each intermediate
13 texture correctly, the final rendered result should show the original
14 texture in the correct orientation, with a white radial gradient
15 centred on the lower-right corner.
16 - If the host application messes something up, the result will probably
17 have different-coloured gradients in different corners.
19 - This shader temporarily stores red-channel data in the "A" channel of the
20 intermediate textures.
21 - If the host application allocates intermediate textures with the
22 "GL_RGBA" internal format, everything should be fine.
23 - If the host application allocates intermediate textures with some other
24 format, certain colour channels will probably be forced to 0 or the
25 maximum value, adding a weird tint to the input texture.
27 - This shader has a pass that overlays an image sampled from outside the
28 0..1 texture coordinate range.
29 - If the host application correctly sets the texture-clamping mode to
30 GL_CLAMP_TO_BORDER, all the colours read from the sampler should be
31 pure black, and this pass will have no visible effect.
32 - If the host application sets any other kind of texture-clamping mode,
33 the colours sampled will be from elsewhere in the texture, and the
34 result will be some kind of horrible mess.
36 Copyright 2012 Screwtape <screwtape@froup.com>
38 Permission to use, copy, modify, and/or distribute this software for any
39 purpose with or without fee is hereby granted, provided that the above
40 copyright notice and this permission notice appear in all copies.
42 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
43 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
44 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
45 SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
46 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
47 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
48 IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
51 <shader language="GLSL">
53 uniform vec2 rubyInputSize;
54 uniform vec2 rubyTextureSize;
55 uniform sampler2D rubyTexture;
57 vec2 imageCoordMax = rubyInputSize / rubyTextureSize;
58 vec2 imageCoord = gl_TexCoord[0].xy / imageCoordMax;
59 gl_FragColor = texture2D(rubyTexture, gl_TexCoord[0].xy);
60 gl_FragColor.a = gl_FragColor.r + imageCoord.x * imageCoord.y;
64 uniform vec2 rubyInputSize;
65 uniform vec2 rubyTextureSize;
66 uniform sampler2D rubyTexture;
68 vec2 imageCoordMax = rubyInputSize / rubyTextureSize;
69 vec2 imageCoord = gl_TexCoord[0].xy / imageCoordMax;
70 gl_FragColor = texture2D(rubyTexture, gl_TexCoord[0].xy);
71 gl_FragColor.g += imageCoord.x * imageCoord.y;
72 gl_FragColor.r = gl_FragColor.a;
76 uniform vec2 rubyInputSize;
77 uniform vec2 rubyTextureSize;
78 uniform sampler2D rubyTexture;
80 vec2 imageCoordMax = rubyInputSize / rubyTextureSize;
81 vec2 imageCoord = gl_TexCoord[0].xy / imageCoordMax;
82 gl_FragColor = texture2D(rubyTexture, gl_TexCoord[0].xy);
83 gl_FragColor.b += imageCoord.x * imageCoord.y;
87 uniform sampler2D rubyTexture;
89 gl_FragColor = texture2D(rubyTexture, gl_TexCoord[0].xy);
90 gl_FragColor += texture2D(rubyTexture, -gl_TexCoord[0].xy);