Pass:setProjection
EditSets the camera projection. This can set the projection for a single view by giving its index, otherwise the projection will be set for all views. The number of views is determined by the number of array layers in the canvas textures.
The Pass returned by lovr.headset.getPass will have its views automatically configured to match the headset.
Arguments
| Name | Type | Description |
| type | ProjectionType | The type of projection to set. |
| ... | number | Parameters for the projection. |
Returns
Nothing
Arguments
| Name | Type | Description |
| view | number | The index of the view to update. |
| type | ProjectionType | The type of projection to set. |
| ... | number | Parameters for the projection. |
Returns
Nothing
Arguments
| Name | Type | Description |
| view | number | The index of the view to update. |
| matrix | Mat4 | The projection matrix. |
Returns
Nothing
Arguments
| Name | Type | Default | Description |
| view | number | The index of the view to update. | |
| left | number | The left field of view angle, in radians. Positive values are to the left of the view center. | |
| right | number | The right field of view angle, in radians. Positive values are to the right of the view center. | |
| up | number | The top field of view angle, in radians. Positive values are above the view center. | |
| down | number | The bottom field of view angle, in radians. Positive values are below the view center. | |
| near | number | .01 | The near clipping plane distance, in meters. |
| far | number | 0.0 | The far clipping plane distance, in meters. |
Returns
Nothing
Notes
By default, the projection is set by the headset. Each HMD has a specific field of view given by lovr.headset.getViewAngles, and the clipping planes can be customized with lovr.headset.setClipDistance.
Example
function lovr.draw(pass)
-- Orthographic/2D
pass:setProjection('orthographic')
-- 90 degree perspective projection
pass:setProjection('perspective', math.rad(90))
-- Asymmetric, for 1 view
local fov = math.rad(60) / 2
pass:setProjection(1, fov, fov, fov, fov, .1, 0)
-- Copying from headset
for i = 1, lovr.headset.getViewCount() do
local left, right, up, down = lovr.headset.getViewAngles(i)
local near, far = lovr.headset.getClipDistance()
pass:setProjection(i, left, right, up, down, near, far)
end
end