Closed HKEFU closed 5 months ago
Hi @HKEFU , please supplement the version information, and then provide relevant sandcastle or tileset to help you better track the issue.
It seems that the issue lies in this piece of code: https://github.com/CesiumGS/cesium/blob/db62d077950f4fad4fc73ed50c08144ae724fa90/packages/engine/Source/Scene/Model/PickingPipelineStage.js#L158-L161
The cesium version is 1.116.0。 tileset.zip Please refer to this article。 https://zhuanlan.zhihu.com/p/407871786 @syzdev
Hi @HKEFU. As @syzdev suggested, would you be able to include a Sandcastle example that replicates the issue? That would help us give us more context to determine the issue. Thanks!
Hi @ggetz. This zip file is the sample code, and the video shows this error message.Thanks! example.zip
video url: https://github.com/CesiumGS/cesium/assets/169979994/e3f4f705-2d14-41ce-9865-a533a4fe191f
Hi @HKEFU, I identified a few errors with the linked tileset using the 3D Tiles Validator tool. I'd suggest running the tool and fixing any errors.
What happened?
[Cesium WebGL] Vertex shader compile log: ERROR: 0:72: 'selectedFeature' : undeclared identifier ERROR: 0:72: 'id' : field selection requires structure, vector, or interface block on left hand side ERROR: 0:72: '<' : wrong operand types - no operation '<' exists that takes a left-hand operand of type 'const highp float' and a right operand of type 'highp int' (or there is no acceptable conversion) ERROR: 0:72: 'model_pickTexture' : undeclared identifier ERROR: 0:72: 'selectedFeature' : undeclared identifier ERROR: 0:72: 'st' : field selection requires structure, vector, or interface block on left hand side ERROR: 0:72: 'texture' : no matching overloaded function found ERROR: 0:72: '?:' : mismatching ternary operator operand types 'const mediump float and 'const 4-component vector of float'
Reproduction steps
1. 2. 3. ...
Sandcastle example
No response
Environment
[Cesium WebGL] Vertex shader source:
version 300 es
define HAS_ATMOSPHERE
define COMPUTE_POSITION_WC_ATMOSPHERE
define HAS_NORMALS
define HAS_TEXCOORD_0
define HAS_FEATURE_ID_0
define HAS_SELECTED_FEATURE_ID
define SELECTED_FEATURE_ID featureId_0
define HAS_SELECTED_FEATURE_ID_ATTRIBUTE
define USE_CPU_STYLING
define LOG_DEPTH
define OES_texture_float_linear
define OES_texture_float
line 0
const float czm_infinity = 5906376272000.0;
struct czm_ray { vec3 origin; vec3 direction; };
struct czm_raySegment { float start; float stop; };
const czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);
const czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);
uniform vec3 czm_atmosphereRayleighCoefficient; uniform vec3 czm_atmosphereMieCoefficient; uniform float czm_atmosphereMieScaleHeight; uniform float czm_atmosphereRayleighScaleHeight;
float czm_approximateTanh(float x) { float x2 = x x; return max(-1.0, min(1.0, x (27.0 + x2) / (27.0 + 9.0 * x2))); }
czm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius) { vec3 o = ray.origin; vec3 d = ray.direction;
}
uniform vec2 czm_currentFrustum; uniform mat4 czm_inverseProjection;
void czm_computeScattering( czm_ray primaryRay, float primaryRayLength, vec3 lightDirection, float atmosphereInnerRadius, out vec3 rayleighColor, out vec3 mieColor, out float opacity ) { const float ATMOSPHERE_THICKNESS = 111e3; const int PRIMARY_STEPS_MAX = 16; const int LIGHT_STEPS_MAX = 4;
}
uniform vec3 czm_viewerPositionWC; uniform vec3 czm_sunDirectionWC; uniform vec3 czm_lightDirectionWC;
ifdef LOG_DEPTH
out float v_depthFromNearPlusOne;
ifdef SHADOW_MAP
out vec3 v_logPositionEC;
endif
endif
vec4 czm_updatePositionDepth(vec4 coords) {
if defined(LOG_DEPTH)
ifdef SHADOW_MAP
endif
endif
}
void czm_vertexLogDepth() {
ifdef LOG_DEPTH
endif
}
void czm_vertexLogDepth(vec4 clipCoords) {
ifdef LOG_DEPTH
endif
}
uniform mat3 czm_normal; uniform mat4 czm_modelView; uniform mat3 czm_normal3D; uniform mat4 czm_modelView3D;
struct czm_modelVertexOutput { vec3 positionMC; float pointSize; };
const float czm_passTranslucent = 8.0;
uniform float czm_pass; uniform mat4 czm_model; uniform mat4 czm_projection;
void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) { vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC; vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC); czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
}
uniform float czm_atmosphereDynamicLighting;
vec3 czm_getDynamicAtmosphereLightDirection(vec3 positionWC, float lightEnum) { const float NONE = 0.0; const float SCENE_LIGHT = 1.0; const float SUNLIGHT = 2.0;
}
float czm_round(float value) { return floor(value + 0.5); }
vec2 czm_round(vec2 value) { return floor(value + 0.5); }
vec3 czm_round(vec3 value) { return floor(value + 0.5); }
vec4 czm_round(vec4 value) { return floor(value + 0.5); }
line 0
in vec3 a_positionMC; in vec3 a_normalMC; in vec2 a_texCoord_0; in float a_featureId_0; uniform int model_featuresLength; uniform sampler2D model_batchTexture; uniform vec4 model_textureStep; uniform bool model_commandTranslucent; out vec3 v_atmosphereRayleighColor; out vec3 v_atmosphereMieColor; out float v_atmosphereOpacity; out vec3 v_positionWC; out vec3 v_positionEC; out vec3 v_positionMC; out vec3 v_normalEC; out vec2 v_texCoord_0; out float v_featureId_0; struct ProcessedAttributes { vec3 positionMC; vec3 normalMC; vec2 texCoord_0; float featureId_0; }; struct SelectedFeature { int id; vec2 st; vec4 color; }; struct FeatureIds { int featureId_0; }; struct Metadata { float _empty; }; struct MetadataClass { float _empty; }; struct MetadataStatistics { float _empty; }; void initializeAttributes(out ProcessedAttributes attributes) { attributes.positionMC = a_positionMC; attributes.normalMC = a_normalMC; attributes.texCoord_0 = a_texCoord_0; attributes.featureId_0 = a_featureId_0; } void setDynamicVaryings(inout ProcessedAttributes attributes) { v_texCoord_0 = attributes.texCoord_0; v_featureId_0 = attributes.featureId_0; } void initializeFeatureIds(out FeatureIds featureIds, ProcessedAttributes attributes) { featureIds.featureId_0 = int(czm_round(attributes.featureId_0)); } void initializeFeatureIdAliases(inout FeatureIds featureIds) { } void setFeatureIdVaryings() { } void initializeMetadata(out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes) { } void setMetadataVaryings() { } void atmosphereStage(ProcessedAttributes attributes) { vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_positionWC, czm_atmosphereDynamicLighting);
}
vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal) { vec4 computedPosition;
}
void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) { initializeFeatureIds(featureIds, attributes); initializeFeatureIdAliases(featureIds); setFeatureIdVaryings(); }
void metadataStage( out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes ) { initializeMetadata(metadata, metadataClass, metadataStatistics, attributes); setMetadataVaryings(); }
vec2 computeSt(float featureId) { float stepX = model_textureStep.x; float centerX = model_textureStep.y;
}
void selectedFeatureIdStage(out SelectedFeature feature, FeatureIds featureIds) {
int featureId = featureIds.SELECTED_FEATURE_ID;
}
void filterByPassType(inout vec3 positionMC, vec4 featureColor) { bool styleTranslucent = (featureColor.a != 1.0);
}
void cpuStylingStage(inout vec3 positionMC, inout SelectedFeature feature) { float show = ceil(feature.color.a); positionMC *= show;
}
czm_modelVertexOutput defaultVertexOutput(vec3 positionMC) { czm_modelVertexOutput vsOutput; vsOutput.positionMC = positionMC; vsOutput.pointSize = 1.0; return vsOutput; }
void czm_log_depth_main() {
}
line 0
void czm_non_renderPass_OutlineEffectPass_main() { czm_log_depth_main(); czm_vertexLogDepth(); }
line 0
vec3 packNormalToRGB(const in vec3 normal) { return normalize(normal) * 0.5 + 0.5; }
vec3 unpackRGBToNormal(const in vec3 rgb) { return 2.0 * rgb.xyz - 1.0; }
const float PackUpscale = 256. / 255.; const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3(256. 256. 256., 256. * 256., 256.); const vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.);
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA(const in float v) { vec4 r = vec4(fract(v PackFactors), v); r.yzw -= r.xyz ShiftRight8; return r * PackUpscale; }
float unpackRGBAToDepth(const in vec4 v) { return dot(v, UnpackFactors); }
vec4 pack2HalfToRGBA(vec2 v) { vec4 r = vec4(v.x, fract(v.x 255.0), v.y, fract(v.y 255.0)); return vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w); } vec2 unpackRGBATo2Half(vec4 v) { return vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0)); }
float viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) { return (viewZ + near) / (near - far); } float orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) { return linearClipZ * (near - far) - near; }
float viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) { return ((near + viewZ) far) / ((far - near) viewZ); } float perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) { return (near far) / ((far - near) invClipZ - far); }
uniform sampler2D czm_selectedIdTexture; uniform float czm_selectedIdTextureStep; uniform float czm_selectedIdTextureWidth;
bool czm_selected(vec4 id) { bool selected = false; for (int i = 0; i < 1024000; i++) { vec4 selectedId = texture(czm_selectedIdTexture, vec2((float(i) + 0.5) * czm_selectedIdTextureStep, 0.5)); if(all(equal(id, selectedId))) { return true; } if(float(i) > czm_selectedIdTextureWidth) break; } return false; } out float me_isSelected; bool czm_selected() { return czm_selected(((selectedFeature.id < int(model_featuresLength)) ? texture(model_pickTexture, selectedFeature.st) : vec4(0.0))); }
{ czm_non_renderPass_OutlineEffectPass_main(); me_isSelected = czm_selected() ? 1. : 0.; czm_renderPass_OutlineEffectPass_main(); }