Hello everyone. I am currently working on my 3D game and trying to make weapon rendered on top of other models to prevent clipping. I was able to achieve a somewhat acceptable result but I am curious if a perfect (or better) result can be achieved. The version I came up with renders weapon and hands on top for the points that are clipping but it is inconsistent within itself and depth is not applied properly?
Here is the part on the render script that handles model, weapon and GUI draw:
-- Draw world
render.enable_state(graphics.STATE_DEPTH_TEST)
render.enable_state(graphics.STATE_CULL_FACE)
render.draw(self.predicates.model, draw_options_world)
render.disable_state(graphics.STATE_CULL_FACE)
-- Draw weapon (always visible)
render.set_depth_mask(false)
render.disable_state(graphics.STATE_DEPTH_TEST)
render.enable_state(graphics.STATE_CULL_FACE)
render.draw(self.predicates.weapon, draw_options_world)
render.disable_state(graphics.STATE_CULL_FACE)
render.enable_state(graphics.STATE_DEPTH_TEST)
render.set_depth_mask(true)
-- Draw rest (particles, GUI, etc)
render.enable_state(graphics.STATE_BLEND)
render.draw(self.predicates.weapon, draw_options_world) -- This line ensures when not clipping, rendering is done correctly, otherwise the problem persists even when no clipping is done
render.draw(predicates.tile, draw_options_world)
render.draw(predicates.particle, draw_options_world)
render.disable_state(graphics.STATE_DEPTH_TEST)
render.draw_debug3d()
reset_camera_world(state)
render.draw_debug3d()
reset_camera_world(state)
Any help/tip is appreciated ![]()