yzt
2023-05-26 de4278af2fd46705a40bac58ec01122db6b7f3d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// This stage is only applied for Feature ID vertex attributes.
// If Feature ID textures are present, those are used in the fragment shader.
void featureStage(inout Feature feature)
{
    float featureId = FEATURE_ID_ATTRIBUTE;
 
    if (featureId < model_featuresLength)
    {
        vec2 featureSt = computeSt(featureId);
 
        feature.id = int(featureId);
        feature.st = featureSt;
        feature.color = texture2D(model_batchTexture, featureSt);
    }
    // Floating point comparisons can be unreliable in GLSL, so we
    // increment the feature ID to make sure it's always greater
    // then the model_featuresLength - a condition we check for in the
    // pick ID, to avoid sampling the pick texture if the feature ID is
    // greater than the number of features.
    else
    {
        feature.id = int(model_featuresLength) + 1;
        feature.st = vec2(0.0);
        feature.color = vec4(1.0);
    }
}