Trying to skew the offset of the Camera viewport. Any help?

Hello!

  1. What do you want to achieve? Keep it simple and clear!
    I want to be able to offset the viewport of the camera, similar to the docking behavior of Roblox Studio. For example, if I have a GUI on the right of the screen, it will skew the camera viewport “center” to the left. I have seen this working with manipulating the 10th and 11th values of the Camera’s CFrame.
    So, CFrame(0,0,0,1,0,0,0,1,0,[X Offset Here],[Y Offset Here],1) is the layout.

  2. What is the issue? Include screenshots / videos if possible!
    No Issues I just need help with finding the proper way to manipulate the vectors.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried looking for a solution on the Developer Hub but I did not find any.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is an example of what I am trying to achieve.
Here is a “normal” Camera Coordinate Frame.

workspace.CurrentCamera.CFrame = CFrame.new(0,2,0,1,0,0,0,1,0,0,0,1) --normal cframe of a camera at 0,2,0 in the 3-D world.

Here is what it looks like:

Here is an example of half the viewport as a “GUI”
This is a camera but with the viewport offset by .6 on the 10th value of the CFrame.

workspace.CurrentCamera.CFrame = CFrame.new(0,2,0,1,0,0,0,1,0,.6,0,1) --cframe offset by .6 on the 10th value of a camera at 0,2,0 in the 3-D world.

I also have a frame with text on it that is taking up the right side of the screen.
Here is what it looks like:

I am wanting the camera to take up to 4 offsets (top offset, left offset, right offset, and bottom offset.)
Any help would be appreciated. Thanks! :slight_smile:

EDIT: Found a thread similar but the thread is unresolved. This might help explain what exactly I am trying to achieve. Link: Screen space camera transformation after perspective projection

4 Likes

I think you can use a ViewPortFrame to do this. Not sure how badly it would hit performance.

1 Like

Sorry, accidentally hit the solution button. I do not want to use the ViewportFrame because they cannot render terrain, and I need to render terrain.
EDIT: Pleeease, Roblox… Add terrain support (rendering from outside its parental structure) for ViewportFrame

Would the CameraOffset vector in humanoids help?

No, because that will offset the camera’s position, but not the camera’s central focal point. It would look like the second image in this thread I mentioned earlier: Screen space camera transformation after perspective projection
As you can see by the picture, since the camera’s central focal point is not at the right, the player looks weird and distorted, it is supposed to look like the one below it.
EDIT: Sorry, accidentally hit the solution button again.

Nevermind; I have decided against this. Thanks to all the people who tried to help contribute.
EDIT: But seriously, Roblox… Add terrain support (rendering from outside its parental structure) for ViewportFrame

2 Likes

Even though you don’t need help anymore I’m still gonna share this cause I think I found the solution.

local cam = workspace.CurrentCamera
local run = game:GetService("RunService")`

-- offsets start to break once you go above .5/-.5
local x_offset = -.5
local y_offset = 0

run.RenderStepped:Connect(function()
cam.CFrame = cam.CFrame * CFrame.new(0,0,0,1,0,0,0,1,0,x_offset,y_offset,1)
end)

EDIT: It’s a local script in StarterGui

This is possible, and it was very recently asked. Please do some more searching before posting!

I answered it there, along with the code necessary:

6 Likes

This is exactly what I was looking for! I might just end up using this after all! Thank you so much!!! I am sorry for the late reply.

1 Like

I’ve tried using this, however it severely distorts the image + I can’t figure out the correct size and position values

Trying to get a similar visual as the OP


and atm having to just manually plug some numbers in and tweak the camera values constantly to get it kinda close to centre but it clearly isnt centered

I know this is 4 years later, but I’m having issues with the text when I use this, for some reason all of the character names, proximity prompts, and also the clouds shift when I use this + trying to get mouse position in 3d doesn’t work

Everything else is fine though