Unity3d 内置世界变量

本文深入解析了UnityCG中内置统一变量的作用及其定义,包括时间值、投影参数、屏幕参数、尺度、世界空间相机位置、模型矩阵、光照参数等。详细解释了这些变量如何在场景渲染过程中发挥关键作用,以及它们与UnityCG.inc文件的关联。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

// The following built-in uniforms (except _LightColor0) 
// are also defined in "UnityCG.cginc", 
// i.e. one could #include "UnityCG.cginc" 
uniform float4 _Time, _SinTime, _CosTime; // time values
uniform float4 _ProjectionParams;
// x = 1 or -1 (-1 if projection is flipped)
// y = near plane; z = far plane; w = 1/far plane
uniform float4 _ScreenParams; 
// x = width; y = height; z = 1 + 1/width; w = 1 + 1/height
uniform float4 unity_Scale; // w = 1/scale; see _World2Object
uniform float3 _WorldSpaceCameraPos;
uniform float4x4 _Object2World; // model matrix
uniform float4x4 _World2Object; // inverse model matrix 
// (all but the bottom-right element have to be scaled 
// with unity_Scale.w if scaling is important) 
uniform float4 _LightPositionRange; // xyz = pos, w = 1/range
uniform float4 _WorldSpaceLightPos0; 
// position or direction of light source
uniform float4 _LightColor0; // color of light source 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值