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

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

lolfx: use square brackets to indicate shader sections.

File size: 2.2 KB
Line 
1[vert.glsl]
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[frag.glsl]
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 tc = 0.0, ta = 0.0;
35        {
36            float s = 3.0 + 2.0 * in_Point.z;
37            vec2 p = pass_Position - in_Point.xy * 0.9;
38            float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
39            float u = t * t * t * t;
40            tc += 3.0 * t * t - 2.0 * t * t * t;
41            ta += 3.0 * u * u - 2.0 * u * u * u;
42        }
43
44        gl_FragColor = vec4(tc * in_Color, ta + 0.1);
45    }
46    else
47    {
48        vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5);
49        gl_FragColor = vec4(texture2D(in_Texture, texcoords).xyz, 1.0);
50    }
51}
52
53[vert.hlsl]
54
55void main(float2 in_Position : POSITION,
56          out float2 pass_Position : TEXCOORD0,
57          out float4 out_Position : POSITION)
58{
59    pass_Position = in_Position;
60    out_Position = float4(in_Position, 0.0, 1.0);
61}
62
63[frag.hlsl]
64
65void main(in float2 pass_Position : TEXCOORD0,
66          uniform sampler2D in_Texture,
67          uniform float in_Flag,
68          uniform float3 in_Point,
69          uniform float3 in_Color,
70          out float4 out_FragColor : COLOR)
71{
72    if (in_Flag == 0.0)
73    {
74        float tc = 0.0, ta = 0.0;
75        {
76            float s = 3.0 + 2.0 * in_Point.z;
77            float2 p = pass_Position - in_Point.xy * 0.9;
78            float t = clamp(1.2 - dot(s * p, s * p), 0.0, 1.0);
79            float u = t * t * t * t;
80            tc += 3.0 * t * t - 2.0 * t * t * t;
81            ta += 3.0 * u * u - 2.0 * u * u * u;
82        }
83
84        out_FragColor = float4(tc * in_Color, ta + 0.1);
85    }
86    else
87    {
88        float2 texcoords = pass_Position * float2(0.5, -0.5) + float2(0.5, 0.5);
89        /* FIXME: this should be passed as a uniform or something */
90        texcoords += float2(0.5 / 800.0, 0.5 / 600.0);
91        out_FragColor = float4(tex2D(in_Texture, texcoords).xyz, 1.0);
92    }
93}
94
Note: See TracBrowser for help on using the repository browser.