Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Certain InstancedStaticMeshComponent instances don't render in the correct place when I add and remove instances in realtime?

So this is a very strange bug I'm running into, and would ideally like to find a workaround for in the meantime while it gets fixed in the engine, and would like to provide whatever is necessary to help.

I have an InstancedStaticMeshComponent (ISMC) that I'm adding and removing instances to/from while the game is running based on player input. The problem is, is whenever I remove certain instances, other instances will be rendered at the wrong location.

The most trivial example is as follows, with the returned indexes in brackets: I will add the first instance [0], then the second instance [1], then the third instance [2] I will then attempt to remove the first instance [0] When I do, the third instance [2] starts rendering at the position of the second instance [1].

This is 100% reproducible and doing the same adding/removing sequence always causes the same instance so be rendered in the wrong location at the same points in the sequence.

EXCEPT: If I open the game as a standalone process, the misrendering of instances will change drastically, and instances are not rendered in the wrong places (to my knowledge), they are not rendered at all and only one instance is ever rendered at a time.

FINALLY: If I'm in the editor, I can solve the issue temporarily by going into the ISMC manually and either checking OR unchecking "Use Dynamic Instance Buffer". It does not matter which it is set on before, or by default, simply toggling it causes the instances to render properly in the editor until I add or remove instances again.

Some other notes:

  • This 99% has nothing to do with the changing indexes of ISMCs in general (externally at least, there might be in issue with the fact that indexes change and multiple internal properties of the ISMC depend on those), I'm not using Hierarchical, and have verified using the toggling "Use Dynamic Instance Buffer" method above and verifying the transforms/indexes in the editor that the instances themselves are being removed/added in the spots they should be.

  • I have tried changing the StaticMesh, this happens with every different one I've used.

  • I've marked the Materials used on the StaticMeshes "Use With Instanced Static Mesh" or whatever that setting is.

  • I'm using the Binary Engine installed by the Launcher, 4.17.1

  • All of the adding/removing of instances are being done in C++, during the Tick() function of a subclass of AActor

I'm happy to provide more information, my source in a minimized project, a video, whatever would be helpful, just let me know.

EDIT More information and testing:

  • Toggling "Use Dynamic Instance Buffer" makes the misrendered instances appear correctly even while the game is PAUSED

  • Using a Hierarchical ISMC doesn't fix the issue, but it does change the pattern of the misrendered instances, and when using an HISMC toggling "Use Dynamic Instance Buffer" has no apparent effect.

  • Using the ISMC's MarkRenderStateDirty(), MarkRenderDynamicDataDirty(), MarkRenderTransformDirty(), MarkPackageDirty(), among several other similar functions have no effect, whether called in the Tick function of the ISMC owning actor, or delayed until the actor's next frame Tick

  • Camera position or view, as well as ISMC Visibility, Show In Game, and other general visibility settings have no effect other than to hide the ISMC in its entirety, and when toggled again, causes the ISMC to reappear still having the misrendering issues.

Product Version: UE 4.17
more ▼

asked Sep 18 '17 at 01:36 AM in C++ Programming

avatar image

31 3 4 8

avatar image Akyton Sep 29 '17 at 05:22 PM

As of 4.17.2, this bug still exists.

avatar image Akyton Nov 28 '17 at 09:59 PM

As of 4.18.1, this bug still exists, except now checking and unchecking "Use Dynamic Instance Buffer" doesn't do anything or fix the misrendered instances.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Fixed in 4.19

more ▼

answered Nov 15 '18 at 09:28 PM

avatar image

31 3 4 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question