Minor 3d update!
Ok, a little update on monkey2’s 3d progress!
I’ve only really spent a couple of weeks on it full time so far (and have had some kind of nasty flu-bug thing over the last few days so have been taking it easy this week) so there’s not all that much done, but in a nutshell:
* There’s a simple model/surface/material system going. Surfaces have a material, vertices and indices and are attached to models, very similar to b3d’s mesh/surface/brush system. Also CreateSphere and CreateBox for testing. All this may or may not yet be thrown away. Also, simple skybox support.
* There’s a pretty cool ‘PBR’ shader going. PBR stands for ‘physically based rendering’, which, as far as I can work out, is really just a slightly different approach to how diffuse/specular/normalmap etc are parameterized, and a few additions/tweaks to the good old ‘blinn-phong’ shader code to make it more realistic. Crash course in PBR is here:
I don’t understand all of that(!) but I had a play around with it a few years ago (in c++) and worked out enough to get it ‘sort of’ going so had a bit of a head start. (It was fun getting back into the ‘shader groove’ too!) Also, I recently discovered this which clarified a few things that had me guessing first time around…
I’m now pretty happy with the results although I’m sure there will be heaps of tweaks to come – esp. from people who *really* understand all the math!
In practice, PBR affects the parameters/colors/textures etc used by materials, but not a lot really. The way I’ve done it, materials have diffuse/specular/gloss/normal colors/maps so it’s almost the same as b3d brushes (although the ‘meaning’ of some parameters differs a little). There are other approaches too such as diffuse/metallic/roughness/normal, which can easily be provided for via a different shader if necessary – and may be better, dunno yet!
What’s the point of this PBR stuff anyway? Well, the biggy is it just plain looks better because the underlying algorithms are better, but IMO PBR is also easier to use. This page has some hints on how PBR colors work and basically they’re just hardcoded diffuse intensities for non-metalic (or ‘dielectric’) materials (with about .04 specular – everything has specular!), and hardcoded specular colors for metalic materals (with black diffuse).
PBR can (theoretically) achieve these sorts of results:
Note that mx23d may not be capable of this level of quality just yet, but the ‘pieces’ are mostly all there I think.
I realize that not all mx23d users are gonna be doing stuff to this level (or are even particularly interested in ‘realism’ in the first place), but even for casual users, I think PBR will be a big win regardless of what you’re doing.
* There’s also a simple gltf loader going. No anim stuff yet, and bizarrely glTFv1.0 has no built-in (ie: non-extension) support for normal maps (glTFv2.0 does, apparently coming very soon) although I’m sure we can kludge something in here if necessary.
Next up, I am going to start work on the entity system, including basic bullet physics integration and animation. This is a pretty exciting time as it should mean I have some stuff flying around relatively soon!
Everything is still gles2 and I haven’t yet decided whether to go to gles3. Nothing I’ve done so far *needs* gles3 so gles2 is still an option at this point, so I don’t see the need to make any firm decisions about this right now. There are some good points on the pros/cons of using gles3 or gles2 here:
Feel free to add your own thoughts/comment(s) but please be nice!
Also, please follow me on twitter @blitzmunter for occasional screenshots of my 3d progress.
Finally, there is no source code yet (and wont be until I have a clearer picture of how it’s all gonna end up) but I’d like to remind everyone that the monkey2 3d module *will* be open source! There seems to be a bit of confusion about this going by some posts on the forums.