是一个三维图形指令,它指定使用法线向量平均着色绘制多边形和其他填充图形对象的面,以作为平滑表面反射.
对漫射光使用衰减因子 d.
GouraudShading[{d,s}]
对镜面光使用衰减因子 s.
GouraudShading[{d,s,a}]
对环境光使用衰减因子 a.
GouraudShading
是一个三维图形指令,它指定使用法线向量平均着色绘制多边形和其他填充图形对象的面,以作为平滑表面反射.
对漫射光使用衰减因子 d.
GouraudShading[{d,s}]
对镜面光使用衰减因子 s.
GouraudShading[{d,s,a}]
对环境光使用衰减因子 a.
更多信息
- GouraudShading 也称为逐顶点着色.
- GouraudShading 通常用于在低多边形表面上实现平滑照明.
- 最终颜色是根据多边形顶点的表面法线平均值和标准着色产生的颜色亮度计算得出的.
- GouraudShading[{d,s,a}] 指定三维表面上的漫射光的衰减因子为 d,镜面光衰减因子为 s,环境光衰减因子为 a.
- GouraudShading[] 实际等价于 GouraudShading[1,1,1].
- 设置 Lighting"Accent" 使用定向光并忠实地再现表面上的颜色.
- 基本着色模型 FlatShading、GouraudShading 与 PhongShading 比较:
范例
打开所有单元 关闭所有单元基本范例 (3)
将 GouraudShading 应用于短程线型多面体:
Graphics3D[{GouraudShading[], GeodesicPolyhedron[4]}]用 GouraudShading 设置绘图样式:
Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> GouraudShading[], Mesh -> None]用 GouraudShading 绘制三维模型:
Graphics3D[{GouraudShading[], ResourceData["Galleon"]}]范围 (14)
基本用法 (5)
Graphics3D[{GouraudShading[], #}]& /@ {Sphere[], CapsuleShape[], Cone[]}SphericalPlot3D[1 + 2 Cos[2 θ], {θ, 0, Pi}, {ϕ, 0, 2 Pi}, Axes -> False, PlotStyle -> GouraudShading[], Mesh -> None]BarChart3D[Range[5], ChartElements -> [image], ChartStyle -> GouraudShading[]]Graphics3D[{GouraudShading[], ResourceData["Beethoven"]}]GouraudShading[]规范 (5)
不带参数的 GouraudShading 使用与默认系统着色器类似的计算:
Graphics3D[{GouraudShading[], Sphere[]}]Graphics3D[{GouraudShading[#], Sphere[]}]& /@ {0, 0.5, 1.0}Graphics3D[{GouraudShading[{#, #, #}], Sphere[]}]& /@ {0, 0.5, 1.0}Graphics3D[{GouraudShading[{#}], Sphere[]}]& /@ {0, 0.5, 1.0}Graphics3D[{GouraudShading[{0, #}], Specularity[White, 5], Sphere[]}]& /@ {0, 0.5, 1.0}Graphics3D[{GouraudShading[{0, 0, #}], Sphere[]}]& /@ {0, 0.5, 1.0}照明 (4)
GouraudShading 适用于所有类型的光:
lights = {AmbientLight[LightGray], PointLight[White, ImageScaled[{1, 1, 2}]], DirectionalLight[White, ImageScaled[{1, 1, 2}]], SpotLight[White, {{1, -1, 1}, {0, 0, 0}}, Pi / 4]};
Graphics3D[{GouraudShading[], Sphere[]}, Lighting -> {#}]& /@ lightsGraphics3D[{GouraudShading[], Sphere[]}, Lighting -> {DirectionalLight[RGBColor[1, 0, 0], ImageScaled[{1, -0.5, 1}]], DirectionalLight[RGBColor[0, 1, 0], ImageScaled[{-1, -0.5, 1}]], DirectionalLight[RGBColor[0, 0, 1], ImageScaled[{0, 1, 1}]], AmbientLight[GrayLevel[0.2]]}]仅当指定了 Specularity 指令时,镜面反射百分比才适用:
Graphics3D[{GouraudShading[{1, #, 1}], Specularity[White], Sphere[]}]& /@ {0.0, 1.0}仅当指定了 AmbientLight 时,环境百分比才适用:
Graphics3D[{GouraudShading[{1, 1, #}], Sphere[]}, Lighting -> AmbientLight[LightGray]]& /@ {0.0, 1.0}应用 (2)
基本应用 (2)
v = {{0, 0, 0}, {1, 0, 0}, {1 / 2, 1, 0}};
cols = {Red, Green, Blue};
lights = Table[PointLight[cols[[i]], v[[i]] + {0, 0, 0.01}], {i, Length[v]}];
Graphics3D[{GouraudShading[], Triangle[v]}, Lighting -> lights, ViewPoint -> Above]这相当于将预先计算的顶点照明作为带有环境 White 光的 VertexColors 传递:
Graphics3D[{EdgeForm[], Triangle[v, VertexColors -> cols]}, Lighting -> AmbientLight[White], ViewPoint -> Above]arrows[_[v_, ___, VertexNormals -> n_]] := Table[Arrow[{v[[i]], v[[i]] + n[[i]]}], {i, Length[v]}]
vnormals[p_] := Graphics3D[{GouraudShading[], p, arrows[p]}, Boxed -> False, Method -> {"ShrinkWrap" -> True}]vnormals[Polygon[{{Sqrt[3]/2, -1/2, 0}, {0, 1, 0}, {-1/2*Sqrt[3], -1/2, 0}},
VertexNormals -> {{0, 0, 1}, {0, 0, 1}, {0, 0, 1}}]]vnormals[Polygon[{{Sqrt[3]/2, -1/2, 0}, {0, 1, 0}, {-1/2*Sqrt[3], -1/2, 0}},
VertexNormals -> {{Sqrt[3/5]/2, -1/2*1/Sqrt[5], 2/Sqrt[5]}, {0, 1/Sqrt[5], 2/Sqrt[5]},
{-1/2*Sqrt[3/5], -1/2*1/Sqrt[5], 2/Sqrt[5]}}]]vnormals[Polyhedron[{{-0.5, 0.5, -0.5}, {0.5, 0.5, -0.5}, {0.5, -0.5, -0.5}, {-0.5, -0.5, -0.5},
{-0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.5, -0.5, 0.5}, {-0.5, -0.5, 0.5}},
{{1, 2, 3, 4}, {5, 6, 2, 1}, {6, 7, 3, 2}, {7, 8, 4, 3}, {8, 5, 1, 4}, {8, 7, 6, 5 ... 258, 0.5773502691896258, 0.5773502691896258},
{0.5773502691896258, 0.5773502691896258, 0.5773502691896258},
{0.5773502691896258, -0.5773502691896258, 0.5773502691896258},
{-0.5773502691896258, -0.5773502691896258, 0.5773502691896258}}]]vnormals[GraphicsComplex[...]]属性和关系 (3)
如果指定,GouraudShading 使用 VertexNormals:
model = GraphicsComplex[{...}, Polygon[...], VertexNormals -> {...}];
Graphics3D[{GouraudShading[], model}]通过 GouraudShading 指定 FaceForm:
Graphics3D[{FaceForm[#], GouraudShading[], Icosahedron[]}]& /@ {Red, Green, Blue}当屏幕尺寸和多边形之间的阴影变化很小时,GouraudShading 近似于 PhongShading:
Graphics3D[{#, EdgeForm[], Specularity[White, 10], ResourceData["Stanford Bunny"]}, Boxed -> False]& /@ {PhongShading[], GouraudShading[]}可能存在的问题 (1)
Plot3D[Cos[x + y] + Sin[y], {x, -3, 3}, {y, -2, 2}, PlotStyle -> GouraudShading[], Mesh -> None, PlotPoints -> 3]Plot3D[Cos[x + y] + Sin[y], {x, -3, 3}, {y, -2, 2}, PlotStyle -> GouraudShading[], Mesh -> None, PlotPoints -> 40]互动范例 (1)
应用 GouraudShading 并渲染三角形时交互式拖动照明位置. 请注意,三角形的颜色是通过在其角处插入照明值来计算的:
DynamicModule[{pt = {0.5, 0.7}, corners = {{0, 0, 0}, {1, 0, 0}, {1 / 2, Sqrt[3] / 2, 0}}}, LocatorPane[Dynamic[pt], Graphics3D[{Dynamic[PointLight[Gray, Append[pt, 1 / 2], {0, 1, 0}]], GouraudShading[], Triangle[corners], PointSize[0.05], Point[corners, VertexNormals -> ConstantArray[{0, 0, 1}, 3]]}, ViewPoint -> Above, PlotRange -> {{0, 1}, {0, 1}, {-0.2, 0.2}}, Lighting -> None]]]文本
Wolfram Research (2022),GouraudShading,Wolfram 语言函数,https://reference.wolfram.com/language/ref/GouraudShading.html.
CMS
Wolfram 语言. 2022. "GouraudShading." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/GouraudShading.html.
APA
Wolfram 语言. (2022). GouraudShading. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/GouraudShading.html 年
BibTeX
@misc{reference.wolfram_2026_gouraudshading, author="Wolfram Research", title="{GouraudShading}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/GouraudShading.html}", note=[Accessed: 05-December-2026]}
BibLaTeX
@online{reference.wolfram_2026_gouraudshading, organization={Wolfram Research}, title={GouraudShading}, year={2022}, url={https://reference.wolfram.com/language/ref/GouraudShading.html}, note=[Accessed: 05-December-2026]}