Ignore:
Timestamp:
10/20/08 01:26:12 (16 years ago)
Author:
mattausch
Message:

added shader for forward shadin tree animation program

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3045 r3046  
    9090 
    9191 
    92 pixel frag(fragin IN,  uniform float4x4 viewMatrix) 
     92pixel frag(fragin IN, uniform float4x4 viewMatrix) 
    9393{ 
    9494        pixel pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/treeanimation.cg

    r3045 r3046  
    2424        //float4 color1: COLOR1;   
    2525        float4 eyePos: TEXCOORD1; // eye position 
    26         float3 normal: TEXCOORD2; 
     26        float4 normal: TEXCOORD2; 
    2727}; 
    2828 
     
    4040{ 
    4141        vtxout OUT; 
    42  
    43 /* 
    44 // Transform vertex position into homogenous clip-space. 
    45 OUT.HPosition = mul(ModelViewProj, IN.Position); 
    46 // Transform normal from model-space to view-space. 
    47 float3 normalVec = normalize(mul(ModelViewIT, 
    48 IN.Normal).xyz); 
    49 // Store normalized light vector. 
    50 float3 lightVec = normalize(LightVec.xyz); 
    51 // Calculate half angle vector. 
    52 float3 eyeVec = float3(0.0, 0.0, 1.0); 
    53 float3 halfVec = normalize(lightVec + eyeVec); 
    54 // Calculate diffuse component. 
    55 float diffuse = dot(normalVec, lightVec); 
    56 // Calculate specular component. 
    57 float specular = dot(normalVec, halfVec); 
    58 // Use the lit function to compute lighting vector from 
    59 // diffuse and specular values. 
    60 float4 lighting = lit(diffuse, specular, 32); 
    61 // Blue diffuse material 
    62 float3 diffuseMaterial = float3(0.0, 0.0, 1.0); 
    63 // White specular material 
    64 float3 specularMaterial = float3(1.0, 1.0, 1.0); 
    65 // Combine diffuse and specular contributions and 
    66 // output final vertex color. 
    67 OUT.Color.rgb = lighting.y * diffuseMaterial + 
    68 lighting.z * specularMaterial; 
    69 OUT.Color.a = 1.0; 
    70 return OUT; 
    71 } 
    72 */ 
    7342        OUT.texCoord = IN.texCoord; 
    7443                 
     
    8150        OUT.position += float4(factor * windDir, 0); 
    8251 
    83         OUT.normal = mul(glstate.matrix.invtrans.modelview[0], IN.normal); 
     52        OUT.normal = normalize(mul(glstate.matrix.invtrans.modelview[0], IN.normal)); 
     53        //const float3 l = normalize(mul(glstate.matrix.modelview[0], float4(lightDir, 0))).xyz; 
     54        const float3 l = normalize(lightDir); 
    8455 
    85         Out.color = IN.color * max(0, dot(OUT.normal, lightDir)); 
    86         //OUT.color1 = IN.color1; 
     56        const float dif = max(.0f, dot(OUT.normal.xyz, l)); 
    8757 
     58        //OUT.color.xyz = IN.color.xyz * max(0, dot(OUT.normal.xyz, normalize(lightDir))); 
     59        OUT.color = glstate.material.ambient + glstate.material.front.diffuse * dif; 
     60        OUT.color.w = IN.color.w; 
    8861        return OUT; 
    8962} 
    9063 
    91 /** vertex shader which conducts an simple tree animation 
    92         that bends the tree depending quadratically on the height 
     64/** vertex shader which provides an simple tree animation 
     65        that bends the tree depending quadratically on the height using vertex displacement. 
    9366        This version of the shader is used for deferred shading and thus only  
    9467        displaces the vertices and outputs the color, put does not do any shading. 
     
    10477 
    10578        OUT.color = IN.color; 
    106         //OUT.color1 = IN.color1; 
    107  
    10879        OUT.texCoord = IN.texCoord; 
    10980                 
Note: See TracChangeset for help on using the changeset viewer.