Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/programs/ps_glow.cg @ 11189

Last change on this file since 11189 was 9425, checked in by davidsa, 12 years ago

Improved glow effect, added some minor documentation to the glow.material file.

File size: 975 bytes
Line 
1struct vertexOut
2{
3    float4 position : POSITION;
4    float2 uv : TEXCOORD0;
5    float3 worldNormal : TEXCOORD1;
6    float3 worldView : TEXCOORD2;
7};
8
9float4 main(vertexOut input, uniform float alphaValue, uniform float cutoffAngle, uniform float exponent, uniform float time, uniform float4 color) : COLOR
10{
11    float3 Nn = normalize(input.worldNormal);
12    float3 Vn = normalize(input.worldView);
13    float alphaMod = dot(Nn, Vn);//this is a measure for how close we are to the edge of a model according to our view
14    float cutoff=cos(cutoffAngle * 3.14 / 180.0);//pi divided by 180
15    if(alphaMod<cutoff)//transform output range so it only affects angles close to 90 degrees
16    {
17        alphaMod/=cutoff;
18    }
19    else
20    {
21        alphaMod=1.0;
22    }
23    alphaMod = pow(alphaMod,exponent); //how fast should the intensity of the glow decrease
24    color.w = alphaMod * alphaValue * ((sin(time)/3.14 + 1.0) / 2.0 + 0.1);
25    return color;
26}
Note: See TracBrowser for help on using the repository browser.