Method to render the entire Viewport with its lighting on a Gui without cloning

I’m not sure if this is a bug, or if this is well known, but I feel this is the best place to document this find. I’ve managed to render the entire users viewport, lighting and all, without cloning a single instance from the Workspace - The CurrentCamera property of the viewport frame isn’t even used!

Tutorial

Start by creating a Part in workspace. From now on, I’ll refer to this part as the “mirror part”. Make it a decent size, and set it’s Material to be Glass. For an accurate depiction of lighting, set its transparency to 0.5:

Next, create a SurfaceGui in StarterGui. Set it’s Adornee property to the “mirror part” created in the previous step. Also create a ViewportFrame inside of your SurfaceGui, and set its BackgroundTransparency to 1:

You’re nearly done: Clone the “mirror part” from the first step, and parent it to the new viewport from the last step. I’ll refer to this part as the “Inner part”. For clarity, rename it to “InnerPart” Also add a LocalScript into the viewport. I recommend setting the position of the “Inner part” to 0, 0, 0:

As for the script, use the following code:

local outerViewport = script.Parent  
local holderPart = outerViewport .InnerPart

local camView = Instance.new("Camera")
camView.CFrame = CFrame.new(
    holderPart.Position - Vector3.new(5, 0, 0), -- Adjust this value as needed. Different values "shift" the Viewport.
    holderPart.Position
)

outerViewport.CurrentCamera = camView

That’s all, join the game and see your entire Viewport be rendered, with your skybox, and lighting!

Examples

Example place: RenderViewport.rbxl (59.3 KB)

9 Likes

Just download your place, that doesn’t work at all, there is not even a viewport doing “a reflection”.

Are sure you upload the correct place ?

i think thats just a bug with a beta feature that break rendering on viewportframe.


i add that this bug is studio only


Yep, just downloaded the place and it all works just fine…

Strange. Looks like we can’t use this for anything useful then.


It’s for sure linked to unified lighting.

1 Like