Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/OldMovieFP.glsl @ 12181

Last change on this file since 12181 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

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