by baggers
Βloody hell, nearly missed it agian. Ok so it's been a crazy couple of weeks on this.
First off, this is working
The code on the left is goraud shading for the dude on the right. This code makes use of the new 'spaces' feature I have been working on for the last couple of months so I'm stoked to see even this simple an examples.
I now have 8 new repos on github:
https://github.com/cbaggers/cepl.examples - example code for cepl
https://github.com/cbaggers/cl-game-math - maths for games (and other realtime stuff)
https://github.com/cbaggers/structy-defclass - unify defclass and defstruct syntax
https://github.com/cbaggers/skitter - event system
https://github.com/cbaggers/grab-bag - optimized pools
https://github.com/cbaggers/hasty - entity component system backed by grab-bag
https://github.com/cbaggers/dendrite - start of media generation library
https://github.com/cbaggers/lark - toy engine made using a lot of this stuff above
A good number as just taking things out of cepl itself and packaging them separately. This is all stuff that needs doing before Ι can say cepl is in beta.
Cepl has been in an accretion phase for a while, testing things has required some basics (simple model loading, simple event system, etc). Even though those don't really belong in cepl, they have lived there because I needed to get the feeling of what this would be like to work with; with that info I then get to see what is essential and what is better expressed as a composition of something more primitive.
I have been doing a lot of bug-fixing on the spaces feature especially around implicit uniforms. Implicit uniforms are a feature in my compiler where: if it sees a variable name it doesn't know in the shader, it looks at the global variables in common lisp, if it finds the variable there (and can guess it's type) it adds code to take that global variable and upload it as a uniform.
This turns out to be really nice in the case of my fundamental spaces. Ι have some globals *world-space*
*clip-space*
*ndc-space*
*screen-space*
which as you can imagine hold definitions of the spaces with the same name. You can then use these global in your shader code without having to explicitly write them as uniforms (see the picture at the top for an example).
note:the * either side of the names is a common lisp style thing, it means it a global (actually a special, which is a global with dynamic scope)
The result of this has been a massive relief, namely it feels really nice to work with. I've been going through the arcsynthesis tutorials again using the new feature and it has been really nice to think about the problem and not the matrix. The guy who wrote that tutorial had a great habit of pushing you to do the calculations in different spaces so you get a feel for them. This time round it has been nice to read "we are going to do this in clip space"
and know that in my code that means (in *clip-space* ....)
.
I also had a fun problem when converting from screen-space or ndc-space back to spaces like clip-space, world space etc. The transform for screen-space -> clip-space cannot be expressed as a matrix, only a function so it couldn't be handled by my space's routing system in the state it currently is. One possible fix was to return a function instead of a matrix but then it meant that the function signature would be something like:
space space -> (or matrix4 function)
Which then means you need to check for what you got at runtime, which is going to hurt performance. It gets even worse on the gpu side where if
statements really do shit all over your performance.
So instead Ι decided to say that you can't pass *screen-space*
or *ndc-space*
as a variable, but instead have to name it explicitly. It turns out that this feels good, and also solves the issue as a compiler pass can just add in the function call that is needed to get from *screen-space*
to whatever the other space is.
In other news Ι have improved the api for making UBOs. Now you can just write: (make-ubo data 'data-type)
e.g.
(make-ubo (v! 0 1 2) :vec3)
And you get a valid ubo you can pass as a uniform to your shaders.
I have also got all the old cepl examples working on the new branch and now need to focus on documentation and better error messages.
You can find the WIP documentation at https://github.com/cbaggers/cepl/tree/feature-errors/docs/jungl
That's enough for now, seeya next time