Ogre高光Shader入门(HLSL)
来源:互联网 发布:淘客自动采集软件 编辑:程序博客网 时间:2024/04/26 13:54
void vs_main(
in float4 Position : POSITION0,
in float2 Texcoord : TEXCOORD0,
in float3 Normal : NORMAL0,
out float4 Pos : POSITION0,
out float2 Tex : TEXCOORD0,
out float4 ViewDirection : TEXCOORD1,
out float4 LightDirection : TEXCOORD2,
out float4 Nor : TEXCOORD3,
uniform float4 fvLightPosition,
uniform float4 fvEyePosition,
uniform float4x4 matView,
uniform float4x4 matViewProjection)
{
Pos = mul( matViewProjection, Position );
Tex = Texcoord;
float4 fvObjectPosition = mul( matView, Position );
ViewDirection = fvEyePosition - fvObjectPosition;
LightDirection = fvLightPosition - fvObjectPosition;
Nor = mul( matView, Normal );
}
void ps_main(
in float2 Texcoord : TEXCOORD0,
in float4 ViewDirection : TEXCOORD1,
in float4 LightDirection: TEXCOORD2,
in float4 Normal : TEXCOORD3,
out float4 color : COLOR0,
uniform float4 komfvAmbient,
uniform float4 komfvDiffuse,
uniform float4 komfvSpecular,
uniform float komfSpecularPower,
uniform sampler2D kombaseMap : register(s0))
{
float4 fvLightDirection = normalize( LightDirection );
float4 fvNormal = normalize( Normal );
float fNDotL = saturate(dot( fvNormal.xyz, fvLightDirection.xyz ));
float4 fvReflection = normalize( ( ( 2.0f * fvNormal ) * ( fNDotL ) ) - fvLightDirection );
float4 fvViewDirection = normalize( ViewDirection );
float fRDotV = max( 0.0f, dot( fvReflection.xyz, fvViewDirection.xyz ) );
float4 fvBaseColor = tex2D( kombaseMap, Texcoord );
float4 fvTotalAmbient = komfvAmbient * fvBaseColor;
float4 fvTotalDiffuse = komfvDiffuse * fNDotL * fvBaseColor;
float4 fvTotalSpecular = komfvSpecular * pow( fRDotV, komfSpecularPower );
color = saturate(fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular);
}
vertex_program Kom/VPhlsl hlsl
{
source kom.hlsl
entry_point vs_main
target vs_2_0
}
fragment_program Kom/FPhlsl hlsl
{
source kom.hlsl
entry_point ps_main
target ps_2_0
}
material Kom/Material
{
technique
{
pass
{
vertex_program_ref Kom/VPhlsl
{
param_named fvLightPosition float4 100.0 100.0 100.0 0
param_named fvEyePosition float4 0.0 0.0 -100.0 0
param_named_auto matView world_matrix
param_named_auto matViewProjection viewproj_matrix
}
fragment_program_ref Kom/FPhlsl
{
param_named komfvAmbient float4 0.3686 0.3686 0.3686 1.0
param_named komfvSpecular float4 0.4887 0.4887 0.4887 1.0
param_named komfvDiffuse float4 0.8850 0.8850 0.8850 1.0
param_named komfSpecularPower float 100.0
}
texture_unit
{
texture BeachStones.jpg
}
}
}
}
转载:http://hi.baidu.com/muyelian/item/e25132c2cfdc83330831c644
- Ogre高光Shader入门(HLSL)
- 顶点高光.Shader
- 片段高光.Shader
- [Shader 着色器]边缘高光
- Unity Shader Example 12 (Bloom 高光)
- shader中创建漫反射和高光
- shader 入门 《着色语言以及HLSL VS GLSL VS CG》
- HLSL模拟散射光
- Unity Shader入门精要笔记(十):Unity 的基础光照——高光反射的实现
- OGRE中使用HLSL
- HLSL Shader Reference(1)
- HLSL Asm Shader Reference
- HLSL风吹草动shader
- 一步步学shader系列(3):高光(specular light)
- Unity 法线贴图、高光贴图、Cube Map shader
- 【shader】边缘自定角度高光,描边,闪烁
- Shader例子(1) 高光效果(surf/顶点)
- unity shader (6)--实现高光反射光照模型
- 使用递归方法为TreeView添加数据
- qtp检查点
- js常用技术汇总
- 生成release版本的Android系统
- mysql 日期格式化函数之date_format()函数
- Ogre高光Shader入门(HLSL)
- warning C4995: “....”: 名称被标记为 #pragma deprecated
- vpn机制
- 请求发送者与接收者解耦——命令模式(一)
- list<>
- Eclipse卸载ADT方法
- android crash / debug 堆栈信息
- 无法与域Active Directory域控制器(AD DC)连接(虚机加域出错问题)
- J2SE之正则表达式验证QQ号