未验证 提交 f9c5efde 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #15557 from horizon-games/features/fix-lambert-hemisphere-shadows

Improved Lambert shadowmaps + Hemisphere light
......@@ -12,9 +12,11 @@ backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
vLightBack = vec3( 0.0 );
vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
......@@ -103,11 +105,11 @@ vec3 directLightColor_Diffuse;
#pragma unroll_loop
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
vLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );
#ifdef DOUBLE_SIDED
vLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );
#endif
......
......@@ -4,13 +4,14 @@ uniform vec3 emissive;
uniform float opacity;
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
varying vec3 vLightBack;
varying vec3 vIndirectBack;
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
......@@ -51,6 +52,16 @@ void main() {
// accumulation
reflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );
#ifdef DOUBLE_SIDED
reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
#else
reflectedLight.indirectDiffuse += vIndirectFront;
#endif
#include <lightmap_fragment>
reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );
......@@ -81,6 +92,5 @@ void main() {
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}
`;
......@@ -2,11 +2,11 @@ export default /* glsl */`
#define LAMBERT
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
varying vec3 vLightBack;
varying vec3 vIndirectBack;
#endif
#include <common>
......@@ -47,6 +47,5 @@ void main() {
#include <lights_lambert_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}
`;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册