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"

What causes materials on a scene proxy to disappear?

I am in the process of removing the bugs from my new Destructible Mesh Editor. The most pressing one is that sometimes the materials disappear from my shattered mesh. This generally only happens when there's more than one.

You can see the effect in this video.

Now, that is rendered by a scene proxy, descended from FSkeletalMeshSceneProxy.

Here's the definition:

 class FDestructibleMeshChunkSceneProxy : public FSkeletalMeshSceneProxy
     FDestructibleMeshChunkSceneProxy(class UDestructiblePreviewComponent *comp);
     virtual ~FDestructibleMeshChunkSceneProxy();
     virtual HHitProxy* CreateHitProxies(UPrimitiveComponent* Component, TArray<TRefCountPtr<HHitProxy> >& OutHitProxies) override;
     virtual void GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const override;
     bool IsChunkSelected(FBoneIndexType BoneIndex) const;
     UDestructiblePreviewComponent *PreviewComp;
     /** Hit Proxy for each bone. */
     TMap<uint8, class HDMEChunk*> HitProxiesByBone;

And the relevant method:

 void FDestructibleMeshChunkSceneProxy::GetDynamicMeshElements(const TArray<const FSceneView*>& Views, const FSceneViewFamily& ViewFamily, uint32 VisibilityMap, FMeshElementCollector& Collector) const
     if (!MeshObject)
     const int32 LODIndex = MeshObject->GetLOD();
     check(LODIndex < SkelMeshResource->LODModels.Num());
     const FStaticLODModel& LODModel = SkelMeshResource->LODModels[LODIndex];
     const FLODSectionElements& LODSection = LODSections[LODIndex];
     check(LODSection.SectionElements.Num() == LODModel.Sections.Num());
     int32 SectionIndex = 1;
     for (int32 SectionIndex=0;SectionIndex<LODModel.Sections.Num();SectionIndex++)
         FSkelMeshSection Section = LODModel.Sections[SectionIndex];
         const FSkelMeshChunk& Chunk = LODModel.Chunks[Section.ChunkIndex];
         const FSectionElementInfo& SectionElementInfo = LODSection.SectionElements[SectionIndex];
         for (int32 ViewIndex = 0; ViewIndex < Views.Num(); ViewIndex++)
             if (VisibilityMap && (1 << ViewIndex))
                 for (FSkelMeshFaceGroup fg : Chunk.FaceGroups)
                     FBoneIndexType BoneIndex = Chunk.BoneMap[fg.Bone];
                     bool bIsSelected = IsChunkSelected(BoneIndex);
                     FMeshBatch& Mesh = Collector.AllocateMesh();
                     Mesh.DynamicVertexData = NULL;
                     Mesh.UseDynamicData = false;
                     Mesh.LCI = NULL;
                     Mesh.bWireframe |= bForceWireframe;
                     Mesh.Type = PT_TriangleList;
                     Mesh.VertexFactory = MeshObject->GetVertexFactory(LODIndex, Section.ChunkIndex);
                     Mesh.bSelectable = IsSelectable();
                     if (bIsSelected)
                         auto SelectionOverrideProxy = new FOverrideSelectionColorMaterialRenderProxy(
                             SectionElementInfo.Material->GetRenderProxy(true, IsHovered()),
                             GetSelectionColor(GEngine->GetSelectedMaterialColor(), true, IsHovered())
                         Mesh.MaterialRenderProxy = SelectionOverrideProxy;
                     } else
                         Mesh.MaterialRenderProxy = SectionElementInfo.Material->GetRenderProxy(false, IsHovered());
                     Mesh.BatchHitProxyId = HitProxiesByBone.Contains(BoneIndex) ? HitProxiesByBone[BoneIndex]->Id : FHitProxyId();
                     Mesh.ReverseCulling = IsLocalToWorldDeterminantNegative();
                     Mesh.CastShadow = false;
                     Mesh.bCanApplyViewModeOverrides = true;
                     Mesh.bUseWireframeSelectionColoring = IsSelected();
                     FMeshBatchElement& BatchElement = Mesh.Elements[0];
                     BatchElement.FirstIndex = fg.StartIndexOffset+Section.BaseIndex;
                     BatchElement.IndexBuffer = LODModel.MultiSizeIndexContainer.GetIndexBuffer();
                     BatchElement.MinVertexIndex = Chunk.BaseVertexIndex;
                     BatchElement.MaxVertexIndex = LODModel.NumVertices - 1;
                     BatchElement.UserIndex = -1;//MeshObject->GPUSkinCacheKeys[Section.ChunkIndex];
                     BatchElement.NumPrimitives = fg.NumTriangles;
                     BatchElement.PrimitiveUniformBufferResource = &GetUniformBuffer();
                     const bool bRequiresAdjacencyInformation = RequiresAdjacencyInformation(SectionElementInfo.Material, Mesh.VertexFactory->GetType(), ViewFamily.GetFeatureLevel());
                     check(Section.TriangleSorting != TRISORT_CustomLeftRight);
                     Collector.AddMesh(ViewIndex, Mesh);
             } else
                 UE_LOG(LogTemp, Log, TEXT("Skipped an invisible piece"));

The same effect happens in the editor, even though that uses an entirely different scene proxy (the original, Epic one, untouched.) The difference is that it flickers there.

So, questions:

What would be causing this effect? Material getting garbage collected? Something else?

How would I debug this?

Product Version: Not Selected
more ▼

asked Apr 16 '15 at 09:51 AM in C++ Programming

avatar image

289 22 131 50

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

1 answer: sort voted first

I had a somewhat similar problem were I was drawing a custom mesh with a scene proxy used in a mesh component, the mesh component had a material property used for rendering. Even when instanced the mesh would only be rendered when overriding these two methods of the mesh component.

 virtual int32 GetNumMaterials() const override;
 virtual UMaterialInterface* GetMaterial(int32 ElementIndex) const override;
more ▼

answered Oct 12 '16 at 11:54 AM

avatar image

6 3

(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