-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial material graph nodes for textures mapped to world uvs
- Loading branch information
1 parent
284c531
commit 5d0d30b
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
mdl 1.7; | ||
|
||
import ::anno::*; | ||
import ::state::*; | ||
import ::tex::*; | ||
|
||
module [[ | ||
anno::version( 1, 0, 0), | ||
anno::display_name("Cesium MDL functions") | ||
]]; | ||
|
||
export float2 world_coordinate_2d(float2 min_world_xy=float2(-5000.0,-5000.0), float2 max_world_xy=float2(5000.0,5000.0)) | ||
[[ | ||
anno::display_name("World Coordinate 2D"), | ||
anno::description("Returns UV coordinates for mapping rasters to world space positions."), | ||
anno::author("Cesium"), | ||
anno::in_group("Cesium functions"), | ||
anno::ui_order(300) | ||
]]{ | ||
// Get the world pos of the pixel | ||
float3 world_pos = state::transform_vector(state::coordinate_internal, state::coordinate_world, state::position()); | ||
|
||
// Return 0-1 UVs based on the min/max world coordinates provided | ||
return float2(0.0,0.0) + (float2(world_pos.x, world_pos.y) - min_world_xy) * (float2(1.0, 1.0) - float2(0.0, 0.0)) / (max_world_xy - min_world_xy); | ||
} | ||
|
||
export float4 lookup_world_texture_float4(uniform texture_2d texture = texture_2d(), float2 min_world_xy=float2(-5000.0,-5000.0), float2 max_world_xy=float2(5000.0,5000.0)) | ||
[[ | ||
anno::display_name("World-mapped texture lookup float4"), | ||
anno::description("Returns float4 from a texture mapped to world UV coordinates"), | ||
anno::author("Cesium GS Inc."), | ||
anno::in_group("Cesium functions"), | ||
anno::ui_order(300) | ||
]] | ||
{ | ||
return tex::lookup_float4( | ||
tex: texture, | ||
coord: world_coordinate_2d(min_world_xy, max_world_xy), | ||
wrap_u: ::tex::wrap_clamp, | ||
wrap_v: ::tex::wrap_clamp); | ||
} | ||
|
||
export color lookup_world_texture_color(uniform texture_2d texture = texture_2d(), float2 min_world_xy=float2(-5000.0,-5000.0), float2 max_world_xy=float2(5000.0,5000.0)) | ||
[[ | ||
anno::display_name("World-mapped texture lookup color"), | ||
anno::description("Returns color from a texture mapped to world UV coordinates"), | ||
anno::author("Cesium GS Inc."), | ||
anno::in_group("Cesium functions"), | ||
anno::ui_order(300) | ||
]] | ||
{ | ||
return tex::lookup_color( | ||
tex: texture, | ||
coord: world_coordinate_2d(min_world_xy, max_world_xy), | ||
wrap_u: ::tex::wrap_clamp, | ||
wrap_v: ::tex::wrap_clamp); | ||
} |