source: trunk/tutorial/08_fbo.lolfx @ 1734

Last change on this file since 1734 was 1734, checked in by sam, 8 years ago

tutorial: fix the FBO shader so that it works with OpenGL ES.

File size: 1.1 KB
Line 
1-- GLSL.Vert --
2
3#version 120
4
5attribute vec2 in_Position;
6
7varying vec2 pass_Position;
8
9void main()
10{
11    pass_Position = in_Position;
12    gl_Position = vec4(in_Position, 0.0, 1.0);
13}
14
15-- GLSL.Frag --
16
17#version 120
18
19#if defined GL_ES
20precision highp float;
21#endif
22
23uniform sampler2D in_Texture;
24uniform float in_Flag;
25uniform vec3 in_Point;
26uniform vec3 in_Color;
27
28varying vec2 pass_Position;
29
30void main(void)
31{
32    if (in_Flag == 0.0)
33    {
34        float s = 4.0 + 4.0 * in_Point.z;
35        vec2 p = pass_Position - in_Point.xy * 0.8;
36        float f = clamp(1.0 - dot(s * p, s * p), 0.0, 1.0);
37        f = sqrt(f);
38        gl_FragColor = vec4(f * in_Color, f + 0.1);
39    }
40    else
41    {
42        vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5);
43        gl_FragColor = vec4(texture2D(in_Texture, texcoords).xyz, 1.0);
44    }
45}
46
47-- HLSL.Vert --
48
49void main(float2 in_Position : POSITION,
50          out float4 out_Position : POSITION)
51{
52    out_Position = float4(in_Position, 0.0, 1.0);
53}
54
55-- HLSL.Frag --
56
57void main(out float4 out_FragColor : COLOR)
58{
59    out_FragColor = float4(0.7, 0.2, 0.5, 1.0);
60}
61
Note: See TracBrowser for help on using the repository browser.