【问题标题】:THREE.ShaderMaterial on JSON model from blender来自搅拌机的 JSON 模型上的 THREE.ShaderMaterial
【发布时间】:2016-01-18 08:32:51
【问题描述】:

three.js r.73

我使用了一个简单的着色器,它可以在脸上制作检查器。这是VertexShader的代码:

varying vec2 vUv;
void main() {
  vUv = uv;
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
}

和 FragmentShader:

uniform vec3 color1;
uniform vec3 color2;
uniform float scale;
varying vec2 vUv;
void main() {
  vec2 center = -1.0 + 2.0 * vUv;
  vec2 uv = floor(center.xy * scale);
  if(mod(uv.x + uv.y, 2.0) > 0.5){
    gl_FragColor = vec4(color1, 1.0);
  }else{
    gl_FragColor = vec4(color2, 1.0);
  }
}

它适用于原始对象,但对于来自 Blender 的 json 格式的模型则不起作用。

问题:为什么shader不适用于json模型?

我已经准备好了jsfiddle with json object(white) and primitive box.

【问题讨论】:

  • 模型中的 uv 坐标为空
  • @gaitat 没错。我可以替别人回答吗?

标签: three.js glsl blender


【解决方案1】:

回答@gaitat

"uvs": [[0.5,0.5,0.5,0.749957(...)]],

JSON 模型必须有 UV 贴图,I've updated jsfiddle

r.73

【讨论】:

    猜你喜欢
    • 2013-10-05
    • 2013-12-25
    • 2015-10-03
    • 2012-07-14
    • 2013-09-28
    • 2020-09-07
    • 2021-09-12
    • 2014-11-28
    • 2019-04-30
    相关资源
    最近更新 更多