0
uv座標我有一個球體與着色器材質。在該材料中,我需要使用uv
座標,但我不明白它們是如何計算的。如果我檢查球體的幾何圖形uv
座標的範圍是[0, 1]
,但在我的着色器中,它們似乎只使用該範圍的一半。爲什麼?什麼範圍是從
var material = new THREE.ShaderMaterial({
vertexShader: vertexShader,
fragmentShader: fragmentShader
});
var sphere = new THREE.Mesh(new THREE.SphereGeometry(150, 16, 16), material);
//
// Vertex shader
//
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
//
// Fragment shader
//
varying vec2 vUv;
void main() {
// why is the vUv.x range somewhere between 17/255 and 110/255
gl_FragColor = vec4(vUv.x, 0.0, 0.0, 1.0);
// this corrects it a little bit but it still isnt range [0/255, 255/255]
//gl_FragColor = vec4(vUv.x*2.0, 0.0, 0.0, 1.0);
}