Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/programs/vs_glow.cg @ 10452

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

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

File size: 1.4 KB
Line 
1struct vertexIn
2{
3    float4 position : POSITION;
4    float4 normal : NORMAL;
5    float2 uv : TEXCOORD0;
6};
7
8struct vertexOut
9{
10    float4 position : POSITION; //<! transformed position
11    float2 uv : TEXCOORD0; //<! passing on uv information
12    float3 worldNormal : TEXCOORD1; //<! surface normal transformed into world
13    float3 worldView : TEXCOORD2; //<! view direction transformed into world
14};
15
16vertexOut main(vertexIn input, uniform float4x4 iWorldTMatrix, uniform float4x4 iViewMatrix, uniform float4x4 worldMatrix, uniform float4x4 viewProjMatrix, uniform float inflate )
17{
18   vertexOut output;
19   float4 myPosition = input.position;
20   output.worldNormal=mul(iWorldTMatrix, input.normal).xyz; //transforming the normal
21   input.normal = normalize(float4(input.normal.xyz,0)); //normalizing the normal according to the three relevant parts
22   myPosition.xyz += inflate * input.normal; //inflating the model into a bigger shape
23   myPosition = mul(worldMatrix, myPosition); //transforming position into world
24   output.worldView = normalize(float3(iViewMatrix[0].w, iViewMatrix[1].w, iViewMatrix[2].w) - myPosition.xyz);//view direction according to world
25   output.position = mul(viewProjMatrix, myPosition); //finish transformation of the position into the projection space
26   output.uv = input.uv; //passing on uv information
27   return output;
28}
Note: See TracBrowser for help on using the repository browser.