在三个j中,我使用顶点着色器为大几何体设置动画。
我还在输出上设置了景深效果。问题是,景深效果似乎不知道在我的顶点着色器中创建的更改位置。它的响应就像几何体处于原始位置一样。
如何更新着色器/材质中的深度信息,以便DOF正常工作? THREE.Material有一个depthWrite属性,但它似乎不是......
我的景深传递方式如下:
renderer.render( this.originalScene, this.originalCamera, this.rtTextureColor, true );
this.originalScene.overrideMaterial = this.material_depth;
renderer.render( this.originalScene, this.originalCamera, this.rtTextureDepth, true );
rtTextureColor和rtTextureDepth都是WebGLRenderTargets。出于某种原因,rtTextureColor是正确的,但rtTextureDepth不是
这是我的顶点着色器:
int sphereIndex = int(floor(position.x/10.));
float displacementVal = displacement[sphereIndex].w;
vec3 rotationDisplacement = displacement[sphereIndex].xyz;
vNormal = normalize( normalMatrix * normal );
vec3 vNormel = normalize( normalMatrix * viewVector );
intensity = abs(pow( c - dot(vNormal, vNormel), p ));
float xVal = (displacementVal*orbitMultiplier) * sin(timeValue*rotationDisplacement.x);
float yVal = (displacementVal*orbitMultiplier) * cos(timeValue*rotationDisplacement.y);
float zVal = 0;
vec3 rotatePosition = vec3(xVal,yVal,zVal);
vec3 newPos = (position-vec3((10.*floor(position.x/10.)),0,0))+rotatePosition;
vec4 mvPosition;
mvPosition = (modelViewMatrix * vec4(newPos,1));
vViewPosition = -mvPosition.xyz;
vec4 p = projectionMatrix * mvPosition;
gl_Position = p;