phong 光照模型。。
来源:互联网 发布:照片卡通化软件 编辑:程序博客网 时间:2024/05/16 18:30
前些日子 乘着有闲功夫,慢慢的hlsl看了起来,发现以前学的数学知识全用上了,只可惜忘得都差不多了,又要恶补数学了。
做了个比较简单的 phong 光照模型。
float4x4 Scal;
float4x4 World;
float4x4 View;
float4x4 projection;
float4x4 WorldViewProjection;
float3 EyePosition;
float3 LightDir;
float4 LightColor;
struct VertexInput
{
float4 Position : POSITION;
float2 Tex : TEXCOORD0;
float3 Normal : NORMAL;
};
struct VertexOutput
{
float4 Position : POSITION;
float2 Tex : TEXCOORD0;
float3 Normal : TEXCOORD1;
float3 View : TEXCOORD2;
};
VertexOutput VertexMain(VertexInput input)
{
VertexOutput output = (VertexOutput)0;
WorldViewProjection = mul(mul(View, World), projection);
output.Position = mul(mul(input.Position, Scal), WorldViewProjection);
output.Tex = input.Tex;
output.Normal = mul(input.Normal, World);
output.View = EyePosition - mul(input.Position, World);
return output;
}
float4 PixelMain(VertexOutput input) : COLOR0
{
float diffsum;
float specularsum;
float4 color;
float sunshinepower;
float4 amibent = float4(0.1f, 0.1f, 0.1f, 1.0f);
sunshinepower = 16.0f;
diffsum = specularsum = 0;
//漫反射
LightDir = normalize(LightDir);
diffsum = saturate(dot(LightDir, input.Normal));
//镜面反射
float3 L = -LightDir;
float3 R = normalize(reflect(L, input.Normal));
float3 V = normalize(input.View);
specularsum = pow(saturate(dot(R, V)), sunshinepower);
color = specularsum + diffsum * LightColor + amibent;
return color;
}
technique techR
{
pass p0
{
VertexShader = compile vs_2_0 VertexMain();
PixelShader = compile ps_2_0 PixelMain();
}
}
转自: http://www.cppblog.com/AstaTus/
- phong 光照模型。。
- 简单phong光照模型
- Phong光照模型、Blinn-phong光照模型归纳
- 常用光照模型汇总:Lambert/Phong/Blinn-Phong光照模型
- <Shader>phong 光照模型和 blinn phong 模式
- Lambertain, Specular, Phong, Dichromatic光照模型
- OpenGL学习脚印:Blinn-Phong光照模型
- Unity Shader-Phong光照模型与Specular
- Unity Shader-Phong光照模型与Specular
- 简单光照模型(Phong模型(镜面反射)与 Blinn-Phong光照模型(修正镜面光) )
- phong光照
- Phong光照
- OpenGL学习: 光照系列1-光照基础(phong模型)
- 课堂笔记_ 颜色模型、Phong光照模型
- GPU实现“Blinn-Phong 光照模型”(Cg语言)
- 新手思路——phong简单光照模型绘制
- 一步一步学RenderMonkey(3)——改良Phong光照模型
- 一步一步学RenderMonkey(3)——改良Phong光照模型
- Android常用的sqlite3 命令
- Android的apk反编译工具Apktool
- Android的Apk文件结构与反编译dex
- 算法百题001:最长平台(The Longest Plateau)问题
- Week 6 - Fri. Graduated
- phong 光照模型。。
- Android的dex文件反编译
- Linux DNS Server 配置 -- for Oracle 11gR2 RAC SCAN IP
- Monkey 是运行在模拟器或设备上的一个工具,用来伪随机
- Android的SDcard使用
- GOD,我终于记住了标签元素的组成部分
- Android发布注意问题
- Android画图并保存图片
- Android 常用工具命令