mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0032172: Visualization, TKOpenGl - implement simple shadow mapping for a spot light source
added test: opengl/data/shadows/spotlight
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
srcinc:::Declarations.glsl
|
||||
srcinc:::DeclarationsImpl.glsl
|
||||
srcinc:::DirectionalLightShadow.glsl
|
||||
srcinc:::LightShadow.glsl
|
||||
srcinc:::PBRCookTorrance.glsl
|
||||
srcinc:::PBRDirectionalLight.glsl
|
||||
srcinc:::PBRDistribution.glsl
|
||||
@@ -27,7 +27,7 @@ srcinc:::TangentSpaceNormal.glsl
|
||||
srcinc:::SkydomBackground.fs
|
||||
Shaders_Declarations_glsl.pxx
|
||||
Shaders_DeclarationsImpl_glsl.pxx
|
||||
Shaders_DirectionalLightShadow_glsl.pxx
|
||||
Shaders_LightShadow_glsl.pxx
|
||||
Shaders_Display_fs.pxx
|
||||
Shaders_PBRCookTorrance_glsl.pxx
|
||||
Shaders_PBRDirectionalLight_glsl.pxx
|
||||
|
@@ -9,10 +9,10 @@ const vec2 occPoissonDisk16[16] = vec2[](
|
||||
);
|
||||
#endif
|
||||
|
||||
//! Function computes directional light shadow attenuation (1.0 means no shadow).
|
||||
float occDirectionalLightShadow (in sampler2D theShadow,
|
||||
in int theId,
|
||||
in vec3 theNormal)
|
||||
//! Function computes directional and spot light shadow attenuation (1.0 means no shadow).
|
||||
float occLightShadow (in sampler2D theShadow,
|
||||
in int theId,
|
||||
in vec3 theNormal)
|
||||
{
|
||||
vec4 aPosLightSpace = PosLightSpace[occLight_Index(theId)];
|
||||
vec3 aLightDir = occLight_Position (theId);
|
@@ -9,7 +9,8 @@ void occSpotLight (in int theId,
|
||||
in vec3 theNormal,
|
||||
in vec3 theView,
|
||||
in vec3 thePoint,
|
||||
in bool theIsFront)
|
||||
in bool theIsFront,
|
||||
in float theShadow)
|
||||
{
|
||||
vec3 aLight = occLight_Position (theId) - thePoint;
|
||||
|
||||
@@ -40,5 +41,5 @@ void occSpotLight (in int theId,
|
||||
DirectLighting += occPBRIllumination (theView, aLight, theNormal,
|
||||
BaseColor, Metallic, Roughness, IOR,
|
||||
occLight_Specular(theId),
|
||||
occLight_Intensity(theId) * anAtten);
|
||||
occLight_Intensity(theId) * anAtten) * theShadow;
|
||||
}
|
||||
|
@@ -5,11 +5,13 @@
|
||||
//! @param theView view direction
|
||||
//! @param thePoint 3D position (world space)
|
||||
//! @param theIsFront front/back face flag
|
||||
//! @param theShadow the value from shadow map
|
||||
void occSpotLight (in int theId,
|
||||
in vec3 theNormal,
|
||||
in vec3 theView,
|
||||
in vec3 thePoint,
|
||||
in bool theIsFront)
|
||||
in bool theIsFront,
|
||||
in float theShadow)
|
||||
{
|
||||
vec3 aLight = occLight_Position (theId) - thePoint;
|
||||
|
||||
@@ -45,6 +47,6 @@ void occSpotLight (in int theId,
|
||||
aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));
|
||||
}
|
||||
|
||||
Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;
|
||||
Specular += occLight_Specular(theId) * aSpecl * anAtten;
|
||||
Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten * theShadow;
|
||||
Specular += occLight_Specular(theId) * aSpecl * anAtten * theShadow;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// This file has been automatically generated from resource file src/Shaders/DirectionalLightShadow.glsl
|
||||
// This file has been automatically generated from resource file src/Shaders/LightShadow.glsl
|
||||
|
||||
static const char Shaders_DirectionalLightShadow_glsl[] =
|
||||
static const char Shaders_LightShadow_glsl[] =
|
||||
"#if (__VERSION__ >= 120)\n"
|
||||
"//! Coefficients for gathering close samples for antialiasing.\n"
|
||||
"//! Use only with decent OpenGL (array constants cannot be initialized with GLSL 1.1 / GLSL ES 1.1)\n"
|
||||
@@ -12,10 +12,10 @@ static const char Shaders_DirectionalLightShadow_glsl[] =
|
||||
");\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
"//! Function computes directional light shadow attenuation (1.0 means no shadow).\n"
|
||||
"float occDirectionalLightShadow (in sampler2D theShadow,\n"
|
||||
" in int theId,\n"
|
||||
" in vec3 theNormal)\n"
|
||||
"//! Function computes directional and spot light shadow attenuation (1.0 means no shadow).\n"
|
||||
"float occLightShadow (in sampler2D theShadow,\n"
|
||||
" in int theId,\n"
|
||||
" in vec3 theNormal)\n"
|
||||
"{\n"
|
||||
" vec4 aPosLightSpace = PosLightSpace[occLight_Index(theId)];\n"
|
||||
" vec3 aLightDir = occLight_Position (theId);\n"
|
@@ -12,7 +12,8 @@ static const char Shaders_PBRSpotLight_glsl[] =
|
||||
" in vec3 theNormal,\n"
|
||||
" in vec3 theView,\n"
|
||||
" in vec3 thePoint,\n"
|
||||
" in bool theIsFront)\n"
|
||||
" in bool theIsFront,\n"
|
||||
" in float theShadow)\n"
|
||||
"{\n"
|
||||
" vec3 aLight = occLight_Position (theId) - thePoint;\n"
|
||||
"\n"
|
||||
@@ -43,5 +44,5 @@ static const char Shaders_PBRSpotLight_glsl[] =
|
||||
" DirectLighting += occPBRIllumination (theView, aLight, theNormal,\n"
|
||||
" BaseColor, Metallic, Roughness, IOR,\n"
|
||||
" occLight_Specular(theId),\n"
|
||||
" occLight_Intensity(theId) * anAtten);\n"
|
||||
" occLight_Intensity(theId) * anAtten) * theShadow;\n"
|
||||
"}\n";
|
||||
|
@@ -8,11 +8,13 @@ static const char Shaders_PhongSpotLight_glsl[] =
|
||||
"//! @param theView view direction\n"
|
||||
"//! @param thePoint 3D position (world space)\n"
|
||||
"//! @param theIsFront front/back face flag\n"
|
||||
"//! @param theShadow the value from shadow map\n"
|
||||
"void occSpotLight (in int theId,\n"
|
||||
" in vec3 theNormal,\n"
|
||||
" in vec3 theView,\n"
|
||||
" in vec3 thePoint,\n"
|
||||
" in bool theIsFront)\n"
|
||||
" in bool theIsFront,\n"
|
||||
" in float theShadow)\n"
|
||||
"{\n"
|
||||
" vec3 aLight = occLight_Position (theId) - thePoint;\n"
|
||||
"\n"
|
||||
@@ -48,6 +50,6 @@ static const char Shaders_PhongSpotLight_glsl[] =
|
||||
" aSpecl = pow (aNdotH, occMaterial_Shininess (theIsFront));\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;\n"
|
||||
" Specular += occLight_Specular(theId) * aSpecl * anAtten;\n"
|
||||
" Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten * theShadow;\n"
|
||||
" Specular += occLight_Specular(theId) * aSpecl * anAtten * theShadow;\n"
|
||||
"}\n";
|
||||
|
Reference in New Issue
Block a user