CesiumGS / CesiumGS/cesium

In CustomShader , normalized values are wrong when the componentType is "UINT8".

Open
#11,092 7 comments 0 reactions 0 assignees View on GitHub
category - 3d tiles type - bug
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

I have a points cloud tileset which has a property named "velocity".
I normalized it and I set the property normalized to true.
![image](https://user-images.githubusercontent.com/1676595/219863863-8ebe76bd-08eb-40fb-8c46-652dec6f2540.png)

But In CustomShader, I got the wrong values.
It seems that the normalized data is not divided by 255.0 before Cesium return result to user;

I got the velocity which was not between min and max;

![image](https://user-images.githubusercontent.com/1676595/219864378-f70654ad-231e-4db3-831f-1b0a28842ae8.png)

I tested the velocity value;
Its value was original * scale + offset;
But it should be original / 255.0 * scale + offset;

[test data: 3dtiles.zip](https://github.com/CesiumGS/cesium/files/10774069/3dtiles.zip)

shader code:

float velocity = fsInput.metadata.velocity;

if(velocity < 25.0)
{
material.diffuse = vec3(1.0, 0.0, 0.0);
material.alpha = 0.9;
}
else
{
material.diffuse = vec3(0.0, 1.0, 0.0);
material.alpha = 0.9;
}

Sandcastle example:

Browser: edge

Operating System: win10

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the attached 3dtiles.zip and the provided CustomShader snippet, then trace how fsInput.metadata.velocity is handled for normalized UINT8 properties. Done means the value is divided by 255.0 before scale and offset are applied, matching the expected normalized range.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.