vec3 aLight = occLight_Position (theId).xyz;
if (occLight_IsHeadlight (theId) == 0)
{
- aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));
+ aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
}
aLight -= thePoint;
vec3 aSpotDir = occLight_SpotDirection (theId).xyz;
if (occLight_IsHeadlight (theId) == 0)
{
- aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 1.0));
- aSpotDir = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aSpotDir, 0.0));
+ aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 1.0));
+ aSpotDir = vec3 (occWorldViewMatrix * vec4 (aSpotDir, 0.0));
}
aLight -= thePoint;
vec3 aLight = normalize (occLight_Position (theId).xyz);
if (occLight_IsHeadlight (theId) == 0)
{
- aLight = vec3 (occWorldViewMatrix * occModelWorldMatrix * vec4 (aLight, 0.0));
+ aLight = vec3 (occWorldViewMatrix * vec4 (aLight, 0.0));
}
vec3 aHalf = normalize (aLight + theView);
vec4 aMaterialAmbient = gl_FrontFacing ? occFrontMaterial_Ambient() : occBackMaterial_Ambient();
vec4 aMaterialDiffuse = gl_FrontFacing ? occFrontMaterial_Diffuse() : occBackMaterial_Diffuse();
vec4 aMaterialSpecular = gl_FrontFacing ? occFrontMaterial_Specular() : occBackMaterial_Specular();
- return vec4 (Ambient, 1.0) * aMaterialAmbient
- + vec4 (Diffuse, 1.0) * aMaterialDiffuse
- + vec4 (Specular, 1.0) * aMaterialSpecular;
+ vec4 aMaterialEmission = gl_FrontFacing ? occFrontMaterial_Emission() : occBackMaterial_Emission();
+ vec3 aColor = Ambient * aMaterialAmbient.rgb
+ + Diffuse * aMaterialDiffuse.rgb
+ + Specular * aMaterialSpecular.rgb
+ + aMaterialEmission.rgb;
+ return vec4 (aColor, aMaterialDiffuse.a);
}
//! Entry point to the Fragment Shader
for (int anIndex = 0; anIndex < occClipPlaneCount; ++anIndex)
{
vec4 aClipEquation = occClipPlaneEquations[anIndex];
- int aClipSpace = occClipPlaneSpaces[anIndex];
- if (aClipSpace == OccEquationCoords_World)
+ if (dot (aClipEquation.xyz, PositionWorld.xyz / PositionWorld.w) + aClipEquation.w < 0.0)
{
- if (dot (aClipEquation.xyz, PositionWorld.xyz) + aClipEquation.w < 0.0)
- {
- discard;
- }
- }
- else if (aClipSpace == OccEquationCoords_View)
- {
- if (dot (aClipEquation.xyz, Position.xyz) + aClipEquation.w < 0.0)
- {
- discard;
- }
+ discard;
}
}
- gl_FragColor = computeLighting (normalize (Normal),
+ occFragColor = computeLighting (normalize (Normal),
normalize (View),
Position);
+
+ if (occOitOutput != 0)
+ {
+ float aWeight = occFragColor.a * clamp (1e+2 * pow (1.0 - gl_FragCoord.z * occOitDepthFactor, 3.0), 1e-2, 1e+2);
+ occFragCoverage.r = occFragColor.a * aWeight;
+ occFragColor = vec4 (occFragColor.rgb * occFragColor.a * aWeight, occFragColor.a);
+ }
}