Skip to content

Commit

Permalink
restore outline
Browse files Browse the repository at this point in the history
  • Loading branch information
pourtheworld committed Jan 22, 2024
1 parent 910bc6e commit 17979a8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 250 deletions.
11 changes: 8 additions & 3 deletions pkg/ant.outline/outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local bgfx = require "bgfx"
local assetmgr = import_package "ant.asset"

local hwi = import_package "ant.hwi"
local queuemgr = ecs.require "queue_mgr"
local queuemgr = ecs.require "ant.render|queue_mgr"
local R = world:clibs "render.render_material"
local RM = ecs.require "ant.material|material"
local iviewport = ecs.require "ant.render|viewport.state"
Expand Down Expand Up @@ -54,7 +54,7 @@ local function create_outline_queue()
local vr = iviewport.viewrect
world:create_entity{
policy = {
"ant.render|outline_queue",
"ant.outline|outline_queue",
"ant.render|watch_screen_buffer",
},
data = {
Expand Down Expand Up @@ -88,7 +88,7 @@ function outline_system:init_world()
end

function outline_system:update_filter()
for e in w:select "filter_result visible_state:in render_layer:in render_object:update filter_material:in skinning?in" do
for e in w:select "filter_result visible_state:in render_layer:in render_object:update filter_material:in skinning?in outline_info?in" do
if e.visible_state["outline_queue"] then
local mo = assert(which_material(e.skinning))
local ro = e.render_object
Expand All @@ -97,6 +97,11 @@ function outline_system:update_filter()
fm["outline_queue"] = mi
fm["main_queue"]:set_stencil(DEFAULT_STENCIL)
R.set(ro.rm_idx, queuemgr.material_index "outline_queue", mi:ptr())
if e.outline_info then
local outline_scale, outline_color = e.outline_info.outline_scale, e.outline_info.outline_color
fm["outline_queue"]["u_outlinescale"] = math3d.vector(outline_scale, 0, 0, 0)
fm["outline_queue"]["u_outlinecolor"] = math3d.vector(outline_color)
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions pkg/ant.render/visible_state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ local function set_visible_states(vs, s, v)
vs["csm2_queue"] = v
vs["csm3_queue"] = v
vs["csm4_queue"] = v
elseif n == "outline" then
vs["outline_queue"] = v
end

vs[n] = v
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
---
policy:
ant.render|render
ant.outline|outline_info
data:
scene:
s: 0.02
t: {5, 1, 5, 1}
material: /pkg/ant.resources/materials/pbr_stencil.material
material: "/pkg/ant.resources.binary/meshes/Duck.glb|materials/blinn3-fx.material"
mesh: "/pkg/ant.resources.binary/meshes/Duck.glb|meshes/LOD3spShape_P1.meshbin"
visible_state: main_view|selectable
---
policy:
ant.render|render
data:
scene: {}
mesh: "/pkg/ant.resources.binary/meshes/Duck.glb|meshes/LOD3spShape_P1.meshbin"
material: /pkg/ant.resources/materials/outline/scale.material
visible_state: main_view
render_layer: translucent_plane
mount: 1
visible_state: main_view|selectable|outline
outline_info:
outline_scale: 1
outline_color: {1, 0, 0, 1}
4 changes: 2 additions & 2 deletions test/features/pkg/ant.test.features/ecs_define.ecs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import_feature "ant.decal"
import_feature "ant.efk"
import_feature "ant.landform"
import_feature "ant.widget"

import_feature "ant.outline"
system "init_system"
.implement "init_system.lua"

Expand All @@ -23,7 +23,7 @@ DEFINE_TEST "motion_sampler"
DEFINE_TEST "group"
DEFINE_TEST "render_layer"
DEFINE_TEST "canvas"

DEFINE_TEST "outline"
DEFINE_TEST "draw_indirect"

-- NOT work right now
Expand Down
14 changes: 7 additions & 7 deletions test/features/pkg/ant.test.features/test/outline_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ local world = ecs.world
local w = world.w

local util = ecs.require "util"
local common = ecs.require "common"
local ot_sys = common.test_system "outline"

local ot_sys = ecs.system "outline_test_system"

local oueline_prefab
local outline_prefab

function ot_sys.init_world()
oueline_prefab = util.create_instance "/pkg/ant.test.features/assets/entities/outline_duck.prefab"
outline_prefab = util.create_instance "/pkg/ant.test.features/assets/entities/outline_duck.prefab"
--util.create_instance "/pkg/ant.test.features/assets/entities/outline_wind.prefab"
end

Expand All @@ -18,9 +18,9 @@ local kb_mb = world:sub{"keyboard"}
function ot_sys.data_changed()
for _, key, press in kb_mb:unpack() do
if key == "L" and press == 0 then
--TODO: need fix
local ee <close> = world:entity(oueline_prefab.tag['*'][1], "outline_remove?update")
ee.outline_remove = true
local ee <close> = world:entity(outline_prefab.tag['*'][1], "outline_info?update")
ee.outline_info.outline_color = {0, 1, 0, 1}
ee.outline_info.outline_scale = 0.8
end
end
end
195 changes: 0 additions & 195 deletions test/features/pkg/ant.test.features/test/terrain_test.lua

This file was deleted.

31 changes: 0 additions & 31 deletions test/features/pkg/ant.test.features/test/velocity_test.lua

This file was deleted.

0 comments on commit 17979a8

Please sign in to comment.