Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/data_extern/programs/Cg/OldMovieFP.cg @ 12397

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

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

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