Grass.cg
资源名称:3dwind2.0.rar [点击查看]
上传用户:xhbjoy
上传日期:2014-10-07
资源大小:38068k
文件大小:1k
源码类别:
游戏引擎
开发平台:
Visual C++
- // Vertex program to wave some grass about
- // Simplistic, assumes base of the grass at 0
- void grass_vp(float4 position : POSITION,
- float3 normal : NORMAL,
- float2 uv : TEXCOORD0,
- out float4 oPosition : POSITION,
- out float2 oUv : TEXCOORD0,
- out float4 colour : COLOR,
- uniform float4x4 worldViewProj,
- uniform float4 ambient,
- uniform float4 objSpaceLight,
- uniform float4 lightColour,
- uniform float4 offset)
- {
- float4 mypos = position;
- //offset = float4(0.5, 0, 0, 0);
- mypos = mypos + offset * mypos.yyyy;
- oPosition = mul(worldViewProj, mypos);
- oUv = uv;
- // get vertex light direction (support directional and point)
- float3 light = normalize(
- objSpaceLight.xyz - (position.xyz * objSpaceLight.w));
- float diffuseFactor = max(dot(normal, light), 0);
- colour = ambient + diffuseFactor * lightColour;
- }