1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

0031099: Visualization, TKOpenGl - support Point light source with artistic full cut-off distance

"Range" parameter of point light sources (positional and spot) concidering in PBR has been added.
Angular attenuation parameter of spot light in PBR has been reimplemented based on existing "concentration" parameter.
This commit is contained in:
iko
2019-12-24 16:05:00 +03:00
committed by bugmaster
parent 0858125fd4
commit 88b312d3a4
12 changed files with 232 additions and 27 deletions

View File

@@ -233,3 +233,16 @@ void Graphic3d_CLight::SetSmoothAngle (Standard_ShortReal theValue)
updateRevisionIf (Abs (mySmoothness - theValue) > ShortRealEpsilon());
mySmoothness = theValue;
}
// =======================================================================
// function : SetRange
// purpose :
// =======================================================================
void Graphic3d_CLight::SetRange (Standard_ShortReal theValue)
{
Standard_ProgramError_Raise_if (myType != Graphic3d_TOLS_POSITIONAL && myType != Graphic3d_TOLS_SPOT,
"Graphic3d_CLight::SetRange(), incorrect light type");
Standard_OutOfRange_Raise_if (theValue < 0.0, "Graphic3d_CLight::SetRange(), Bad value for falloff range");
updateRevisionIf (Abs (Range() - theValue) > ShortRealEpsilon());
myDirection.w() = theValue;
};

View File

@@ -177,6 +177,16 @@ public:
//! Modifies the smoothing angle (in radians) of directional light source; should be within range [0.0, M_PI/2].
Standard_EXPORT void SetSmoothAngle (Standard_ShortReal theValue);
//! Returns maximum distance on which point light source affects to objects and is considered during illumination calculations.
//! 0.0 means disabling range considering at all without any distance limits.
//! Has sense only for point light sources (positional and spot).
Standard_ShortReal Range() const { return myDirection.w(); }
//! Modifies maximum distance on which point light source affects to objects and is considered during illumination calculations.
//! Positional and spot lights are only point light sources.
//! 0.0 means disabling range considering at all without any distance limits.
Standard_EXPORT void SetRange (Standard_ShortReal theValue);
//! @name low-level access methods
public:
@@ -189,8 +199,8 @@ public:
//! Returns the color of the light source with dummy Alpha component, which should be ignored.
const Graphic3d_Vec4& PackedColor() const { return myColor; }
//! Returns direction of directional/spot light.
const Graphic3d_Vec4& PackedDirection() const { return myDirection; }
//! Returns direction of directional/spot light and range for positional/spot light in alpha channel.
const Graphic3d_Vec4& PackedDirectionRange() const { return myDirection; }
//! @return modification counter
Standard_Size Revision() const { return myRevision; }
@@ -204,10 +214,10 @@ private:
Standard_ShortReal& changeLinearAttenuation() { return myParams.y(); }
//! Access spotlight angle parameter from packed vector.
Standard_ShortReal& changeAngle() { return myParams.z(); }
Standard_ShortReal& changeAngle() { return myParams.z(); }
//! Access spotlight concentration parameter from packed vector.
Standard_ShortReal& changeConcentration() { return myParams.w(); }
Standard_ShortReal& changeConcentration() { return myParams.w(); }
private: