////////////////////////////////////////////////////////////////////////////
//
// File: diffuse.txt
//
// Author: Frank Luna (C) All Rights Reserved
//
// System: AMD Athlon 1800+ XP, 512 DDR, Geforce 3, Windows XP, MSVC++ 7.0
//
// 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.
//
extern matrix ViewMatrix;
extern matrix ViewProjMatrix;
extern vector AmbientMtrl;
extern vector DiffuseMtrl;
extern 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.
//
extern vector DiffuseLightIntensity = {0.0f, 0.0f, 1.0f, 1.0f};
extern 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
// componentes 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 recieves 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 gives
// us our final vertex color.
//
output.diffuse = (AmbientMtrl * AmbientLightIntensity) +
(s * (DiffuseLightIntensity * DiffuseMtrl));
return output;
}
没有合适的资源?快使用搜索试试~ 我知道了~
(非shader版本)完整版本 Introduction to 3D Game Programming with DirectX...
共505个文件
cpp:99个
tlog:68个
h:62个
需积分: 9 8 下载量 88 浏览量
2013-12-29
14:14:40
上传
评论
收藏 27.6MB 7Z 举报
温馨提示
这是《Introduction to 3D Game Programming with DirectX 9.0c》的电子书和所有实例代码,已经整理好,方便大家下载,即所谓的龙书,不是shader版本的,shader版本的在我另外上传的资源中
资源推荐
资源详情
资源评论
收起资源包目录
(非shader版本)完整版本 Introduction to 3D Game Programming with DirectX 9.0c (505个子文件)
desert.bmp 768KB
desert.bmp 768KB
desert.bmp 768KB
desert.bmp 768KB
ice.bmp 768KB
ice.bmp 768KB
ice.bmp 768KB
grass.bmp 768KB
desert.bmp 768KB
text.bmp 192KB
crate.bmp 192KB
alphachannel.bmp 65KB
dx5_logo.bmp 65KB
dx5_logo.bmp 65KB
spotlight.bmp 65KB
toonshade.bmp 48KB
toonshade.bmp 48KB
toonshade.bmp 48KB
block.bmp 17KB
snowball.bmp 17KB
block.bmp 17KB
flare.bmp 17KB
flare.bmp 17KB
dxutil.cpp 37KB
dxutil.cpp 35KB
d3dfont.cpp 26KB
d3dutil.cpp 25KB
d3dfont.cpp 23KB
d3dutil.cpp 20KB
stencilmirrorshadow.cpp 13KB
terrain.cpp 13KB
terrain.cpp 13KB
d3dxcreatemeshfvf.cpp 12KB
pSystem.cpp 11KB
pSystem.cpp 11KB
pSystem.cpp 11KB
stencilmirror.cpp 11KB
silhouetteEdges.cpp 10KB
stencilshadow.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
d3dUtility.cpp 10KB
toon.cpp 9KB
d3dUtility.cpp 9KB
d3dUtility.cpp 9KB
ps_multitex.cpp 8KB
boundingvolumes.cpp 8KB
pmesh.cpp 7KB
toon.cpp 6KB
tooneffect.cpp 6KB
pickSample.cpp 6KB
light_tex_effect.cpp 6KB
mtrlAlpha.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
d3dUtility.cpp 6KB
vs_diffuse.cpp 5KB
d3dxcreate.cpp 5KB
cube.cpp 5KB
texAlpha.cpp 5KB
litPyramid.cpp 5KB
xfile.cpp 5KB
addressModes.cpp 5KB
fog.cpp 5KB
transform.cpp 5KB
spotLight.cpp 5KB
pointLight.cpp 4KB
directionalLight.cpp 4KB
d3dxcreatetext.cpp 4KB
d3dUtility.cpp 4KB
d3dUtility.cpp 4KB
d3dUtility.cpp 4KB
d3dUtility.cpp 4KB
d3dUtility.cpp 4KB
d3dUtility.cpp 4KB
共 505 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
raoxuanxuan
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功