目录索引
译文
“min”是指两个向量或标量之间的最小值,而“max”则相反。我们将在不同的操作中经常使用这些函数,例如,我们可以在计算漫反射时用到max函数:用来返回“0”和法线与光方向之间的点积之间的最大值。
其语法如下:
// if "a" is less than "b", it returns "a", otherwise returns "b"
float min (float a, float b)
{
float n = (a < b? a : b);
return n;
}
float2 min (float2 a, float2 b);
float3 min (float3 a, float3 b);
float4 min (float4 a, float4 b);
// if "a" is greater than "b", it returns "a", otherwise returns "b"
float max (float a, float b)
{
float n = (a > b? a : b);
return n;
}
float2 max (float2 a, float2 b);
float3 max (float3 a, float3 b);
float4 max (float4 a, float4 b);
我们将在稍后的第二章第7.0.3节中详细讨论这个函数,讨论漫反射。
原文对照
On the one hand, “min” refers to the minimum value between two vectors or scalars, while the “max” is the opposite. We will use these functions frequently in different operations, e.g., we can use max to calculate the diffusion on an object, returning the maximum between “zero” and the dot product between the normals of the mesh and the direction of the light.
Its syntax is as follows:
// if "a" is less than "b", it returns "a", otherwise returns "b"
float min (float a, float b)
{
float n = (a < b? a : b);
return n;
}
float2 min (float2 a, float2 b);
float3 min (float3 a, float3 b);
float4 min (float4 a, float4 b);
// if "a" is greater than "b", it returns "a", otherwise returns "b"
float max (float a, float b)
{
float n = (a > b? a : b);
return n;
}
float2 max (float2 a, float2 b);
float3 max (float3 a, float3 b);
float4 max (float4 a, float4 b);
We will review this function in detail later in Chapter II, Section 7.0.3, discussing diffuse reflection.
© 版权声明
文章版权归作者所有,未经允许请勿转载。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
THE END

![[udemy]在 Unity 中创建 RPG 游戏的终极指南-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/TheUltimateGuidetoCreatinganRPGGameinUnity.webp)
![[udemy]学习在 Unity 和 C# 中创建吸血鬼幸存者风格的游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/LearnToCreateAVampireSurvivorsStyleGameinUnityC.webp)
![[udemy] 在 Godot 4 中创建完整的 2D 幸存者风格游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/CreateaComplete2DSurvivorsStyleGameinGodot4.webp)
![[gamedev tv] RPG核心战斗力的创造者 :学习中级 Unity C# 编码-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/04/RPGCoreCombatCreatorLearnIntermediateUnityCCoding.png)
![[gamedev tv]Unity 2.5D 回合制角色扮演游戏-软件开发学习笔记](https://gamedevfan.cn/wp-content/uploads/2025/05/Unity2.5DTurn-BasedRPG.webp)




暂无评论内容