Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken vertex shaders for Draco compressed meshes with vec3 per-vertex color #7576

Closed
likangning93 opened this issue Feb 16, 2019 · 0 comments

Comments

@likangning93
Copy link
Contributor

Here's Draco and non-Draco versions of the model as glb: luyssport_Ftm_skysphere.zip

These were derived from https://sketchfab.com/3d-models/ftm-0970f30574d047b1976ba0aa6f2ef855, by Sketchfab user luyssport, used under CC Attribution-NonCommercial-ShareAlike: https://creativecommons.org/licenses/by-nc-sa/4.0/

The shader Cesium is generating:

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;
uniform float gltf_u_dec_normal_rangeConstant;
vec3 gltf_a_dec_normal;
uniform float gltf_u_dec_color_0_normConstant;
uniform vec3 gltf_u_dec_color_0_min;
vec3 gltf_a_dec_vertexColor;
attribute vec4 a_tangent;
attribute vec3 a_normal;
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
attribute vec3 a_position;
attribute vec2 a_texcoord_0;
varying vec2 v_texcoord_0;
attribute vec4 a_vertexColor;
varying vec4 v_vertexColor;
void gltf_decoded_COLOR_0() 
{
    vec3 weightedPosition = gltf_a_dec_position;
    vec4 position = vec4(weightedPosition, 1.0);
    position = u_modelViewMatrix * position;
    gl_Position = u_projectionMatrix * position;
    v_texcoord_0 = gltf_a_dec_texcoord_0;
  v_vertexColor = gltf_a_dec_vertexColor; // <<< here!
}

void gltf_decoded_NORMAL() {
    gltf_a_dec_vertexColor = gltf_u_dec_color_0_min + a_vertexColor * gltf_u_dec_color_0_normConstant;
    gltf_decoded_COLOR_0();
}

void gltf_decoded_POSITION() {
    gltf_a_dec_normal = czm_octDecode(a_normal.xy, gltf_u_dec_normal_rangeConstant).zxy;
    gltf_decoded_NORMAL();
}

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 czm_depth_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();
}

void main() 
{ 
    czm_depth_main(); 
    czm_vertexLogDepth(u_projectionMatrix * u_modelViewMatrix * vec4(gltf_a_dec_position.xyz, 1.0)); 
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant