lighting.nvf
来自「游戏编程精华02-含有几十个游戏编程例子」· NVF 代码 · 共 64 行
NVF
64 行
#include "constants.h"
vs.1.0
// Helpers for the lighting
#beginfragment set_power
mov r_intensity.w, c_mat_power.w
#endfragment
#beginfragment clamp_diffuse_exponentiate_specular
lit r_intensity_result, r_intensity
#endfragment
#beginfragment pointlight_accumulate_diffuse
mad r_diffusecolor.xyz, r_intensity_result.y, c_pointlight_diffuse++, r_diffusecolor
#endfragment
#beginfragment pointlight_accumulate_diffuse_last
mad oD0.xyz, r_intensity_result.y, c_pointlight_diffuse++, r_diffusecolor
#endfragment
#beginfragment pointlight_accumulate_specular_first
mul r_specularcolor.xyz, r_intensity_result.z, c_pointlight_specular++
#endfragment
#beginfragment pointlight_accumulate_specular
mad r_specularcolor.xyz, r_intensity_result.z, c_pointlight_specular++, r_specularcolor
#endfragment
#beginfragment pointlight_accumulate_specular_last
mad oD1.xyz, r_intensity_result.z, c_pointlight_specular++, r_specularcolor
#endfragment
#beginfragment pointlight_accumulate_specular_first_and_last
mul oD1.xyz, r_intensity_result.z, c_pointlight_specular++
#endfragment
// Dirlight
#beginfragment dirlight_accumulate_diffuse
mad r_diffusecolor.xyz, r_intensity_result.y, c_dirlight_diffuse++, r_diffusecolor
#endfragment
#beginfragment dirlight_accumulate_diffuse_last
mad oD0.xyz, r_intensity_result.y, c_dirlight_diffuse++, r_diffusecolor
#endfragment
#beginfragment dirlight_accumulate_specular_first
mul r_specularcolor.xyz, r_intensity_result.z, c_dirlight_specular++
#endfragment
#beginfragment dirlight_accumulate_specular
mad r_specularcolor.xyz, r_intensity_result.z, c_dirlight_specular++, r_specularcolor
#endfragment
#beginfragment dirlight_accumulate_specular_last
mad oD1.xyz, r_intensity_result.z, c_dirlight_specular++, r_specularcolor
#endfragment
#beginfragment dirlight_accumulate_specular_first_and_last
mul oD1.xyz, r_intensity_result.z, c_dirlight_specular++
#endfragment
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?