Last change
on this file since 10169 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
|
Rev | Line | |
---|
[9425] | 1 | struct vertexOut |
---|
[9408] | 2 | { |
---|
[9425] | 3 | float4 position : POSITION; |
---|
| 4 | float2 uv : TEXCOORD0; |
---|
| 5 | float3 worldNormal : TEXCOORD1; |
---|
| 6 | float3 worldView : TEXCOORD2; |
---|
| 7 | }; |
---|
| 8 | |
---|
| 9 | float4 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); |
---|
[9408] | 25 | return color; |
---|
[9425] | 26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.