Monthly Monkey2 update for May 2018

Hello everyone!I have mainly been playing with 3d over the last month. The shader system is now much tidier, thanks to the addition of a pseudo ‘import’ directive (glsl doesn’t have one so you need to roll your own) that should make writing shaders much cleaner/easier. For example, the default PbrMaterial shader is now only about a page long, and most of that is just texture lookups. I also implemented spot lights and light texturing for point/spot lights. Spot light textures are just simple 2d textures, while point light textures need to be cube maps. It’s a neat effect so I uploaded a few WASM demos:

http://monkeycoder.co.nz/bananas/spotlight/Spotlight.html

http://monkeycoder.co.nz/bananas/room/Room.html

I also added AmbientTexture and AmbientLight properties to PbrMaterial so you can now lightmap/prelight models. AmbientTexture uses secondary texture coordinates, and gltf and assimp loaders now fully support 2 sets of texture coordinates.

Simple support for high dynamic range (‘.hdr’) files has also been added. High dynamic range allows for intensity values > 1.0 and, combined with bloom, can produce spectacularly cool ‘overbright’ images. This is WIP stuff that will currently only work on desktop GL as it uses a floating point pixel format, which AFAICT isn’t supported in webgl. But the actual source hdr data only actually takes a byte per component so could theoretically be stored in simple RGBA textures and unpacked in the shader at runtime – later.

Most hdr files out there are 2d spherical environment maps so I added support for spherical sky/env textures too. Unfortunately, there’s a bit of a ‘gotcha’ – spherical textures can’t be mipmapped without introducing an ugly ‘seam’ where the textures wraps around (and a weird ‘pinched’ effect at the poles) , so mipmapping isn’t recommended for spherical textures. This is OK when it comes to skyboxes as long as the texture size if right, but mipmapping is a large part of how the the roughness effect is achieved so turning it off kind of screws that up – ie: specular reflections are always sharp regardless of material roughness setting. The solution here I think is to convert spherical textures to cubemaps – possibly at a reduced resolution – for when they are used as specular reflection maps, and stick with unmipmapped 2d textures for skyboxes. I think this is worth the effort as they are a LOT of cool hdr maps around, eg: https://hdrihaven.com/

The roughness calculation in general has been improved too – compare the ducks or pbrspheres demo in 2018.05 with 2018.04. In v2018.04, some triangles in the ducks demo would noticeably stand out when viewed up close, due to the use of incorrect roughness on some triangles. In the pbrspheres demo, surfaces tended to be overly rough (eg: roughness of 0.5 was looking more like it should have been 0.75) but is now producing a better distribution of smooth/rough surfaces. Kind of nit-picky stuff, but I’ve been vaguely aware of this for ages but haven’t really known what was going on until I had to come to grips with the spherical mapping stuff.

Finally, I have also added a few physics ‘joint’ components such as BallSocketJoint, HingeJoint and FixedJoint. Check out the jointchain and hingechain tests for some simple demos.

Have fun!

Bye,
Mark

***** Monkey-v2018.05 Mx2cc-v1.1.13 Ted2go-2.10 *****

Added simple support for .hdr pixmap/texture/image loading (wont work on android).

Added mojo3d HingeJoint. See tests/hingechain.monkey2

Renamed mojo3d Constraint->Joint and PointToPointConstraint->BallSocketJoint.

Added mojo3d support for ‘spherical’ sky textures. Also added TextureFlags.Envmap which must be used for envmap textures. Previously, cubemap+mipmap implied envmap but this is no longer true.

Fixed a very gnarly bug in garbage collector. Thanks Mac767!

Changed emscripten module builds so they generate .bc files instead of .a for a minor link speed up.

Added experimental spot and point light texturing via new Light.Texture property. See tests/spotlight and tests/room for demos.

Added RigidBody.LinearFactor and RigidBody.Angular factor properties – untested!

Added support for multiple UVs to gltf2 and assimp loaders.

Streamlined mojo3d tests dir.

Added LinearDamping and AngularDamping properties to RigidBody, but can’t get them to do anything so far – please have a play James!

Added ‘offset’ version of ApplyImpulse to RigidBody.

Added AmbientTexture and AmbientFactor to PbrMaterial. Like EmissiveFactor, AmbientFactor defaults to black so needs to be set to white to enable AmbientTexture.

Major clean up of mojo3d material system. Minor cleanup of post effect system, mainly just added some helper methods in base PostEffect class.

Added multidimensional array initializers, eg: New Int[2,2]( 1,2,3,4 ). Array length much match number of elements exactly or runtime error.

Added first physics constraint component to mojo3d, PointToPointConstraint – should probably be renamed joint IMO. Stay tuned…

Added low budget OpenUrl for emscripten. It just replaces current page with the given URL so effectively ends app too.

Added zlib module and DataBuffer.Compress and DataBuffer.Decompress.

0

Liked it? Take a second to support Monkey 2 on Patreon!

Leave a Reply