Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/OldMovieFP.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 5 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.6 KB
Line 
1#version 100
2
3precision mediump int;
4precision mediump float;
5
6varying vec2 oUv0;
7//varying vec2 uv1;
8
9uniform sampler2D RT;
10uniform sampler2D SplotchesTx;
11uniform sampler2D Texture2;
12uniform sampler2D SepiaTx;
13uniform float time_cycle_period;
14uniform float flicker;
15uniform float DirtFrequency;
16uniform vec3 luminance;
17uniform float frameJitter;
18uniform float lumiShift;
19
20vec2 calcSpriteAddr(vec2 texCoord, float DirtFrequency1, float period)
21{
22   return texCoord + texture2D(Texture2, vec2(period * DirtFrequency1, 0.0)).xy;
23}
24
25vec4 getSplotches(vec2 spriteAddr)
26{
27   // get sprite address into paged texture coords space
28   spriteAddr = spriteAddr / 6.3;
29   spriteAddr = spriteAddr - (spriteAddr / 33.3);
30
31   return texture2D(SplotchesTx, spriteAddr);
32}
33
34void main()
35{
36   // get sprite address
37   vec2 spriteAddr = calcSpriteAddr(oUv0, DirtFrequency, time_cycle_period);
38
39   // add some dark and light splotches to the film
40   vec4 splotches = getSplotches(spriteAddr);
41   vec4 specs = 1.0 - getSplotches(spriteAddr / 3.0);
42
43   // convert color to base luminance
44   vec4 base = texture2D(RT, oUv0 + vec2(0.0, spriteAddr.y * frameJitter));
45   float lumi = dot(base.rgb, luminance);
46   // randomly shift luminance
47   lumi -= spriteAddr.x * lumiShift;
48   // tone map luminance
49   base.rgb = texture2D(SepiaTx, vec2(lumi, 0.0)).rgb;
50
51   // calc flicker speed
52   float darken = fract(flicker * time_cycle_period);
53
54   // we want darken to cycle between 0.6 and 1.0
55   darken = abs(darken - 0.5) * 0.4 + 0.6;
56   // composite dirt onto film
57   gl_FragColor = base * splotches * darken + specs;
58}
Note: See TracBrowser for help on using the repository browser.