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));"
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
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
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));"
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"}";
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));"
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
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));"
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"}";
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));"
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
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"}";
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));"
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.
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:
}
for (Standard_Integer aLightIt = 0; aLightIt < aNbLightsMax; ++aLightIt)
{
- myLightTypeArray.ChangeValue (aLightIt).Type = -1;
+ myLightTypeArray.SetValue (aLightIt, -1);
}
if (myLightSourceState.LightSources().IsNull()
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;
}
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)
aLightParams.Position.x() = static_cast<float>(aLight.Position().X() - myLocalOrigin.X());
aLightParams.Position.y() = static_cast<float>(aLight.Position().Y() - myLocalOrigin.Y());
aLightParams.Position.z() = static_cast<float>(aLight.Position().Z() - myLocalOrigin.Z());
- aLightParams.Position.w() = 1.0f;
}
else
{
aLightParams.Position.x() = static_cast<float>(aLight.Position().X());
aLightParams.Position.y() = static_cast<float>(aLight.Position().Y());
aLightParams.Position.z() = static_cast<float>(aLight.Position().Z());
- aLightParams.Position.w() = 1.0f;
}
+ aLightParams.Position.w() = aLight.IsHeadlight() ? 1.0f : 0.0f;
if (aLight.Type() == Graphic3d_TOLS_SPOT)
{
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,
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)
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; }";
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
|| (theBits & OpenGl_PO_IsPoint) != 0);
aSrcFrag = TCollection_AsciiString()
+ EOL
- + aSrcFragExtraFunc
- + aSrcFragExtraOut
+ aSrcFragGetVertColor
+ + EOL"vec3 Normal;"
+ aLights
+ aSrcFragGetColor
+ EOL