Download

3D Objects with Slate?

I know this has been asked a heap of times for UMG, but has anybody had any luck rendering 3D objects to the HUD via Slate?

I’m working a 3D Radar, purely emissive in terms of lighting etc so I don’t need to access the Lighting from the world - it just needs to be a regular HUD element, with it’s own 3D Transform and support for Sprites etc in it’s own 3D Space. I’m essentially creating a 3D Radar, similar to those you see in flight simulators.

All of the same things apply to Slate. You make an image widget and you give it a material as part of a brush that renders the contents of a SceneCaptureComponent.

https://answers.unrealengine.com/questions/225399/off-screen-rendering.html

The other approach you could take with raw slate would be to completely fake the 3D radar. It would be a 2D widget that would project 3D locations into 2D, and make the needed draw box calls every frame in onpaint of the widget to draw all the sprites at the proper locations.

Thanks Nick, was hoping you’d see this thread.

The second idea of faking everything is what I was leaning towards. While it’s probably more computationally expensive, it’s definitely more flexible and portable, since I don’t have to set up a second level and render targets etc, which could also be more pricey. A self-containing system is more what I’m looking for. I’d much rather be able to drop myself into a blank map and have the Radar working regardless of the mas setup.

This is a screenshot of the Radar I’m trying to emulate below. The wireframe part is a map of the surrounding terrain, which is easy enough to fake, since I can probe the local terrain, create a list of points that use the same faked 3D transform system and use the Line Batcher to draw lines between them. (Much easier to write that than do it of course). It’s all ‘procedural’ so I can generate and transform it as I like, that works fine.

The white ‘lines’ you can see are either the objects height from the terrain beneath it, with the two angled lines representing the players field of view (so they can tell what’s behind/in front of them etc.)

The same is true to the Sprites. I currently have a UWidget* class, which is a sub-class of the UImage, but it ticks. All it’s doing is constantly reducing it’s opacity, updating it’s location and checking what colour it should be and whether it’s visible or not (based on Team / allegiance etc). No idea how this will hold up with several hundred objects in the world, but I’ll just have to wait and find out. Transforming those however should again be easy.

Not the foggiest idea how to handle the arrows at the edge of the radar yet. That’ll have to come later…

The tricky part is the mesh that acts as the compass and forms the base of the radar. In the original game, that is literally a mesh rendered on screen with a specific transform, and what is essentially an ‘emissive’ material. There’s no lighting or anything, it’s just a mesh with a texture applied. Looking through Slate, I can’t find anything that would allow me to load a mesh, then tilt it and re-project the pixels or vertices into screen space and still draw it as a mesh. There’s a ‘Viewport’ class and a couple of others that look interesting, even some stuff on projection matrices, but I’m not sure if that’s what I’m looking for.

The mesh itself rotates (yaws) to stay aligned like a compass, along with all objects on the Radar. Would it perhaps be possible to create a texture, then distort that texture via UV’s, to make it ‘look’ at if it’s a 3D object that spins on one axis? If so, all of that could be done in the material and the rotation driven by a single parameter. That’s probably a question more for Ryan or Daniel… Just wondering if that might be a possibility.

That’s going to be super tricky to fake, occlusion, angling, the slate renderer can only render things with 2D transforms, it’s not going to be able to fake occlusions and the like. For your example image, I’d definitely suggest going the Scene capture component route. My hope is that in the far future we can force the renderer to render a specific actor using the forward renderer, directly onto the backbuffer, but that’s quite a ways off i suspect.

I didn’t even think about Occlusion… good point. Perhaps I’ll do the rest of the system for now without the compass mesh, then see if I even need it or if I can create a compass another way.

I don’t suppose there is anything I can do outside of slate, where I can render an object in a separate pass and slap that on top of the GBuffer is there? I suppose that’s almost doing the same as the Scene Capture then anyway…