Skip to content

Commit

Permalink
Merge pull request #735 from CesiumGS/fix-alpha-textures
Browse files Browse the repository at this point in the history
Fixed rendering base color textures that contain an alpha channel
  • Loading branch information
lilleyse authored Oct 1, 2024
2 parents dab0d0d + 912e682 commit 60aa7b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
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

0 comments on commit 60aa7b2

Please sign in to comment.