Skip to content

Commit

Permalink
translucent primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Aug 27, 2024
1 parent 54d077c commit fade971
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/ant.framework.demo/primitive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@ end

function primitive.new(world, name, obj)
local mat = obj.material
local trans
if mat == nil then
mat = { visible = true }
obj.material = mat
elseif mat.color then
trans = (mat.color >> 24) > 0
end
local render_layer
local material = "/pkg/ant.resources/materials/primitive.material"
if trans then
render_layer = "translucent"
material = "/pkg/ant.resources/materials/primitive_translucent.material"
end
local eid; eid = world:create_entity {
policy = {
"ant.render|render",
},
data = {
scene = {},
material = "/pkg/ant.resources/materials/primitive.material",
scene = {},
render_layer = render_layer,
material = material,
visible_masks = "main_view|cast_shadow",
visible = mat.visible,
visible = mat.visible,
cast_shadow = true,
receive_shadow = true,
mesh = name .. ".primitive",
mesh = name .. ".primitive",
on_ready = function ()
obj.eid = eid
obj.material = monitor.material(world, { eid })
Expand Down

0 comments on commit fade971

Please sign in to comment.