提交 db5b099c 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #11810 from WestLangley/dev-equirect

Equirect shader: fixed equirectangular projection
......@@ -172,15 +172,10 @@ var ShaderLib = {
},
/* -------------------------------------------------------------------------
// Cube map shader
------------------------------------------------------------------------- */
equirect: {
uniforms: {
tEquirect: { value: null },
tFlip: { value: - 1 }
},
vertexShader: ShaderChunk.equirect_vert,
......
uniform sampler2D tEquirect;
uniform float tFlip;
varying vec3 vWorldPosition;
......@@ -7,11 +6,14 @@ varying vec3 vWorldPosition;
void main() {
// gl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );
vec3 direction = normalize( vWorldPosition );
vec2 sampleUV;
sampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );
sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;
gl_FragColor = texture2D( tEquirect, sampleUV );
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册