question

Mark S3 avatar image
2 Likes"
Mark S3 asked Mark S3 commented

How can I close the shadows on certain objects ?

In "Global Preferences",I checked the "Use Shadows" box.But in my model,I want certain objects not to use shadows, and certain objects to use shadows.How can I close the shadows on certain objects ?

FlexSim 18.2.2
shadows
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Mark S3 commented

You can also use the fglinfo() command to determine if you are in the draw pass rendering into the shadow map.

if (fglinfo(FGL_INFO_SHADERTYPE, view) == SHADERTYPE_RENDER_SHADOWS)

If you hide the shapes so that they aren't drawn during the shadow map pass, then they will not cast shadows (but they will still be affected by the view's lighting).

Attached is an example model that has an object with an array label pointing at other objects to hide during the shadow draw pass.

shadowcontroller.fsm

Note that the switch_hideshape() code is on a separate object (ShadowController) than the objects that it is hiding. If you try to hide and show an object from its own draw trigger, then it will stay hidden because it will no longer fire its own On Draw trigger after being hidden.

Also, the ShadowController object needs to be below the objects it is controlling in the tree so that its On Draw trigger is fired before they are drawn. So set the rank of the object to be last in your model.


shadowcontroller.png (434.1 KiB)
shadowcontroller.fsm (109.0 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Mark S3 avatar image Mark S3 commented ·

@phil.bobo,@jordan.johnson Both of your methods can all work. Thank you for your help!

1 Like 1 ·
Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Phil BoBo edited

You can make an object luminous. Then it won't use lighting or shadows:

treenode object = model().find("Processor1");
assertattribute(object, "drawflags", DATATYPE_NUMBER);
rebindobjectattributes(object);
set(drawflags(object), get(drawflags(object)) | DRAW_FLAG_LUMINOUS);
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.