Nathan-Hutton / solar-system

1 stars 0 forks source link

Combine the matrices in the vertex shader into one matrix before passing to the vertex shader #17

Closed Nathan-Hutton closed 4 days ago

Nathan-Hutton commented 1 week ago

I currently pass the view, projection, and model matrix to the vertex shader as uniform variables then do this: gl_Position = projection view model vec4(pos, 1.0); It is more common and more efficient to just pass one uniform variable matrix, like modelToClip, to the shader and just do: gl_Position = modelToClip vec4(pos, 1.0);

Nathan-Hutton commented 1 week ago

The projection matrix will need to not just be stored in main.cpp but in Renderer.cpp as well. renderObjectsVector may need to take in the view matrix (reference) as a parameter to do this, and it could just use the projection matrix without it being a parameter since it will likely be a global variable. One way to further optimize this would be to multiply view and projection immediately as view is calculated, and pass that result to renderObjectsVector since view (and obviously projection) will be the same for each rendering cycle whereas model will not be.

Nathan-Hutton commented 4 days ago

Fixed with commit #c9aa227