I bring great tidings of screenshots, and descriptions of how fiddling with renderdoc helped me figure out my problem with rendering not working, the tldr was that my shader was borked, and the correct line was above the incorrect line of my shader, but commented out
So we'll start from the beginning, nothing was rendering at all, but of course it's a PBR renderer and there's no lights, so I thought there might be an issue with there being no lights to light up my test cube in the scene. Also there was an issue with not knowing offhand which way my camera started facing, so I had to hack in some camera movement to turn the camera, which worked on paper, but still got me a blank screen.
First I'll back up a bit and explain how the renderer works, since it's part deferred, part forward, and all pain in the butt.
So the rendering happens in a few stages, first the deferred geometry gets rendered to frame buffers with the diffuse, normal, metalness, roughness, ao textures just being written as is to textures on the framebuffer. Then after the geometry is rendered like that, the framebuffer gets swapped out to render to the screen, and the framebuffer with the data is then read to calculate the lighting in a separate draw pass.
After that, anything transparent gets rendered using forward rendering, and then the UI stuff gets rendered on top of that.
So looking in Renderdoc, we see here are the list of calls:
glDrawElements(36) is the call to draw my 3d cube, all those
glDrawArrays(6) calls are drawing text on the screen for the fps counter (yes that is a lot of overhead for an fps counter ) And then that SwapBuffers is the end of the frame where it actually shows stuff on screen.
So that tells me that its actually trying to draw something on screen, so my renderstates stuff works! yay!
So then I looked further into Renderdoc, and me being me, I didn't read a tutorial about it or anything, just started poking around, but the tab I found most useful was pipeline state and mesh viewer. First I looked at the pipeline state and saw this:
I knew that the ao texture didn't have anything there, and I don't expect that to cause issues, and I expected the metallic and roughness to be the same texture, but what I didn't know/expect, was for them to show up as invalid textures.
Lucky for me I had some logging information in my texture loading class that printed out the number of channels in a texture, and sure enough, the improper textures were single channel. The problem there lied in how I was setting up the
glTexImage2D format, I just needed to tweak the format and voila, that was resolved, but still no output.
Next I went to the Mesh view and saw this:
There are a few problems with this, first let's look at the
gl_Position is a vec4, that means it has x, y, z, and w parts to it, but here all the z values for all the points are
-1 that doesn't seem right.
Also notice in the window below, the cube is there, but is behind the camera frustrum. That's strange.
I did a whole bunch of debugging and random testing, moved the camera around and got it to be other z values than -1, but the mesh view still showed the cube as being behind the view frustum and it had a really weird distortion to the cube.
Then I checked my shader code and found this:
//#gl_Position = projection * view * worldPos;
gl_Position = worldPos * view * projection;
Now if you're not familiar with matrix math, I've found the key thing to remember is that you have to do the operations "backwards" so instead of taking the object matrix, multiplying by the view matrix, then by the projection matrix, you have to take the projection matrix, and multiply it by the view matrix, then the object matrix. The order matters, and here I had the correct thing clearly written previously, and then commented out with the backwards order in its place.
Commenting out the incorrect line and uncommenting the correct line then gets me this result in renderdoc:
And this result in engine:
I don't have the camera movement working perfectly, the mouse looks around wayyyy too fast, and I don't have position movement set up yet, but soon I'll hopefully have more to show off. and maybe I can get the camera turned around to default to look at the cube instead of away