Godot Version
4.4
Question
Yes I know that doing that will distort the screen.
I don’t know how it works in Unity, but at least it did in Unreal.
Mahan
February 13, 2025, 10:47am
2
Godot uses the page dimensions for the 3D camera; if you want the camera ratio to change, you must change it.
Perhaps doing so would cause the rendering resolution to be different from the screen resolution?
Mahan
February 13, 2025, 11:58am
4
I have never tried changing the dimensions of the viewport with code at runtime, so I’m not sure how it will work, but I have another idea: you can have a viewport linked to the camera, then adjust the dimensions of the viewport and make the surrounding area black (if that’s what you want to happen for the empty space), so only the parts of the view that are consistent will be displayed. I use this to show multiple angles at the same time, and I think it will work for you too.
Thank you for replying.
I think that solution does not solve my case.
Because my game is pixel based game and I want to show pixel-perfect.
I need to set aspect ratio to 16.0 / 9.0 / sqrt(2.0)
Is this right?
Calinou
February 13, 2025, 2:20pm
6
This is not supported in 3D yet:
opened 08:47PM - 11 May 21 UTC
topic:core
topic:rendering
topic:3d
### Describe the project you are working on
I'm working on a portal plugin.
… ### Describe the problem or limitation you are having in your project
I need to use oblique frustum projection to allow for the portals' cameras to clip content that's behind the portal plane. Which is currently impossible in Godot.
### Describe the feature / enhancement and how it helps to overcome the problem or limitation
The enhancement would be to add a new projection mode, PROJECTION_CUSTOM to the Camera class, which would allow the developer to directly set the matrix to be used for projection. For my specific case, that would allow me to use oblique frustum projection. It would also address any other projection that any developer could want to use. And it would probably allow for some weird distortion effects as well.
Also, if a new projection is added with a CameraMatrix exposed to the user, it would make sense to migrate the entire Camera class and camera rendering to work with a CameraMatrix object belonging to each Camera instead of calculating the matrices from the Cameras' parameters.
### Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
I think this can be done in a few steps:
1. Make CameraMatrix or other 4x4 matrix type available to user code
1. Register CameraMatrix so that it is accessible to user code
2. Add CameraMatrix to the documentation
2. Change the Camera class to allow for custom matrices
1. Add a CameraMatrix object to the Camera class (could be named projection_matrix)
2. Add updating the matrix when a parameter is changed (fov, near, far, etc.) by modifying the appropriate item in the matrix
3. Add updating the matrix when the projection mode is changed by using the already existing methods in the CameraMatrix struct
4. Add PROJECTION_CUSTOM to the Projection enum
5. Add the CameraMatrix to the Camera's properties
3. Replace steps like [this one](https://github.com/godotengine/godot/blob/e2a2138d2bcd5f5f5c7dde8d9371c62192d459f1/servers/rendering/renderer_scene_cull.cpp#L2439) in the rendering process with getting the camera's projection matrix.
4. Add necessary methods to either Camera3D or CameraMatrix to replace the functionality that calculating the matrix when necessary provided (e.g. setting the aspect ratio). So that the matrix doesn't have to be completely remade
5. Update Camera3D and possibly RenderingServer documentation
6. XR wizardry I cannot comprehend.
Here's a little mockup:
 

### If this enhancement will not be used often, can it be worked around with a few lines of script?
Most definitely not
### Is there a reason why this should be core and not an add-on in the asset library?
It requires considerable (although not very invasive) changes to two core classes and the rendering system.
However, you can do it in 2D by using Camera2D’s zoom
property where X can be set separately from Y.
If you want the entire viewport’s rendering to be stretched, use the canvas_items
stretch mode and ignore
stretch aspect in the Project Settings and resize the window to have a different aspect ratio from the base viewport size. However, this will also stretch 2D/UI rendering.
Thank you.
I’ll think another solution.
system
Closed
March 15, 2025, 11:45pm
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.