diff --git a/src/OpenGl/OpenGl_ShaderManager.cxx b/src/OpenGl/OpenGl_ShaderManager.cxx index ee435d0cc9..a1dfa2bf5f 100644 --- a/src/OpenGl/OpenGl_ShaderManager.cxx +++ b/src/OpenGl/OpenGl_ShaderManager.cxx @@ -109,7 +109,7 @@ const char THE_FUNC_pointLight[] = EOL" in vec3 thePoint," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = occLight_Position (theId).xyz;" + EOL" vec3 aLight = occLight_Position (theId);" EOL" if (!occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));" @@ -119,8 +119,7 @@ const char THE_FUNC_pointLight[] = EOL" float aDist = length (aLight);" EOL" aLight = aLight * (1.0 / aDist);" EOL - EOL" float anAtten = 1.0 / (occLight_ConstAttenuation (theId)" - EOL" + occLight_LinearAttenuation (theId) * aDist);" + EOL" float anAtten = 1.0 / (occLight_ConstAttenuation (theId) + occLight_LinearAttenuation (theId) * aDist);" EOL EOL" vec3 aHalf = normalize (aLight + theView);" EOL @@ -134,8 +133,8 @@ const char THE_FUNC_pointLight[] = EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());" EOL" }" EOL - EOL" Diffuse += occLight_Diffuse (theId).rgb * aNdotL * anAtten;" - EOL" Specular += occLight_Specular (theId).rgb * aSpecl * anAtten;" + EOL" Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;" + EOL" Specular += occLight_Specular(theId) * aSpecl * anAtten;" EOL"}"; //! Function computes contribution of isotropic point light source @@ -146,7 +145,7 @@ const char THE_FUNC_PBR_pointLight[] = EOL" in vec3 thePoint," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = occLight_Position (theId).xyz;" + EOL" vec3 aLight = occLight_Position (theId);" EOL" if (occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrixInverse * vec4 (aLight, 1.0));" @@ -159,14 +158,9 @@ const char THE_FUNC_PBR_pointLight[] = EOL" float anAtten = 1.0 / max (aDist * aDist, 0.01);" EOL EOL" theNormal = theIsFront ? theNormal : -theNormal;" - EOL" DirectLighting += occPBRIllumination (theView," - EOL" aLight," - EOL" theNormal," - EOL" BaseColor," - EOL" Metallic," - EOL" Roughness," - EOL" IOR," - EOL" occLight_Specular(theId).rgb," + EOL" DirectLighting += occPBRIllumination (theView, aLight, theNormal," + EOL" BaseColor, Metallic, Roughness, IOR," + EOL" occLight_Specular (theId)," EOL" occLight_Intensity(theId) * anAtten);" EOL"}"; @@ -178,8 +172,8 @@ const char THE_FUNC_spotLight[] = EOL" in vec3 thePoint," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = occLight_Position (theId).xyz;" - EOL" vec3 aSpotDir = occLight_SpotDirection (theId).xyz;" + EOL" vec3 aLight = occLight_Position (theId);" + EOL" vec3 aSpotDir = occLight_SpotDirection (theId);" EOL" if (!occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));" @@ -218,8 +212,8 @@ const char THE_FUNC_spotLight[] = EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());" EOL" }" EOL - EOL" Diffuse += occLight_Diffuse (theId).rgb * aNdotL * anAtten;" - EOL" Specular += occLight_Specular (theId).rgb * aSpecl * anAtten;" + EOL" Diffuse += occLight_Diffuse (theId) * aNdotL * anAtten;" + EOL" Specular += occLight_Specular(theId) * aSpecl * anAtten;" EOL"}"; //! Function computes contribution of spotlight source @@ -230,8 +224,8 @@ const char THE_FUNC_spotLight[] = EOL" in vec3 thePoint," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = occLight_Position (theId).xyz;" - EOL" vec3 aSpotDir = occLight_SpotDirection (theId).xyz;" + EOL" vec3 aLight = occLight_Position (theId);" + EOL" vec3 aSpotDir = occLight_SpotDirection (theId);" EOL" if (occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrixInverse * vec4 (aLight, 1.0));" @@ -258,14 +252,9 @@ const char THE_FUNC_spotLight[] = EOL" }" EOL EOL" theNormal = theIsFront ? theNormal : -theNormal;" - EOL" DirectLighting += occPBRIllumination (theView," - EOL" aLight," - EOL" theNormal," - EOL" BaseColor," - EOL" Metallic," - EOL" Roughness," - EOL" IOR," - EOL" occLight_Specular(theId).rgb," + EOL" DirectLighting += occPBRIllumination (theView aLight, theNormal," + EOL" BaseColor, Metallic, Roughness, IOR," + EOL" occLight_Specular(theId)," EOL" occLight_Intensity(theId) * anAtten);" EOL"}"; @@ -276,7 +265,7 @@ const char THE_FUNC_directionalLight[] = EOL" in vec3 theView," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = normalize (occLight_Position (theId).xyz);" + EOL" vec3 aLight = normalize (occLight_Position (theId));" EOL" if (!occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));" @@ -294,8 +283,8 @@ const char THE_FUNC_directionalLight[] = EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());" EOL" }" EOL - EOL" Diffuse += occLight_Diffuse (theId).rgb * aNdotL;" - EOL" Specular += occLight_Specular (theId).rgb * aSpecl;" + EOL" Diffuse += occLight_Diffuse (theId) * aNdotL;" + EOL" Specular += occLight_Specular (theId) * aSpecl;" EOL"}"; //! Function computes contribution of directional light source @@ -305,21 +294,16 @@ const char THE_FUNC_PBR_directionalLight[] = EOL" in vec3 theView," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = normalize (occLight_Position (theId).xyz);" + EOL" vec3 aLight = normalize (occLight_Position (theId));" EOL" if (occLight_IsHeadlight (theId))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrixInverse * vec4 (aLight, 0.0));" EOL" }" EOL EOL" theNormal = theIsFront ? theNormal : -theNormal;" - EOL" DirectLighting += occPBRIllumination (theView," - EOL" aLight," - EOL" theNormal," - EOL" BaseColor," - EOL" Metallic," - EOL" Roughness," - EOL" IOR," - EOL" occLight_Specular(theId).rgb," + EOL" DirectLighting += occPBRIllumination (theView, aLight, theNormal," + EOL" BaseColor, Metallic, Roughness, IOR," + EOL" occLight_Specular (theId)," EOL" occLight_Intensity(theId));" EOL"}"; @@ -330,7 +314,7 @@ const char THE_FUNC_directionalLightFirst[] = EOL" in vec3 theView," EOL" in bool theIsFront)" EOL"{" - EOL" vec3 aLight = normalize (occLightSources[1].xyz);" + EOL" vec3 aLight = normalize (occLight_Position(0));" EOL" if (!occLight_IsHeadlight (0))" EOL" {" EOL" aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));" @@ -348,8 +332,8 @@ const char THE_FUNC_directionalLightFirst[] = EOL" aSpecl = pow (aNdotH, theIsFront ? occFrontMaterial_Shininess() : occBackMaterial_Shininess());" EOL" }" EOL - EOL" Diffuse += occLightSources[0].rgb * aNdotL;" - EOL" Specular += occLightSources[0].rgb * aSpecl;" + EOL" Diffuse += occLight_Diffuse(0) * aNdotL;" + EOL" Specular += occLight_Specular(0) * aSpecl;" EOL"}"; //! Returns the real cubemap fetching direction considering sides orientation, memory layout and vertical flip. @@ -500,7 +484,7 @@ EOL" gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatr theCtx->core11->glLightf (theLightGlId, GL_SPOT_CUTOFF, THE_DEFAULT_SPOT_CUTOFF); theCtx->core11->glLightf (theLightGlId, GL_CONSTANT_ATTENUATION, theLight.ConstAttenuation()); theCtx->core11->glLightf (theLightGlId, GL_LINEAR_ATTENUATION, theLight.LinearAttenuation()); - theCtx->core11->glLightf (theLightGlId, GL_QUADRATIC_ATTENUATION, 0.0); + theCtx->core11->glLightf (theLightGlId, GL_QUADRATIC_ATTENUATION, 0.0f); break; } case Graphic3d_TOLS_SPOT: @@ -867,7 +851,7 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr } for (Standard_Integer aLightIt = 0; aLightIt < aNbLightsMax; ++aLightIt) { - myLightTypeArray.ChangeValue (aLightIt).Type = -1; + myLightTypeArray.SetValue (aLightIt, -1); } if (myLightSourceState.LightSources().IsNull() @@ -881,8 +865,8 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 0.0f)); theProgram->SetUniform (myContext, theProgram->GetStateLocation (OpenGl_OCC_LIGHT_SOURCE_TYPES), - aNbLightsMax * OpenGl_ShaderLightType::NbOfVec2i(), - myLightTypeArray.First().Packed()); + aNbLightsMax, + &myLightTypeArray.First()); return; } @@ -901,22 +885,20 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr continue; } - OpenGl_ShaderLightType& aLightType = myLightTypeArray.ChangeValue (aLightsNb); + Standard_Integer& aLightType = myLightTypeArray .ChangeValue (aLightsNb); OpenGl_ShaderLightParameters& aLightParams = myLightParamsArray.ChangeValue (aLightsNb); if (!aLight.IsEnabled()) // has no affect with Graphic3d_LightSet::IterationFilter_ExcludeDisabled - here just for consistency { // if it is desired to keep disabled light in the same order - we can replace it with a black light so that it will have no influence on result - aLightType.Type = -1; // Graphic3d_TOLS_AMBIENT can be used instead - aLightType.IsHeadlight = false; - aLightParams.Color = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 0.0f); + aLightType = -1; // Graphic3d_TOLS_AMBIENT can be used instead + aLightParams.Color = OpenGl_Vec4 (0.0f, 0.0f, 0.0f, 0.0f); ++aLightsNb; continue; } // ignoring OpenGl_Context::ToRenderSRGB() for light colors, // as non-absolute colors for lights are rare and require tuning anyway - aLightType.Type = aLight.Type(); - aLightType.IsHeadlight = aLight.IsHeadlight(); + aLightType = aLight.Type(); aLightParams.Color = aLight.PackedColor(); aLightParams.Color.a() = aLight.Intensity(); // used by PBR and ignored by old shading model if (aLight.Type() == Graphic3d_TOLS_DIRECTIONAL) @@ -928,15 +910,14 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr aLightParams.Position.x() = static_cast(aLight.Position().X() - myLocalOrigin.X()); aLightParams.Position.y() = static_cast(aLight.Position().Y() - myLocalOrigin.Y()); aLightParams.Position.z() = static_cast(aLight.Position().Z() - myLocalOrigin.Z()); - aLightParams.Position.w() = 1.0f; } else { aLightParams.Position.x() = static_cast(aLight.Position().X()); aLightParams.Position.y() = static_cast(aLight.Position().Y()); aLightParams.Position.z() = static_cast(aLight.Position().Z()); - aLightParams.Position.w() = 1.0f; } + aLightParams.Position.w() = aLight.IsHeadlight() ? 1.0f : 0.0f; if (aLight.Type() == Graphic3d_TOLS_SPOT) { @@ -955,8 +936,8 @@ void OpenGl_ShaderManager::pushLightSourceState (const Handle(OpenGl_ShaderProgr anAmbient); theProgram->SetUniform (myContext, theProgram->GetStateLocation (OpenGl_OCC_LIGHT_SOURCE_TYPES), - aNbLightsMax * OpenGl_ShaderLightType::NbOfVec2i(), - myLightTypeArray.First().Packed()); + aNbLightsMax, + &myLightTypeArray.First()); if (aLightsNb > 0) { theProgram->SetUniform (myContext, @@ -2593,7 +2574,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha aProgramSrc->SetPBR (theIsPBR); TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain; - TCollection_AsciiString aSrcFrag, aSrcFragExtraFunc, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain; + TCollection_AsciiString aSrcFrag, aSrcFragGetVertColor, aSrcFragExtraMain; TCollection_AsciiString aSrcFragGetColor = TCollection_AsciiString() + EOL"vec4 getColor(void) { return " + aPhongCompLight + "; }"; OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts; if ((theBits & OpenGl_PO_IsPoint) != 0) @@ -2708,7 +2689,6 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha if (isFlatNormal) { - aSrcFragExtraOut += EOL"vec3 Normal;"; aSrcFragExtraMain += TCollection_AsciiString() + EOL" Normal = " + aDFdxSignReversion + "normalize (cross (dFdx (" + aPosition + ".xyz / " + aPosition + ".w), dFdy (" + aPosition + ".xyz / " + aPosition + ".w)));" EOL" if (!gl_FrontFacing) { Normal = -Normal; }"; @@ -2718,7 +2698,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha aStageInOuts.Append(OpenGl_ShaderObject::ShaderVariable("vec3 vNormal", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT)); aSrcVertExtraFunc += THE_FUNC_transformNormal_world; aSrcVertExtraMain += EOL" vNormal = transformNormal (occNormal);"; - aSrcFragExtraFunc += EOL" vec3 Normal = vNormal;"; + aSrcFragExtraMain += EOL" Normal = vNormal;"; if ((theBits & OpenGl_PO_IsPoint) == 0 && (theBits & OpenGl_PO_HasTextures) == OpenGl_PO_TextureNormal @@ -2782,9 +2762,8 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha || (theBits & OpenGl_PO_IsPoint) != 0); aSrcFrag = TCollection_AsciiString() + EOL - + aSrcFragExtraFunc - + aSrcFragExtraOut + aSrcFragGetVertColor + + EOL"vec3 Normal;" + aLights + aSrcFragGetColor + EOL diff --git a/src/OpenGl/OpenGl_ShaderManager.hxx b/src/OpenGl/OpenGl_ShaderManager.hxx index ea56a4814d..e11f179f9c 100644 --- a/src/OpenGl/OpenGl_ShaderManager.hxx +++ b/src/OpenGl/OpenGl_ShaderManager.hxx @@ -760,27 +760,16 @@ protected: //! Packed properties of light source struct OpenGl_ShaderLightParameters { - OpenGl_Vec4 Color; - OpenGl_Vec4 Position; - OpenGl_Vec4 Direction; - OpenGl_Vec4 Parameters; + OpenGl_Vec4 Color; //!< RGB color + Intensity (in .w) + OpenGl_Vec4 Position; //!< XYZ Direction or Position + IsHeadlight (in .w) + OpenGl_Vec4 Direction; //!< spot light XYZ direction + OpenGl_Vec4 Parameters; //!< same as Graphic3d_CLight::PackedParams() //! Returns packed (serialized) representation of light source properties const OpenGl_Vec4* Packed() const { return reinterpret_cast (this); } static Standard_Integer NbOfVec4() { return 4; } }; - //! Packed light source type information - struct OpenGl_ShaderLightType - { - Standard_Integer Type; - Standard_Integer IsHeadlight; - - //! Returns packed (serialized) representation of light source type - const OpenGl_Vec2i* Packed() const { return reinterpret_cast (this); } - static Standard_Integer NbOfVec2i() { return 1; } - }; - //! Fake OpenGL program for tracking FFP state in the way consistent to programmable pipeline. class OpenGl_ShaderProgramFFP : public OpenGl_ShaderProgram { @@ -852,7 +841,7 @@ protected: gp_XYZ myLocalOrigin; //!< local camera transformation Standard_Boolean myHasLocalOrigin; //!< flag indicating that local camera transformation has been set - mutable NCollection_Array1 myLightTypeArray; + mutable NCollection_Array1 myLightTypeArray; mutable NCollection_Array1 myLightParamsArray; mutable NCollection_Array1 myClipPlaneArray; mutable NCollection_Array1 myClipPlaneArrayFfp; diff --git a/src/Shaders/Declarations.glsl b/src/Shaders/Declarations.glsl index 0081b83edd..b7dbe78c2e 100644 --- a/src/Shaders/Declarations.glsl +++ b/src/Shaders/Declarations.glsl @@ -139,19 +139,22 @@ uniform vec4 occLightAmbient; //!< Cumulative ambient color uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources //! Type of light source, int (see OccLightType enum). -#define occLight_Type(theId) occLightSourcesTypes[theId].x +#define occLight_Type(theId) occLightSourcesTypes[theId] -//! Is light a headlight, int? -#define occLight_IsHeadlight(theId) (occLightSourcesTypes[theId].y != 0) +//! Specular intensity (equals to diffuse), vec3. +#define occLight_Specular(theId) occLightSources[theId * 4 + 0].rgb -//! Specular intensity (equals to diffuse), vec4. -#define occLight_Specular(theId) occLightSources[theId * 4 + 0] +//! Intensity of light source (>= 0), float. +#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a -//! Position of specified light source, vec4. -#define occLight_Position(theId) occLightSources[theId * 4 + 1] +//! Is light a headlight, bool? +#define occLight_IsHeadlight(theId) (occLightSources[theId * 4 + 1].w > 0.5) -//! Direction of specified spot light source, vec4. -#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2] +//! Position of specified light source, vec3. +#define occLight_Position(theId) occLightSources[theId * 4 + 1].xyz + +//! Direction of specified spot light source, vec3. +#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2].xyz //! Maximum spread angle of the spot light (in radians), float. #define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z @@ -159,13 +162,9 @@ uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sour //! Attenuation of the spot light intensity (from 0 to 1), float. #define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w -#if defined(THE_IS_PBR) -//! Intensity of light source (>= 0), float. -#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a -#else - -//! Diffuse intensity (equals to Specular), vec4. -#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0] +#if !defined(THE_IS_PBR) +//! Diffuse intensity (equals to Specular), vec3. +#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0].rgb //! Const attenuation factor of positional light source, float. #define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x diff --git a/src/Shaders/DeclarationsImpl.glsl b/src/Shaders/DeclarationsImpl.glsl index a2521a56b4..dba698d0f3 100644 --- a/src/Shaders/DeclarationsImpl.glsl +++ b/src/Shaders/DeclarationsImpl.glsl @@ -19,8 +19,8 @@ void occSetFragColor (in vec4 theColor) #if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0) // arrays of light sources -uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters -uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types +uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters +uniform THE_PREC_ENUM int occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types #endif #if defined(THE_IS_PBR) diff --git a/src/Shaders/Shaders_DeclarationsImpl_glsl.pxx b/src/Shaders/Shaders_DeclarationsImpl_glsl.pxx index b2e47cdb2d..51a35dc097 100644 --- a/src/Shaders/Shaders_DeclarationsImpl_glsl.pxx +++ b/src/Shaders/Shaders_DeclarationsImpl_glsl.pxx @@ -22,8 +22,8 @@ static const char Shaders_DeclarationsImpl_glsl[] = "\n" "#if defined(THE_MAX_LIGHTS) && (THE_MAX_LIGHTS > 0)\n" "// arrays of light sources\n" - "uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters\n" - "uniform THE_PREC_ENUM ivec2 occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types\n" + "uniform vec4 occLightSources[THE_MAX_LIGHTS * 4]; //!< packed light sources parameters\n" + "uniform THE_PREC_ENUM int occLightSourcesTypes[THE_MAX_LIGHTS]; //!< packed light sources types\n" "#endif\n" "\n" "#if defined(THE_IS_PBR)\n" diff --git a/src/Shaders/Shaders_Declarations_glsl.pxx b/src/Shaders/Shaders_Declarations_glsl.pxx index c0e596deb2..4cd83b435d 100644 --- a/src/Shaders/Shaders_Declarations_glsl.pxx +++ b/src/Shaders/Shaders_Declarations_glsl.pxx @@ -142,19 +142,22 @@ static const char Shaders_Declarations_glsl[] = "uniform THE_PREC_ENUM int occLightSourcesCount; //!< Total number of light sources\n" "\n" "//! Type of light source, int (see OccLightType enum).\n" - "#define occLight_Type(theId) occLightSourcesTypes[theId].x\n" + "#define occLight_Type(theId) occLightSourcesTypes[theId]\n" "\n" - "//! Is light a headlight, int?\n" - "#define occLight_IsHeadlight(theId) (occLightSourcesTypes[theId].y != 0)\n" + "//! Specular intensity (equals to diffuse), vec3.\n" + "#define occLight_Specular(theId) occLightSources[theId * 4 + 0].rgb\n" "\n" - "//! Specular intensity (equals to diffuse), vec4.\n" - "#define occLight_Specular(theId) occLightSources[theId * 4 + 0]\n" + "//! Intensity of light source (>= 0), float.\n" + "#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a\n" "\n" - "//! Position of specified light source, vec4.\n" - "#define occLight_Position(theId) occLightSources[theId * 4 + 1]\n" + "//! Is light a headlight, bool?\n" + "#define occLight_IsHeadlight(theId) (occLightSources[theId * 4 + 1].w > 0.5)\n" "\n" - "//! Direction of specified spot light source, vec4.\n" - "#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2]\n" + "//! Position of specified light source, vec3.\n" + "#define occLight_Position(theId) occLightSources[theId * 4 + 1].xyz\n" + "\n" + "//! Direction of specified spot light source, vec3.\n" + "#define occLight_SpotDirection(theId) occLightSources[theId * 4 + 2].xyz\n" "\n" "//! Maximum spread angle of the spot light (in radians), float.\n" "#define occLight_SpotCutOff(theId) occLightSources[theId * 4 + 3].z\n" @@ -162,13 +165,9 @@ static const char Shaders_Declarations_glsl[] = "//! Attenuation of the spot light intensity (from 0 to 1), float.\n" "#define occLight_SpotExponent(theId) occLightSources[theId * 4 + 3].w\n" "\n" - "#if defined(THE_IS_PBR)\n" - "//! Intensity of light source (>= 0), float.\n" - "#define occLight_Intensity(theId) occLightSources[theId * 4 + 0].a\n" - "#else\n" - "\n" - "//! Diffuse intensity (equals to Specular), vec4.\n" - "#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0]\n" + "#if !defined(THE_IS_PBR)\n" + "//! Diffuse intensity (equals to Specular), vec3.\n" + "#define occLight_Diffuse(theId) occLightSources[theId * 4 + 0].rgb\n" "\n" "//! Const attenuation factor of positional light source, float.\n" "#define occLight_ConstAttenuation(theId) occLightSources[theId * 4 + 3].x\n"