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

Fixed rendering base color textures that contain an alpha channel #735

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### v0.23.0 - 2024-10-01

* Fixed bug where tilesets and raster overlays were not being passed the correct custom ellipsoid.
* Fixed rendering base color textures that contain an alpha channel.

### v0.22.0 - 2024-09-03

Expand Down
17 changes: 13 additions & 4 deletions exts/cesium.omniverse/mdl/cesium.mdl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ float4 alpha_blend(float4 src, float4 dst) {
float4 compute_base_color(
color base_color_factor,
float base_alpha,
bool has_base_color_texture,
float4 base_color_texture,
float4 raster_overlay,
float4 tile_color,
Expand All @@ -61,10 +62,17 @@ float4 compute_base_color(
if (alpha_clip > 0.5) return float4(0.0);

auto base_color_factor_float3 = float3(base_color_factor);
auto base_color_factor_float4 = float4(base_color_factor_float3.x, base_color_factor_float3.y, base_color_factor_float3.z, base_alpha);

float4 base_color;

if (has_base_color_texture) {
base_color = base_color_texture;
base_color *= base_color_factor_float4;
} else {
base_color = base_color_factor_float4;
}

auto base_color = float4(1.0);
base_color = alpha_blend(base_color_texture, base_color);
base_color *= float4(base_color_factor_float3.x, base_color_factor_float3.y, base_color_factor_float3.z, base_alpha);
base_color *= scene::data_lookup_float4("COLOR_0", float4(1.0));
base_color = alpha_blend(raster_overlay, base_color);
base_color *= tile_color;
Expand Down Expand Up @@ -1536,7 +1544,8 @@ export material cesium_internal_material(
auto base_color = compute_base_color(
base_color_factor,
base_alpha,
base_color_texture.valid ? base_color_texture.value : float4(0.0),
base_color_texture.valid,
base_color_texture.value,
raster_overlay.valid ? raster_overlay.value : float4(0.0),
tile_color,
alpha_clip.valid ? alpha_clip.value.x : 0.0
Expand Down
Loading