Skip to main content

Model Outline

Overview

Interaction needs to be shown by the appearance change of the model when a 3D model is selected in the 3D scene. For example, if you want the model silhouette to glow when a model is selected in the game/Editor, it needs to be achieved through Model Outline, as shown below.

Outline

Enabling Model Outline Effects in the Engine

Click Windows (Menu Bar) -> Default Effect to open the Default Effect window in the Editor.

image-20230322150429417

Find Model Outline in the Default Effect window and check Visible to enable the effect.

image-20230323111805201

Select LSceneSettings-1 in the Hierarchy panel, and then check Enable Model Outline under Context Config in the Inspector panel.

image-20230323155938765

Enabling Model Outline by Code

Model Outline can be enabled through code in the game. Obtain the Material List of this model object first, and then enable the outline effect for each material used. To enable the outline, the following four properties need to be set:

  1. To enable outline (OutlineEnable), you need to pass in true or false in the form of a string.
  2. Outline color (OutlineColor).
  3. Outline expand size (ExpandSize), If the given value is 10, then no expand by default.
if nx_name(visual) == "Model" then
if nx_find_method(visual, "GetMaterialNameList") then
local material_table = visual:GetMaterialNameList()

for i = 1, table.getn(material_table) do
visual:SetCustomMaterialValue(material_table[i], "OutlineEnable", nx_string(enable))
visual:SetCustomMaterialValue(material_table[i], "OutlineColor", "0.2, 0.95, 1.0")
visual:SetCustomMaterialValue(material_table[i], "ExpandSize", "0.0")
end
end

Different outline effects can be viewed by setting the related properties of Model Outline in the Default Effect window.

image-20230323112113003

PropertyDescription
VisibleUsed to control whether the outline is visible.
Draw SeamsWhether to enable seams for overlapping parts of the model when drawing multiple outlines.
Pixel SizeThe thickness of the outline.
Depth OffsetThe offset value of the Model Outline during the depth test (This property is used to adjust the depth culling effect).

To use the depth culling effect, select LSceneSettings-1 in the Hierarchy panel first, and then check Enable Outline Depth Culling under Context Config in the Inspector panel.

image-20230323160059110

Displaying Effects

Seam Outline

Disable
Enable

Depth Culling

Disable
Enable