Download

Create a scene and render it to a texture at runtime?

I asked this question over at answers, but I figured I’d post it here too incase anyone on the forums has any ideas:
https://answers.unrealengine.com/questions/76733/create-a-scene-and-render-it-to-a-texture-at-runti.html

I know that the scene capture component is able to capture the scene that the player is currently in and display its view on a texture. I’m curious if it is possible to create a separate scene not visible to the player, but have that scene render to a texture in the player’s scene.

Does that make sense?

Have you seen this tutorial by TeslaDev? It goes over how to create a camera and render it’s image onto a plane in the world, I think that’s what you mean? Here it is:

https://www.youtube.com/watch?v=jWRkM-95k2I&list=UU3QBWg9pMnaFF-q0qjXPDEg

Hope that helps! :slight_smile:

I have seen that tutorial.

What I want to do differently is not to use the scene that the player currently resides in, but make an independent scene that is just used to render out a cube and then present that to the player on the texture, just like he renders the scene component to the texture in his tutorial.

I’m not sure which would be best for your situation (depends on the size of your actual level, and the size of the camera’s level whether this would not hurt performance) but this could be one way of doing it:

If the scene is just a small one, you could potentially build it underneath your actual level so the player would never see it, place the camera setup in there, and then render the camera’s view to a texture in your actual game world. If you want each side of the cube to show a different view, you could change the UV map so that each side get’s it’s own texture, then place 4 cameras close together pointing in opposite directions (north, east, south, west or whatever works best for you), and make each cameras output correspond to each of the textures.

Would that be more what you are looking for?

I was thinking about a solution like that, but you’d have to take lighting and other environment variables into consideration when rendering.

I was hoping that I could setup a fresh scene with nothing but the lighting for the cube and the scene capture and then have that render out instead of trying to put it all into the same scene.

Yeah, I was thinking that as well (wasn’t sure if it was indoor or outdoor scene).

Another option might be to look into level streaming through the new World Composition tool, I would need someone else to confirm if this is possible, but you may be able to create 2 levels side by side, but have the world browser not render the level to the player. The reason I didn’t bring this up before is I am unsure whether you could set the level as “do not render” but only have that affect the players camera, and have the other cameras set to view only the camera level.

I don’t think it will work as I stated out of the box, but there may be a way to customize this for your idea (if you are using C++ I am sure it is possible, not sure using blueprints). I don’t think this would work initially simply because not rendering it, will not render to any camera period. However there may be a setting I am unaware of, so I thought I would post this in case anyone else knows the answer. For more info on the new level tool see here:

Maybe that would be a way to go if you can get it working.

That might be a place to look.

I found classes like FPreviewScene, which I thought I could use, but there is a lot of ground work to do to make it render out. Since this is primarily used by the editor, I’m also not sure that it will work at runtime.

Loading a separate level instance not attached to current world is useful.
Whether UE4.19 supports this feature now?