Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/programs/Grass.cg @ 10256

Last change on this file since 10256 was 7708, checked in by dafrick, 14 years ago

Merging cleanup branch. You will need to update your data repository as well as your local copy of the code.

  • Property svn:eol-style set to native
File size: 912 bytes
RevLine 
[5035]1// Vertex program to wave some grass about
2// Simplistic, assumes base of the grass at 0
3void grass_vp(float4 position : POSITION,
4                          float3 normal   : NORMAL,
5                          float2 uv               : TEXCOORD0,
6                          out float4 oPosition : POSITION,
7                          out float2 oUv           : TEXCOORD0,
8                          out float4 colour    : COLOR,
9
10                          uniform float4x4 worldViewProj,
11                          uniform float4 ambient,
12                          uniform float4 objSpaceLight,
13                          uniform float4 lightColour,
14                          uniform float4 offset)
15{
16        float4 mypos = position;
17        //offset = float4(0.5, 0, 0, 0);
18        float4 factor = float4(1,1,1,1) - uv.yyyy;
19        mypos = mypos + offset * factor;
20        oPosition = mul(worldViewProj, mypos);
21
22        oUv = uv;
23        // get vertex light direction (support directional and point)
24        float3 light = normalize(
25                objSpaceLight.xyz -  (position.xyz * objSpaceLight.w));
26        float diffuseFactor = max(dot(normal, light), 0);
27       
28       
29        colour = ambient + diffuseFactor * lightColour;
30}
31
Note: See TracBrowser for help on using the repository browser.