为什么gl_Position变量是一个vec4而不是vec3

vec3 ndc = gl_Position.xyz / gl_Position.w;
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
"uniform float gltf_u_dec_texcoord_0_normConstant; uniform vec2 gltf_u_dec_texcoord_0_min; vec2 gltf_a_dec_texcoord_0; uniform float gltf_u_dec_position_normConstant; uniform vec3 gltf_u_dec_position_min; vec3 gltf_a_dec_position; precision highp float; uniform mat4 u_modelViewMatrix; uniform mat4 u_projectionMatrix; #ifdef APPLY_FLATTEN uniform sampler2D gltf_flattenTexture; uniform vec4 gltf_flattenBounds; uniform mat4 gltf_flattenRenderMatrix; uniform mat4 gltf_flattenInverseRenderMatrix; uniform float gltf_flattenHeight; #endif attribute vec3 a_position; attribute vec2 a_texcoord_0; varying vec2 v_texcoord_0; void gltf_decoded_POSITION() { vec3 weightedPosition = gltf_a_dec_position; vec4 position = vec4(weightedPosition, 1.0); position = u_modelViewMatrix * position; gl_Position = u_projectionMatrix * position; #ifdef PICK_VERTEX gl_PointSize = 1.0; #endif #ifdef APPLY_FLATTEN vec4 positionRelative = gltf_flattenInverseRenderMatrix * position; vec2 flattenBoundsDimension = gltf_flattenBounds.zw - gltf_flattenBounds.xy; vec2 texCoord = (positionRelative.xy - gltf_flattenBounds.xy) / flattenBoundsDimension; bool outOfBounds = texCoord.x > 1.0 || texCoord.x < 0.0 || texCoord.y > 1.0 || texCoord.y < 0.0; vec4 color = texture2D(gltf_flattenTexture, texCoord); if(!outOfBounds && abs(color.r - 1.0) < 0.1) { positionRelative.z = gltf_flattenHeight + sin(positionRelative.z) * 0.1; gl_Position = u_projectionMatrix * gltf_flattenRenderMatrix * positionRelative; } #endif v_texcoord_0 = gltf_a_dec_texcoord_0; } void gltf_decoded_TEXCOORD_0() { gltf_a_dec_position = gltf_u_dec_position_min + a_position * gltf_u_dec_position_normConstant; gltf_decoded_POSITION(); } void main() { gltf_a_dec_texcoord_0 = gltf_u_dec_texcoord_0_min + a_texcoord_0 * gltf_u_dec_texcoord_0_normConstant; gltf_decoded_TEXCOORD_0(); } "
02-07

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值