// File: diffuse.txt
// Desc: Vertex shader that does diffuse lighting.
//
// Global variables we use to hold the view matrix, projection matrix,
// ambient material, diffuse material, and the light vector that
// describes the direction to the light source. These variables are
// initialized from the application.
//
matrix ViewMatrix;
matrix ViewProjMatrix;
vector AmbientMtrl;
vector DiffuseMtrl;
vector LightDirection;
//
// Global variables used to hold the ambient light intensity (ambient
// light the light source emits) and the diffuse light
// intensity (diffuse light the light source emits). These
// variables are initialized here in the shader.
//
vector DiffuseLightIntensity = {0.0f, 0.0f, 1.0f, 1.0f};
vector AmbientLightIntensity = {0.0f, 0.0f, 0.2f, 1.0f};
//
// Input and Output structures.
//
struct VS_INPUT
{
vector position : POSITION;
vector normal : NORMAL;
};
struct VS_OUTPUT
{
vector position : POSITION;
vector diffuse : COLOR;
};
//
// Main
//
VS_OUTPUT Main(VS_INPUT input)
{
// zero out all members of the output instance.
VS_OUTPUT output = (VS_OUTPUT)0;
//
// Transform position to homogeneous clip space
// and store in the output.position member.
//
output.position = mul(input.position, ViewProjMatrix);
//
// Transform lights and normals to view space. Set w
// components to zero since we're transforming vectors
// here and not points.
//
LightDirection.w = 0.0f;
input.normal.w = 0.0f;
LightDirection = mul(LightDirection, ViewMatrix);
input.normal = mul(input.normal, ViewMatrix);
//
// Compute cosine of the angle between light and normal.
//
float s = dot(LightDirection, input.normal);
//
// Recall that if the angle between the surface and light
// is greater than 90 degrees the surface receives no light.
// Thus, if the angle is greater than 90 degrees we set
// s to zero so that the surface will not be lit.
//
if( s < 0.0f )
s = 0.0f;
//
// Ambient light reflected is computed by performing a
// component-wise multiplication with the ambient material
// vector and the ambient light intensity vector.
//
// Diffuse light reflected is computed by performing a
// component-wise multiplication with the diffuse material
// vector and the diffuse light intensity vector. Further
// we scale each component by the shading scalar s, which
// shades the color based on how much light the vertex received
// from the light source.
//
// The sum of both the ambient and diffuse components give
// us our final vertex color.
//
output.diffuse = (AmbientMtrl * AmbientLightIntensity) +
(s * (DiffuseLightIntensity * DiffuseMtrl));
return output;
}
没有合适的资源?快使用搜索试试~ 我知道了~
DirectX3D游戏场景
共66个文件
h:17个
cpp:16个
dds:9个
5星 · 超过95%的资源 需积分: 10 126 下载量 81 浏览量
2011-09-05
15:37:27
上传
评论 8
收藏 7.73MB RAR 举报
温馨提示
最近自己写的一个基于DirectX3D的游戏场景。 里面包括了灵活的摄像机、地形、人物骨骼动画、下雪粒子、雾化、公告板、MP3音乐播放、天空盒、键盘输入输出类的封装、纹理动画类的封装等,供给初学DirectX游戏编程人员参考与学习。
资源推荐
资源详情
资源评论
收起资源包目录
GameEngine.rar (66个子文件)
GameEngine
GameEngine
head.tga 975KB
SerialTexController.h 2KB
D3DCamera.cpp 3KB
D3DBillboard.cpp 1KB
resource.h 404B
D3DTerrain.h 2KB
bin
Plant
r_grassboard2.jpg 11KB
BillBoard
tree01S.dds 52KB
Particle
Particle.png 13KB
Terrain
terrain_texture.dds 683KB
terrain_detail.dds 43KB
terrain_heightmap.png 316KB
Music
0.mp3 908KB
0.avi 2.84MB
Sky
cloudy_noon_LF.dds 171KB
cloudy_noon_FR.dds 171KB
cloudy_noon_DN.dds 171KB
cloudy_noon_BK.dds 171KB
cloudy_noon_RT.dds 171KB
cloudy_noon_UP.dds 171KB
Box
glass.bmp 48KB
Star
3.png 2KB
0.png 21KB
1.png 18KB
2.png 17KB
Role
head.tga 975KB
man.X 2.7MB
daotietu-001.tga 165KB
body.tga 957KB
stdafx.h 1KB
D3DTerrain.cpp 9KB
D3DParticleSystem.cpp 7KB
D3DMesh.h 679B
GameEngine.exe 193KB
D3DGameManager.h 1KB
D3DSkyBox.cpp 5KB
D3DBounding.h 812B
D3DBox.cpp 3KB
D3DRole.h 967B
GameEngine.vcproj 6KB
SkinMesh.cpp 29KB
D3DAudio.h 744B
daotietu-001.tga 165KB
D3DParticleSystem.h 2KB
D3DFog.h 416B
diffuse.txt 3KB
D3DSkyBox.h 934B
SerialTexController.cpp 3KB
D3DInput.cpp 3KB
D3DAudio.cpp 2KB
D3DMain.cpp 4KB
D3DRole.cpp 3KB
GameEngine.aps 17KB
D3DMesh.cpp 3KB
D3DBillboard.h 652B
GameEngine.rc 1KB
D3DInput.h 1KB
body.tga 957KB
GameEngine.vcproj.DFCAV4IYV1AF8J0.Administrator.user 1KB
D3DBox.h 774B
D3DCamera.h 2KB
D3DBounding.cpp 1KB
SkinMesh.h 7KB
D3DGameManager.cpp 3KB
D3DFog.cpp 2KB
GameEngine.sln 896B
共 66 条
- 1
CabinLS
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
前往页