I have a problem with deep mask. The ground not rendered after sprite alpha channel.
One way to fix this use different predicates for ground and sprites.Save shelter (old school fps) #CoronaDefoldJam
But i whant to use same material and predicate for ground and sprites.Can i do that?
local MsgReceiver = require "libs.msg_receiver"
local HASHES = require "libs.hashes"
local function set_view_projection(self, message_id, message)
self.view = message.view
self.projection = message.projection
end
local function window_resized(self, message_id, message)
self.gui_projection = vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)
end
function init(self)
self.tile_pred = render.predicate({"tile"})
self.gui_pred = render.predicate({"gui"})
self.text_pred = render.predicate({"text"})
self.particle_pred = render.predicate({"particle"})
self.three_d_pred = render.predicate({"3d"})
self.skybox_pred = render.predicate({"skybox"})
self.clear_color = vmath.vector4(0.5, 0.5, 0.5, 1)
self.clear_table = {[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}
self.view = vmath.matrix4()
self.empty_view = vmath.matrix4()
self.gui_projection = vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)
self.projection = vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1)
self.msg_receiver = MsgReceiver.new()
self.msg_receiver:add(HASHES.MSG_RENDER_SET_VIEW_PROJECTION, set_view_projection)
self.msg_receiver:add(HASHES.MSG_RENDER_WINDOW_RESIZED, window_resized)
end
function update(self)
render.set_depth_mask(true)
render.set_stencil_mask(0xff)
render.clear(self.clear_table)
render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
render.enable_state(render.STATE_BLEND)
render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
--draw 3d walls
render.enable_state(render.STATE_DEPTH_TEST)
render.set_view(self.view)
render.set_projection(self.projection)
-- render.draw_debug3d()
render.draw(self.skybox_pred)
render.draw(self.three_d_pred)
render.disable_state(render.STATE_DEPTH_TEST)
render.set_depth_mask(false)
render.set_projection(self.projection)
render.draw(self.tile_pred)
render.draw(self.particle_pred)
render.draw_debug3d()
render.set_view(self.empty_view)
render.set_projection(self.gui_projection)
render.enable_state(render.STATE_STENCIL_TEST)
render.draw(self.gui_pred)
render.draw(self.text_pred)
render.disable_state(render.STATE_STENCIL_TEST)
render.set_depth_mask(false)
render.draw_debug2d()
end
function on_message(self, message_id, message)
self.msg_receiver:on_message(self, message_id, message)
end