Download

Select Camera, Render, get image?

Hey All,

I’ve been searching for the answer to this question for nearly a week now and am finally posting it to the forums. I have a level with many cameras. Some are attached to players, some are not. A player might have upwards of 10 cameras. I need to select a specific camera from the level, render its current view and grab the rendered output. That output does not need to be displayed to a screen. I just need to grab it in C++ and send it to another location over the network in one of 2 formats. Either a .jpg or 3 channel 2 dimensional array (RGB channels, height, width).

Thanks!

Another solution might be to select a specific camera and broadcast its view across a network as a live stream. (This may be more optimal.)

Have you looked at RenderTargets? They are a material that the camera renders to, then in C++ you can get the color data out of the material. I may have a UE4 snippet of pulling the rgb data from a material still, but it’s on a different workstation, I’ll try to follow up later and add it. I was using a material as a height map, and it worked.

This isn’t exactly what you are looking for, but it is working with color data: https://answers.unrealengine.com/questions/463625/c-updating-texture-data.html

I don’t have code snippet to share, but I did this in UE3 except instead of Rendertarget I took a screenshot from C++ with the camera at the position, orientation, fov etc. that I wanted, then I used DirectX functions in code to manipulate the image further, then sent it in packets over a local network to another UE3 client that saved the packets as .jpegs on it’s local hardrive.

Hope that helps some with direction to look in.

I’ve definitely seen the Render Targets. I was hoping to do this completely headless as well. Not sure if it will work without a screen, but will give it a shot. Seems like the only solution is to use RenderTargets. I don’t actually need to render anything at all to a screen ever. Having a screen is just a nice to have thing for this scenario.

So I’ve got a SceneCapture2D component in the scene, and a Render Target. I’ve created a C++ component and I need to get access to the SceneCapture2D’s Render Target. How does one do this? In Unity its self.gameobject.getcomponent<name>();

(I’m an awesome Unity Dev testing out Unreal Engine to see what this thing has to offer.)

I’ve come up with an idea to create an actor which has a SceneCapture2D* as a property that can be set, from there I grab the RenderTarget and need to grab the 256x256 pixel data. Does anybody know how to do this? This I think is the peice I need.

Got it, I was able to extend the SceneCapture2D class. Any thoughts on how to perhaps dynamically create a new Texture Render Target and set the Render Target in the Scene Capture device programatically?