Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2012, 6:02:05 PM (12 years ago)
Author:
davidsa
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • data/trunk/programs/vs_glow.cg

    r9408 r9425  
    1 void main(float4 position : POSITION, float3 normal : NORMAL, float2 uv : TEXCOORD0, out float4 oPosition : POSITION, out float2 oUv : TEXCOORD0, out float4 colour : COLOR,
    2           uniform float4x4 worldViewProjMatrix, uniform float size_value, uniform float time )
     1struct vertexIn
    32{
    4    float4 myPosition = position;
    5    myPosition.xyz += size_value * (1.0 + (sin(time * 5.0) + 1.0)  / 5.0 ) * normal;
    6    oPosition = mul(worldViewProjMatrix, myPosition);
     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;
    728}
    8 
Note: See TracChangeset for help on using the changeset viewer.