用可编程渲染管线实现phone光照模型
2008-05-04 23:09
363 查看
Ambient Lighting = Ca*[Ga + sum(Atti*Spoti*Lai)]
Where:
Parameter | Default value | Type | Description |
---|---|---|---|
Ca | (0,0,0,0) | D3DCOLORVALUE | Material ambient color |
Ga | (0,0,0,0) | D3DCOLORVALUE | Global ambient color |
Atteni | (0,0,0,0) | D3DCOLORVALUE | Light attenuation of the ith light. See Attenuation and Spotlight Factor (Direct3D 9). |
Spoti | (0,0,0,0) | D3DVECTOR | Spotlight factor of the ith light. See Attenuation and Spotlight Factor (Direct3D 9). |
sum | N/A | N/A | Sum of the ambient light |
Lai | (0,0,0,0) | D3DVECTOR | Light ambient color of the ith light |
Diffuse Lighting = sum[Cd*Ld*(N.Ldir)*Atten*Spot]
Parameter | Default value | Type | Description |
---|---|---|---|
sum | N/A | N/A | Summation of each light's diffuse component. |
Cd | (0,0,0,0) | D3DCOLORVALUE | Diffuse color. |
Ld | (0,0,0,0) | D3DCOLORVALUE | Light diffuse color. |
N | N/A | D3DVECTOR | Vertex normal |
Ldir | N/A | D3DVECTOR | Direction vector from object vertex to the light. |
Atten | N/A | FLOAT | Light attenuation. See Attenuation and Spotlight Factor (Direct3D 9). |
Spot | N/A | FLOAT | Spotlight factor. See Attenuation and Spotlight Factor (Direct3D 9). |
Specular Lighting = Cs * sum[Ls * (N • H)P * Atten * Spot] |
Parameter | Default value | Type | Description |
---|---|---|---|
Cs | (0,0,0,0) | D3DCOLORVALUE | Specular color. |
sum | N/A | N/A | Summation of each light's specular component. |
N | N/A | D3DVECTOR | Vertex normal. |
H | N/A | D3DVECTOR | Half way vector. See the section on the halfway vector. |
P | 0.0 | FLOAT | Specular reflection power. Range is 0 to +infinity |
Ls | (0,0,0,0) | D3DCOLORVALUE | Light specular color. |
Atten | N/A | FLOAT | Light attenuation value. See Attenuation and Spotlight Factor (Direct3D 9). |
Spot | N/A | FLOAT | Spotlight factor. See Attenuation and Spotlight Factor (Direct3D 9). |
float4x4 matViewProjection; float4 Light_Position; float4 Light_Attenuation; float4 Light_Color; float4 Ambient_Color; float4 vViewPosition; float alpha; struct VS_INPUT { float4 Position : POSITION0; float3 Normal : NORMAL0; float2 Texcoord : TEXCOORD0; }; struct VS_OUTPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float4 Color : COLOR0; }; float4 PointLighting(float3 position, float3 normal , float3 eyedir, float4 ambient , float3 lightpos, float3 lightatt, float4 lightcolor) { float3 lightdir = normalize(position - lightpos); float3 dis = distance(position, lightpos); float disatt = saturate(1 / ( lightatt.x + lightatt.y * dis + lightatt.z * dis * dis )); float angleatt = saturate(-lightdir * normal); float3 reflectdir = normalize(reflect(lightdir, normal)); float specularatt = pow(saturate(reflectdir * eyedir), alpha); return ambient + lightcolor * disatt * (angleatt + specularatt); } VS_OUTPUT vs_main( VS_INPUT Input ) { VS_OUTPUT Output; Output.Position = mul( Input.Position, matViewProjection ); Output.Texcoord = Input.Texcoord; float3 eyedir = normalize(vViewPosition - Input.Position); Output.Color = PointLighting(Input.Position, Input.Normal , eyedir, Ambient_Color , Light_Position, Light_Attenuation, Light_Color); return( Output ); } |
相关文章推荐
- 基于可编程渲染管线的雷达图像分层模型设计与实现
- 3D图形学编程基础-基于Direct3D11-学习记录(二)光照模型的实现
- opengl光照 Blinn-Phone模型与实现
- [CG编程] 基本光照模型的实现与拓展以及常见光照模型解析
- OpenGL(十一) 可编程管线 基础光照 的实现
- [置顶] 【Aladdin Unity3D Shader编程】之二 光照模型(一)
- 渲染管线——视图坐标与相机模型
- 用于实现 Web 服务的 SOA 编程模型,第 10 部分: SOA 用户角色
- Linux 网络编程——并发服务器的三种实现模型
- Hadoop Map/Reduce编程模型实现海量数据处理—数字求和-Hadoop学习
- GPU渲染管线的组成,以及可编程着色的进化史,顶点、几何、像素三种可编程着色器。
- GPU图形处理管线、图形硬件接口(OpenGL)与可编程图形渲染语言(CG)的关系
- 基于visual c++之windows核心编程代码分析(33)实现防火墙模型
- 7种网络编程I/O模型代码实现实例
- [帖子收集]渲染光照模型
- 可编程图形渲染管线
- 传统渲染管线与可编程Shader着色器
- Atitit..组件化事件化的编程模型--(2)---------Web datagridview 服务器端控件的实现原理and总结
- 【Linux网络编程】并发服务器的三种实现模型
- windows下的网络编程——Select模型实例,一款ECHO服务的实现代码