is a three‐dimensional graphics directive that specifies that faces of polygons and other filled graphics objects are to be drawn to reflect as a smooth surface using a normal‐vector interpolation shading.
PhongShading[d]
uses the attenuation factor d for the diffuse light.
PhongShading[{d,s}]
uses the attenuation factor s for the specular light.
PhongShading[{d,s,a}]
uses the attenuation factor a for the ambient light.
PhongShading
is a three‐dimensional graphics directive that specifies that faces of polygons and other filled graphics objects are to be drawn to reflect as a smooth surface using a normal‐vector interpolation shading.
PhongShading[d]
uses the attenuation factor d for the diffuse light.
PhongShading[{d,s}]
uses the attenuation factor s for the specular light.
PhongShading[{d,s,a}]
uses the attenuation factor a for the ambient light.
Details
- PhongShading is also known as per‐pixel shading and Phong interpolation.
- PhongShading is typically used to achieve smooth lighting on polygon surfaces.
- The final colors are computed from the interpolation of the surface normals across polygons and the luminosity of the color resulting from standard shading.
- PhongShading[{d,s,a}] specifies that the diffuse light on a 3D surface should be attenuated by a factor d, the specular light by s and the ambient light by a.
- PhongShading[] is effectively equivalent to PhongShading[{1,1,1}].
- The setting Lighting"Accent" uses a directional light and faithfully reproduces colors on the surface.
- The basic shading models FlatShading, GouraudShading and PhongShading compared:
Examples
open all close allBasic Examples (3)
Apply PhongShading to the unit sphere:
Graphics3D[{PhongShading[], GeodesicPolyhedron[5]}]Style a plot with PhongShading:
Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> PhongShading[], Mesh -> None]Draw a 3D model with PhongShading:
Graphics3D[{PhongShading[], ResourceData["Galleon"]}]Scope (14)
Basic Uses (5)
Apply Phong shading to a graphics primitive:
Graphics3D[{PhongShading[], #}]& /@ {Sphere[], CapsuleShape[], Cone[]}Apply Phong shading to a plot:
SphericalPlot3D[1 + 2 Cos[2 θ], {θ, 0, Pi}, {ϕ, 0, 2 Pi}, Axes -> False, PlotStyle -> PhongShading[], Mesh -> None]Apply Phong shading to a chart:
BarChart3D[Range[5], ChartElements -> [image], ChartStyle -> PhongShading[]]Apply Phong shading to a 3D object:
Graphics3D[{PhongShading[], ExampleData[{"Geometry3D", "Beethoven"}, "GraphicsComplex"]}]PhongShading[]Specification (5)
PhongShading with no arguments uses similar calculations as the default system shader:
Graphics3D[{PhongShading[], Sphere[]}]Attenuate all light from the surface by a scaler value:
Graphics3D[{PhongShading[#], Sphere[]}]& /@ {0, 0.5, 1.0}This is equivalent to specifying each attenuation factor explicitly:
Graphics3D[{PhongShading[{#, #, #}], Sphere[]}]& /@ {0, 0.5, 1.0}Attenuate the diffuse light, setting other attenuation factors to zero:
Graphics3D[{PhongShading[{#}], Sphere[]}]& /@ {0, 0.5, 1.0}Attenuate the specular light, setting other attenuation factors to zero:
Graphics3D[{PhongShading[{0, #}], Specularity[White, 5], Sphere[]}]& /@ {0, 0.5, 1.0}Attenuate the ambient light, setting other attenuation factors to zero:
Graphics3D[{PhongShading[{0, 0, #}], Sphere[]}]& /@ {0, 0.5, 1.0}Lighting (4)
PhongShading works with all types of lights:
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[{PhongShading[], Sphere[]}, Lighting -> {#}]& /@ lightsGraphics3D[{PhongShading[], 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]]}]The specular percentage only applies if the Specularity directive has been specified:
Graphics3D[{PhongShading[{1, #, 1}], Specularity[White], Sphere[]}]& /@ {0.0, 1.0}The ambient percentage only applies if an AmbientLight is has been specified:
Graphics3D[{PhongShading[{1, 1, #}], Sphere[]}, Lighting -> AmbientLight[LightGray]]& /@ {0.0, 1.0}Applications (2)
Basic Applications (2)
Show interior normals interpolated from vertex normals:
barycentric[Polygon[{v1_, v2_, v3_}, ___], xyz_] := LinearSolve[Append[Transpose[{v1, v2, v3}], {1, 1, 1}], Append[xyz, 1]]
arrow[p : Polygon[v_, VertexNormals -> n_], bcoords_] := With[{o = Total[v * bcoords]}, Arrow[{o, o + Normalize[Total[n * bcoords]] / 2}]]
bsample[r_] := barycentric[r, #]& /@ MeshCoordinates[DiscretizeRegion[r, MaxCellMeasure -> {2 -> 0.03}]]
normals[p_] := Graphics3D[{PhongShading[], p, arrow[p, #]& /@ bsample[p]}, Boxed -> False, Method -> {"ShrinkWrap" -> True}]Triangle with identical vertex normals:
normals[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}}]]Triangle with a different normal at each vertex:
normals[Polygon[{{Sqrt[3]/2, -1/2, 0}, {0, 1, 0}, {-1/2*Sqrt[3], -1/2, 0}},
VertexNormals -> {{Sqrt[3]/2, -1/2, 1}, {0, 1, 1}, {-1/2*Sqrt[3], -1/2, 1}}]]PhongShading can be separated into individual components for diffuse, specular and ambient lighting:
Graphics3D[{PhongShading[#], Specularity[White, 5], ResourceData["Utah Teapot"]}, Boxed -> False]& /@ {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}These components are summed to achieve the final result:
ImageAdd[Rasterize /@ %]PhongShading performs the individual calculations and summation by default:
Graphics3D[{PhongShading[], Specularity[White, 5], ResourceData["Utah Teapot"]}, Boxed -> False]Properties & Relations (4)
PhongShading uses VertexNormals if specified:
model = GraphicsComplex[{...}, Polygon[...], VertexNormals -> {...}];
Graphics3D[{PhongShading[], model}]Specify FaceForm with PhongShading:
Graphics3D[{FaceForm[#], PhongShading[], Sphere[]}]& /@ {Red, Green, Blue}GouraudShading approximates the PhongShading when the screen size and shade variance across polygons are small:
Graphics3D[{#, EdgeForm[], Specularity[White, 10], ResourceData["Stanford Bunny"]}, Boxed -> False]& /@ {PhongShading[], GouraudShading[]}PhongShading typically has a smaller specular highlight than the default system shader:
Graphics3D[{#, Specularity[White, 10], Sphere[]}, Boxed -> False, Lighting -> "Accent"]& /@ {PhongShading[], Null}History
Text
Wolfram Research (2022), PhongShading, Wolfram Language function, https://reference.wolfram.com/language/ref/PhongShading.html.
CMS
Wolfram Language. 2022. "PhongShading." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/PhongShading.html.
APA
Wolfram Language. (2022). PhongShading. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PhongShading.html
BibTeX
@misc{reference.wolfram_2026_phongshading, author="Wolfram Research", title="{PhongShading}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/PhongShading.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_phongshading, organization={Wolfram Research}, title={PhongShading}, year={2022}, url={https://reference.wolfram.com/language/ref/PhongShading.html}, note=[Accessed: 13-June-2026]}