Download

(39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required!

I am trying to use this node to save images and it works perfectly when I play from the editor or standalone game but I am getting crashed when I used this node in the packaged development build.
this is the crashed I m getting:

Exception was “SIGSEGV: invalid attempt to access memory at address 0x15852a000”

Source context from “”

<SOURCE START>
<SOURCE END>

<CALLSTACK START>
UVictoryBPFunctionLibrary::CaptureComponent2D_SaveImage(USceneCaptureComponent2D*, FString) Address = 0x105981ec6 (filename not found) [in UITest]
UVictoryBPFunctionLibrary::Capture2D_SaveImage(ASceneCapture2D*, FString) Address = 0x105982780 (filename not found) [in UITest]
UVictoryBPFunctionLibrary::execCapture2D_SaveImage(FFrame&, void*) Address = 0x1059bc476 (filename not found) [in UITest]
UFunction::Invoke(UObject*, FFrame&, void*) Address = 0x10301f272 (filename not found) [in UITest]

Is there something that I have add to make it work?

Thanks,

Rama Needs Answering Help

Hi lots of great questions!

I’m going to need help answering them all, I have a full UE4 work week ahead of me!

****Just letting you all know I’m not ignoring you! ****

I just have to prioritize stuff I am getting paid for so I can, you know, eat and stuff :slight_smile:

[FONT=Comic Sans MS]:heart:

Rama

Sorry Rama, I will delete my question since is not really related to this thread. Will ask somewhere else.

**Improved Get Vertex Locations of Static Mesh

Now works in Packaged Games**

560b4f2b24fb116ffc5c2ddfd4f04754501ad6c2.jpeg

I have re-written my Get Vertex Positions BP node so that it works in packaged games!


**My C++ Code For You**

See my PhysX wiki for the basic build.cs setup:
https://wiki.unrealengine.com/PhysX,_Integrating_PhysX_Code_into_Your_Project

Here is the code I wrote to get all of the transformed vertex positions using the Body Instance and PhysX code!

I am doing many safety checks to ensure the Body Instance data is valid before utilizing it, and the result is that now you can get accurate vertex locations in packaged games!



```


//~~~ PhysX ~~~
#include "PhysXIncludes.h"
#include "PhysicsPublic.h"		//For the ptou conversions
//~~~~~~~~~~~

//Get Transformed Vertex positions of any static mesh! -Rama
bool UVictoryBPFunctionLibrary::GetStaticMeshVertexLocations(UStaticMeshComponent* Comp, TArray<FVector>& VertexPositions)
{
	
	if(!Comp || !Comp->IsValidLowLevel()) 
	{
		return false;
	}
	//~~~~~~~~~~~~~~~~~~~~~~~
	
	//Component Transform
	FTransform RV_Transform = Comp->GetComponentTransform(); 
	
	//Body Setup valid?
	UBodySetup* BodySetup = Comp->GetBodySetup();
	
	if(!BodySetup || !BodySetup->IsValidLowLevel())
	{
		return false;
	}  
	
	//Get the Px Mesh!
	PxTriangleMesh* TriMesh = BodySetup->TriMesh;
	 
	if(!TriMesh) 
	{
		return false;
	}
	//~~~~~~~~~~~~~~~~
	
	//Number of vertices
	PxU32 VertexCount 			= TriMesh->getNbVertices();
	
	//Vertex array
	const PxVec3* Vertices 	= TriMesh->getVertices();
	
	//For each vertex, transform the position to match the component Transform 
	for(PxU32 v = 0; v < VertexCount; v++)
	{ 
		VertexPositions.Add(RV_Transform.TransformPosition(P2UVector(Vertices[v])));
	}
	
	return true;
} 


```





**UE4 Wiki, Plugin Download Page**
https://wiki.unrealengine.com/File:VictoryPlugin.zip

Enjoy!

:)

Rama

Rama’s Instanced Static Mesh Creator, as BP Nodes!

Dear Community,

Hi everyone!

So I have an immediate solution for the issues people are having with instanced static mesh actors working in packaged games!

I’ve created two BP nodes that let you easily specify which actors you want to convert to Instanced Static Mesh Actors at runtime!

This means that while in the editor, the actors are independent and can be moved around normally (the main advantage I sought to achieve with my ISM editor mode).

But once runtime starts, you can run my BP node to convert all the actors of a specified blueprint/class to instanced static mesh actors!

The other node lets you quickly and easily iterate over all Victory Instanced Static Mesh Actors (VictoryISM) that have been created during runtime!


**Make Dynamic Level Generation Super-Efficient!**

When dynamically generating levels your level unit size has to get smaller the more detailed and varied you want the levels to be. This means that for detailed dynamically generated levels, you usually end up with a very high actor count!

**Well using my two new BP nodes, you can make dynamic level generation super-efficient** by turning 100s of actors sharing the same static mesh asset into a single static mesh!

Remember, the scaling, rotation, and translation of the static meshes can be anything you want!

Two New Advantages For You

The two new advantages of this new system are:

a. You can use my BP nodes with actors that you have created yourself at runtime, such as for dynamically generated levels, MAZES, and such

b. This system will work with packaged games, since the instanced static mesh components do not need to serialize properly (as they currently dont seem to be doing). The serialization/cooking process becomes irrelevant since the actors are only converted to Instanced Static Mesh Actors at level start!


**Use of TMap, One Instanced Static Mesh Per Static Mesh Asset**

I use a C++ TMap to group all the actors of the class you specify, and create as many instanced static mesh actors as are required.

Each Instanced Static Mesh Actor can only represent actors that **share the same static mesh asset**, so I group all the found actors by their static mesh asset!

Here's the code where I do this!



```


**//I want one array of actors for each unique static mesh asset!  -Rama**
TMap< UStaticMesh*,TArray<AActor*> > VictoryISMMap;

**//Note the ActorClass filter on the Actor Iterator! -Rama**
for (TActorIterator<AActor> Itr(World, ActorClass); Itr; ++Itr)
{
	**//Get Static Mesh Component!**
	UStaticMeshComponent* Comp = Itr->FindComponentByClass<UStaticMeshComponent>();
	if(!Comp) continue; 
	if(!Comp->IsValidLowLevel()) continue;
	//~~~~~~~~~
	
	**//Add Key if not present!**
	if(!VictoryISMMap.Contains(Comp->StaticMesh))
	{
		VictoryISMMap.Add(Comp->StaticMesh);
		VictoryISMMap[Comp->StaticMesh].Empty(); //ensure array is properly initialized
	}
	
	**//Add the actor!**
	VictoryISMMap[Comp->StaticMesh].Add(*Itr);
}


```



Then, I loop over the TMap, and access the Array of actors that I created that all share the same Static Mesh asset, and then turn the whole lot of them into a single Instanced Static Mesh Actor!



```


**//For each Static Mesh Asset in the Victory ISM Map**
for (TMap< UStaticMesh*,TArray<AActor*> >::TIterator It(VictoryISMMap); It; ++It)
{
	**//Get the Actor Array for this particular Static Mesh Asset!**
	TArray<AActor*>& ActorArray = It.Value();
	
	**//No entries?**
	if(ActorArray.Num() < 1) continue;
	//~~~~~~~~~~~~~~~~~~
	  
	**//Get the Root**
	UStaticMeshComponent* RootSMC = ActorArray[0]->FindComponentByClass<UStaticMeshComponent>();
	if(!RootSMC) continue;
	//~~~~~~~~~~
	
	**//Gather transforms!**
	TArray<FTransform> WorldTransforms;
	for(AActor* Each : ActorArray)
	{
		WorldTransforms.Add(Each->GetTransform());
		 
		//Destroy original?
		if(DestroyOriginalActors)
		{
			Each->Destroy();
		}
	}
	  
	**//Create Victory ISM**
	FActorSpawnParameters SpawnInfo;
	SpawnInfo.bNoCollisionFail 		= true; //always create!
	SpawnInfo.bDeferConstruction 	= false;
	 
	AVictoryISM* NewISM = World->SpawnActor<AVictoryISM>(
		AVictoryISM::StaticClass(), 
		RootSMC->GetComponentLocation() ,
		RootSMC->GetComponentRotation(), 
		SpawnInfo 
	);
	
	if(!NewISM) continue;
	//~~~~~~~~~~
	
	**//Mesh**
	NewISM->Mesh->SetStaticMesh(RootSMC->StaticMesh);

	**//Materials**
	const int32 MatTotal = RootSMC->GetNumMaterials();
	for(int32 v = 0; v < MatTotal; v++)
	{
		NewISM->Mesh->SetMaterial(v,RootSMC->GetMaterial(v));
	}
	 
	**//Set Transforms!**
	for(const FTransform& Each : WorldTransforms)
	{
		NewISM->Mesh->AddInstanceWorldSpace(Each);
	}
	
	**//Add new ISM!**
	CreatedISMActors.Add(NewISM);
}

**//Clear memory**
VictoryISMMap.Empty();


```



Easy to Edit, High Performance at Runtime!

The result of using my BP nodes to turn all actors of a certain class to instanced static mesh actors is that you can now maintain easy editing of the actors while in the editor, and during game-time still gain the performance advantages of converting a large number of actors that share the same static mesh asset into a single actor!

You can also now convert the large quantity of actors in dynamically generated levels into high performance instanced static mesh actors!

[FONT=Comic Sans MS]:heart:
Rama

Oh that’s great! Going to test it now. Is this in the March 25th download? Also does it make sense to just point it at all static mesh actors, or should a new actor subclass be made just for the ones to turn into instances?

Thank you as always!

The new node looks great!

I tested it out though, and while I see the number of Victory ISM objects in the world outliner that I would expect, I am not seeing any change in performance whatsoever(from what used to be 30K instances down to ~4). I already PM’ed Rama about it, but I would be interested to see what other people are experiencing.

In your pm you mention that lots of foliage actors are involved, that could be complicating the matter, I look forward to hearing of other people’s tests as well!

Rama

Does the April 1st build show up for you?

That’s the build that has the latest addition!

Also yes you do want to make a subclass / Blueprint just for the actors that you plan to merge together, that is how you control which actors my BP node iterates over!

Have fun!

:slight_smile:

Rama

Nice, can’t wait for the node that will allow me to access external files like textures in a packed game.

I am using this node “Load Texture 2D From File!” and it is working perfectly. Only issue is when I m loading 1920x1080 resolution image, it increase Texture Memory by 18 to 20mb per image even if image size is couple of mb. Is there a way that I can compress the Texture after it is loaded in as I am loading around 60 to 100 images at runtime, texture memory goes over its budget and some of the in game streaming texture are not able to load properly.

Thanks,

No latest shows 25th March

A question for you also, what are the conditions aside from StaticMesh must be same for Instanced Mesh to work? Does Material play a role, scale perhaps? Thank you.

Actually, RE: Zeus’ post, they aren’t foliage actors, they are speedtree static meshes. 4 unique meshes, about 2-3K polys, no wind, collision, or bones. I removed the speedtree vertex part of the material to get it working with Z’s spherical projection, so it’s not even doing the smooth LOD. It’s just a plain mesh really which is why I’m surprised it’s having such poor performance. Would it be better to import it from an FBX file instead of the speedtree importer?

J^2

P.S. Is there a Mac version of the plugin I can grab?

Initial tests on Instanced Meshes using VictoryPlugin was same for me, no difference in performance. The Stats panel does see only 1 use of each SM so it is working …

Got it working, and have to agree, not seeing any jump in performance so far. Could it be because the original static meshes are loaded initially anyway, even if they get destroyed and replaced?

Thanks! I will try that out :slight_smile:

Further Instanced Static Mesh Testing

Anyone who has mac could post a mac version of the plugin by adding a single C++ file to the editor and compiling their project.

:slight_smile:

If someone does this and doesnt know where to post it they can PM me and I can post it :slight_smile:

That’s odd, can you confirm that if you use my Editor plugin method instead, which deletes the static mesh actors from the editor world, that there is indeed a performance improvement?

I’ve noticed performance improvements using the editor plugin method, and would be interested to know if you can get a contrasting experience bdtween

  1. the BP node method
  2. the editor plugin method which uses i and SHIFT + i to create/restore the instanced static mesh actor

The problem with #2 is that it does not package, which is why I created solution #1.

Multiple people have reported performance benefits from #2.

So the goal is to find a way to get #1 to cause the same performance gains.

But if anyone can get a scenario going where they see performance gains via #2 and not from #1 that would be great intel

:slight_smile:

Rama

I dont know of a way to compress the texture in memory, no, I hope Epic can help you with this goal.

Once the UTexture2D is loaded from hard disk that is the extent of my ability to easily have control over how it is managed.

If anyone knows of / chooses to research further changes that can be made to the UTexture2D after it has been loaded from file data, to reduce memory footprint, let me know!

Have fun today everyone!

:slight_smile:

Rama

29133cff34e19b6d5f6450f26dd03f0fbc0104a7.jpeg

Get a Hard-drive accurate listing of all Save Game Objects!

Dear Community,

I’ve released a new node that gives you a hard-drive accurate listing of all save game files that you’ve created!

I am referring to UE4’s Save Object system!

You can now access a full listing in a developer build or in a packaged game, to know all the save files that have been saved!

These save files are stored in GameDir/Saved/SaveGames

26bed6e9726e2f5bd0c108371726fef9d0d800a1.jpeg


**UE4 Blueprint Save System?**

If you did not know, you can use UE4's save system like this:

1. Create a new blueprint based on SaveGame
2. Add your variables to the blueprint that you want to save the values of
3. in level BP or some other blueprint, create a save game object, and set the values of that object
4. Save this object to a Save Game Slot, as shown in my pictures
5. You can load a save game object from a Slot name at any time!

6.** Now with my new Victory BP Library, you can obtain a full listing of all existing save games as stored on your computer's hard disk! **This let's you know whether a file exists before you try to load it! You can also find out how many save files exist from within BP!

Most Recent Plugin Download From UE4 Wiki

Enjoy!

:slight_smile:

Rama

Thanks for the help. I am looking into source code of how unreal import Texture assets. If I find any solution I will post it here.
And awesome work creating this great plugin.

Thanks,