Class: QgsPhongMaterialSettings

Basic shading material used for rendering based on the Phong shading model with three color components: ambient, diffuse and specular.

Warning

This is not considered stable API, and may change in future QGIS releases. It is exposed to the Python bindings as a tech preview only.

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis._3d.QgsPhongMaterialSettings

Base classes

QgsAbstractMaterialSettings

Abstract base class for material settings.

Abstract Methods

averageColor

Returns an approximate color representing the blended material color.

setColorsFromBase

Decomposes a base color into Phong material components, and sets the material's colors accordingly.

Methods

ambient

Returns ambient color component

ambientCoefficient

Returns the coefficient for the ambient color contribution (ie strength factor of the ambient color).

diffuse

Returns diffuse color component

diffuseCoefficient

Returns the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).

opacity

Returns the opacity of the surface

setAmbient

Sets ambient color component

setAmbientCoefficient

Sets the coefficient for the ambient color contribution (ie strength factor of the ambient color).

setDiffuse

Sets diffuse color component

setDiffuseCoefficient

Sets the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).

setOpacity

Sets opacity of the surface

setShininess

Sets shininess of the surface

setSpecular

Sets specular color component

setSpecularCoefficient

Sets the coefficient for the specular color contribution (ie strength factor of the specular color).

shininess

Returns shininess of the surface

specular

Returns specular color component

specularCoefficient

Returns the coefficient for the specular color contribution (ie strength factor of the specular color).

Static Methods

create

Returns a new instance of QgsPhongMaterialSettings.

supportsTechnique

Returns True if the specified technique is supported by the Phong material.

class qgis._3d.QgsPhongMaterialSettings

Bases: QgsAbstractMaterialSettings

ambient(self) QColor

Returns ambient color component

Return type:

QColor

ambientCoefficient(self) float

Returns the coefficient for the ambient color contribution (ie strength factor of the ambient color).

Added in version 3.36.

Return type:

float

abstract averageColor(self) QColor

Returns an approximate color representing the blended material color.

This function calculates a weighted average of the ambient, diffuse, and specular color components to produce a single representative color.

See also

ambient()

See also

diffuse()

See also

specular()

Added in version 4.2.

Return type:

QColor

static create() QgsAbstractMaterialSettings | None

Returns a new instance of QgsPhongMaterialSettings.

Return type:

Optional[QgsAbstractMaterialSettings]

diffuse(self) QColor

Returns diffuse color component

Return type:

QColor

diffuseCoefficient(self) float

Returns the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).

Added in version 3.36.

Return type:

float

opacity(self) float

Returns the opacity of the surface

Added in version 3.26.

Return type:

float

setAmbient(self, ambient: QColor | Qt.GlobalColor | int)

Sets ambient color component

Parameters:

ambient (Union[QColor, Qt.GlobalColor, int])

setAmbientCoefficient(self, coefficient: float)

Sets the coefficient for the ambient color contribution (ie strength factor of the ambient color).

Added in version 3.36.

Parameters:

coefficient (float)

abstract setColorsFromBase(self, baseColor: QColor | Qt.GlobalColor | int, metallic: float)

Decomposes a base color into Phong material components, and sets the material’s colors accordingly.

Sets ambient, diffuse, and specular colors from the input color. This also sets the shininess parameter based on the metallic value.

Parameters:
  • baseColor (Union[QColor, Qt.GlobalColor, int]) – The color to decompose

  • metallic (float) – Controls how “metal-like” a material appears. Value between 0 and 1

See also

setAmbient()

See also

setDiffuse()

See also

setSpecular()

See also

setShininess()

Added in version 4.2.

setColorsFromBase(self, baseColor: Union[QColor, Qt.GlobalColor, int]) Decomposes a base color into Phong material components.

Sets ambient, diffuse, and specular colors from the input color. This is equivalent to calling setColorsFromBase with the metallic parameter equal to 0: setColorsFromBase(baseColor, 0).

Parameters:

baseColor – The color to decompose

See also

setAmbient()

See also

setDiffuse()

See also

setSpecular()

Added in version 4.2.

setDiffuse(self, diffuse: QColor | Qt.GlobalColor | int)

Sets diffuse color component

Parameters:

diffuse (Union[QColor, Qt.GlobalColor, int])

setDiffuseCoefficient(self, coefficient: float)

Sets the coefficient for the diffuse color contribution (ie strength factor of the diffuse color).

Added in version 3.36.

Parameters:

coefficient (float)

setOpacity(self, opacity: float)

Sets opacity of the surface

Added in version 3.26.

Parameters:

opacity (float)

setShininess(self, shininess: float)

Sets shininess of the surface

Parameters:

shininess (float)

setSpecular(self, specular: QColor | Qt.GlobalColor | int)

Sets specular color component

Parameters:

specular (Union[QColor, Qt.GlobalColor, int])

setSpecularCoefficient(self, coefficient: float)

Sets the coefficient for the specular color contribution (ie strength factor of the specular color).

Added in version 3.36.

Parameters:

coefficient (float)

shininess(self) float

Returns shininess of the surface

Return type:

float

specular(self) QColor

Returns specular color component

Return type:

QColor

specularCoefficient(self) float

Returns the coefficient for the specular color contribution (ie strength factor of the specular color).

Added in version 3.36.

Return type:

float

static supportsTechnique(technique: Qgis.MaterialRenderingTechnique) bool

Returns True if the specified technique is supported by the Phong material.

Parameters:

technique (Qgis.MaterialRenderingTechnique)

Return type:

bool