How to set ortho projection / model view matrix without a camera?

I’m trying to create the correct projection and modelview matrix for rendering without a camera.

_orthoCamera is a camera I set up in the scene view. Using the _orthoCamera projection matrix and modelview matrix works but I don’t know exactly how to recreate these. My attempt is the commented code.

//not correct
    //var projection = Matrix4x4.Ortho(-512, 512, -512, 512, 0.3f, 1000);
    //var modelView = Matrix4x4.LookAt(new Vector3(512, 512, -5), new Vector3(512, 512, 0), Vector3.up); //inverse?

    //correct result
    var projection = _orthoCamera.projectionMatrix;
    var modelView = _orthoCamera.worldToCameraMatrix;

    GL.modelview = (modelView);

This is how I set the camera up in the scene.
alt text

Why don’t you just use a disabled camera? It has no overhead and does all the calculations for you. However if you want to create it manually, have a look over here. Setting up a projection matrix works the same regardless of the used engine.

Ended up going with this. Based on this documentation.

var orthoSize = 512f;
var projection = Matrix4x4.Ortho(-orthoSize, orthoSize, -orthoSize, orthoSize, 0.3f, 1000);
var offset = new Vector3(512, 512, -5);
var modelView = Matrix4x4.TRS(new Vector3(-offset.x, -offset.y, offset.z), Quaternion.identity, new Vector3(1,1,-1));