提交 7cda20da 编写于 作者: M Mr.doob

Merge pull request #6224 from WestLangley/dev-lambert

Lambert: calculate incoming light in vertex shader; outgoing light in...
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 ambientLightColor;
#if MAX_DIR_LIGHTS > 0
......
......@@ -187,10 +187,10 @@ for( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {
#endif
vLightFront = vLightFront * diffuse + diffuse * ambientLightColor + emissive;
vLightFront += ambientLightColor;
#ifdef DOUBLE_SIDED
vLightBack = vLightBack * diffuse + diffuse * ambientLightColor + emissive;
vLightBack += ambientLightColor;
#endif
......@@ -171,8 +171,11 @@ THREE.ShaderLib = {
fragmentShader: [
"uniform vec3 diffuse;",
"uniform float opacity;",
"uniform vec3 emissive;",
"varying vec3 vLightFront;",
"#ifdef DOUBLE_SIDED",
......@@ -195,7 +198,7 @@ THREE.ShaderLib = {
"void main() {",
" vec3 outgoingLight = vec3( 0.0 );", // outgoing light does not have an alpha, the surface does
" vec4 diffuseColor = vec4( 1.0, 1.0, 1.0, opacity );",
" vec4 diffuseColor = vec4( diffuse, opacity );",
THREE.ShaderChunk[ "logdepthbuf_fragment" ],
THREE.ShaderChunk[ "map_fragment" ],
......@@ -210,13 +213,13 @@ THREE.ShaderLib = {
//"gl_FragColor.xyz *= isFront * vLightFront + ( 1.0 - isFront ) * vLightBack;",
" if ( gl_FrontFacing )",
" outgoingLight += diffuseColor.rgb * vLightFront;",
" outgoingLight += diffuseColor.rgb * vLightFront + emissive;",
" else",
" outgoingLight += diffuseColor.rgb * vLightBack;",
" outgoingLight += diffuseColor.rgb * vLightBack + emissive;",
" #else",
" outgoingLight += diffuseColor.rgb * vLightFront;",
" outgoingLight += diffuseColor.rgb * vLightFront + emissive;",
" #endif",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册