Ignore:
Timestamp:
Aug 13, 2012, 2:45:12 AM (8 years ago)
Author:
sam
Message:

tutorial: make the FBO example display something at last, so we can port
it to DirectX.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tutorial/08_fbo.lolfx

    r1574 r1730  
    33#version 120
    44
     5attribute vec2 in_Position;
     6
     7varying vec2 pass_Position;
     8
    59void main()
    610{
    7     gl_Position = gl_Vertex;
    8     gl_TexCoord[0] = gl_MultiTexCoord0;
     11    pass_Position = in_Position;
     12    gl_Position = vec4(in_Position, 0.0, 1.0);
    913}
    1014
     
    1317#version 120
    1418
    15 uniform sampler2D texture;
     19uniform sampler2D in_Texture;
     20uniform float in_Flag;
     21uniform vec3 in_Point;
     22uniform vec3 in_Color;
     23
     24varying vec2 pass_Position;
    1625
    1726void main(void)
    1827{
    19     gl_FragColor = vec4(texture2D(texture, gl_TexCoord[0].xy).xyz, 1.0);
     28    if (in_Flag == 0.0)
     29    {
     30        float s = 4.0 + 4.0 * in_Point.z;
     31        vec2 p = pass_Position - in_Point.xy * 0.8;
     32        float f = clamp(1.0 - dot(s * p, s * p), 0.0, 1.0);
     33        f = sqrt(f);
     34        gl_FragColor = vec4(f * in_Color, f + 0.1);
     35    }
     36    else
     37    {
     38        vec2 texcoords = pass_Position * 0.5 + vec2(0.5, 0.5);
     39        gl_FragColor = vec4(texture2D(in_Texture, texcoords).xyz, 1.0);
     40    }
    2041}
    2142
Note: See TracChangeset for help on using the changeset viewer.