提交 a56405c4 编写于 作者: B Ben Houston (Clara.io) 提交者: Mr.doob

Quick fix nexus5 point/spot light issues (#9948)

* remove testLightInRange, not equivalent to calcLightAttenuation.

* convert vec3( 0.0, 0.0, 0.0 ) -> vec3( 0.0 ), smaller, equivalent.

* fix merge issue in SpotLight glsl code.
上级 0237f191
bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {
return any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );
}
float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
if( decayExponent > 0.0 ) {
......
......@@ -63,19 +63,9 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
float lightDistance = length( lVector );
if ( testLightInRange( lightDistance, pointLight.distance ) ) {
directLight.color = pointLight.color;
directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
directLight.visible = true;
} else {
directLight.color = vec3( 0.0 );
directLight.visible = false;
}
directLight.color = pointLight.color;
directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
directLight.visible = ( directLight.color != vec3( 0.0 ) );
}
......@@ -110,14 +100,13 @@ vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
float lightDistance = length( lVector );
float angleCos = dot( directLight.direction, spotLight.direction );
if ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {
if ( angleCos > spotLight.coneCos ) {
float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
directLight.color = spotLight.color;
directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
directLight.visible = true;
directLight.visible = true;//( directLight.color != vec3( 0.0 ) );
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册