Sunday, October 27, 2013

Here's a quick dump of getting DualShock 4 support in your SDL title that should work for SDL 1.2 and 2.0. If you're not using the controller mapping in SDL ( like for Steam OS titles ), but want to do it old-school here's the button layout in SDL terms:

You can detect the pad via the string "Sony Computer Entertainment Wireless Controller". Here's a dump from Linux dmesg for more USB details if you want to fingerprint:

Monday, October 7, 2013

So I dusted off the terrain / biome system to hook it up to the voxel terrain system, since it makes a lot more sense to model very large landmasses in a way people can understand. Density functions by parts isn't a bad thing, but even if you expose this with a UI flow graph -- who the fuck is going to understand it that also wants to use a flow graph chart? Exactly.

Better to allow for 'big picture' visualization of what those damn things do I say. Take for example this simple gem on how to generate large landmasses... Clamp your density by masks of large water bodies and scale by smaller ones. Simple and effective. Rock composition is the variable that effects water erosion the most. It happens in nature everywhere that's why you get the grand canyon to the salt flats. Forget elevation as the main factor.

In fact you can completely ignore the physics and go for a purely artistic version of a bay like below. Only using three of the density function operators no less for a playground for artists to start hacking away. Each KaDensity function takes a list of parameters and returns a density. They're pretty self-explanatory:

Here each stage is generated via simplex noise and saturated to threshold the values, and then combined to produce composite images. Don't have to teach artists about physics or generate all the voxel terrain for them to visualize while dialing it in... make continent iteration quicker. This mask alone has a large effect on the Terrain and Biomes as you can see. From here you can pass this to VoxelSector density samplers and get your 3d terrain as a GPU visualization and / or CPU mesh from isosurface extraction as seen previously on the blog. BTW I have found the ideal width of a river is ~1km so these pixels are about 1km^2 while typically I would generate VoxelSectors at about 1/4km^3 to give a sense of scale. That makes these preview windows about 512x512km while the camera in game tends to only go to a view distance of 12km. From here you can feed back masks into each other such as for Fanua mask generator. :)

Friday, September 27, 2013

Had a free hour between 0145 and 0245, so I "ported" freyja 3d to a modern Linux system. Kind of funny things have changed so much since then... mostly a hassle due to cmake being so horribad. If premake4 was around back then it would have been much easier. The cmake system ties into a hand rolled cross compiler system for building for platforms like Windows from Linux if you didn't know. Good times. I mostly fixed it to use as a model viewer / tweaker / debugger for some blender exported skinned meshes with animations.

Also got the per voxel sector procedural deco system up and running, but didn't post anything about it as there is a long way to go to get the cubemap gen, depth/height gen, etc in for IBL fun per sector. Not much to look at especially without even volumeric fog / aerial perspective enabled. I was just testing 'fill' with this screen capture basically. The bright yellow dots are markers that flash on/off to visualize the sector layout, and show where the 'smart sector' object is located. It is mostly for coordinating deco batches and the cached/dynamic maps mentioned above.

About to get back to working on graphics after making several script based camera rigs and character controllers to test the new scripting API improvements including fast math lib exposure and the ability to dynamically bind script classes from the native side. May toss in a quick shooter game play demo like I did in midgard... that was 11 years ago! I feel old as the last engine I wrote from scratch with network gameplay is older than most game companies today.

Once I have a polished network model for gameplay I may do a public alpha test. If that goes well... ah kickstarter? This time it will be an action rpg-ish death match in an open world environment. I also need to get the Makehuman models animated for demo content I can release. Currently I'm using "stand-in" animated models that can't be redistributed with the demo as you likely noticed. Right now that would mean you can plug-in any md5mesh model and play, and I'm not going to encrypt the script files or shaders as I want to demo with the web browser as editor, so people can mod it. It'll be like old times. I thought about purchasing some stock animated models in FBX and converting them... but I would have to reverse engineer FBX binaries. If you have some to sell and are willing to export to md5 for me I will pay extra to save the time for coding on my engine. ;)

Failing that I may release a single player version to let people kill and loot some mobs, and focus on gameplay net code later. Hell worked for minecraft going single player + editor. I already support a couple network servers per game client already for editor on httpd and script console via telnet. The dedicated server part is easier that this, but I have yet to put time into it. Time for bed! 0310 :)

Monday, September 9, 2013

Got the basic voxel terrain in today. The most time was spent on new ways to generate and enqueue Voxels, RenderMesh, PhysicsMesh in various worker threads and sync them amongst all the subsystems. Also refactored some of the math library and noise generation while in there to avoid overlap.

Voxel Terrain Sectors 2x1x2

The scale of this image required me to adjust my camera... typical player could be about as big as a pixel here... going to hook this up to my biome and erosion simulation next. That way flora and fauna will spawn with rivers and 'set piece' locations, and have some more high frequency details... I had some crazy stuff like ocean trenches prototyped, but who would ever see that? Took out the randomized caves for now too as they should be created by the biome / erosion system. The trick will be to convert it to density functions properly - eg account for overlapping terrain. I don't think trees grow under ground.

This is just a 2x1x2 voxel terrain patch to get a sense of scale... I have mostly been testing with 6x2x6 and 9x3x9 for a complete world earlier. It is all hooked up to script you can spawn more terrain as the player runs around until you run out of floating point sanity if you like.

Memory overhead is super low at ~1/4 the size of the older heightmap generated terrain. That said you could make worlds smaller than one walk cycle of animation or short sound clip by far still. :DPlanning on adding real-time editor later that works by altering density in a selected Voxel Sector for artist controlled editing via terrain brush. It would be nice to make it work with touchscreens via the web editor too in real-time, but not high on my list. Elevation and Biome splat controller needs to come in next. Maybe add some slope blending adjustments to the basic shader / materials too. The most fun will be allowing scripted density functions by exposing the native structs holding function pointers and args to script that run in the density summation as addends. In other words alter the density functions from script ( data driven ) at any time not just alter the voxel field... well laters.

Saturday, September 7, 2013

Voxels and Triplanar Mapping only took a day and a half thanks to the excellent docs from Nvidia and my awesome little engine that could. Going to work in real-time editing and maybe tessellation guided by isosurface extraction later if I don't get sidetracked with other big features. This is a CPU converted isosurface to standard mesh to use the CPU side physics. eg voxels -> mesh. Will be doing GPU side physics to use with noise based particles / fluid simulation at some point. Also GPU only is good for real-time editing.

BTW was using marching cubes for this, but I'm still toying with naive surface nets for low end mobile platforms as it's much less ploygon soup when done. Also with naive surface nets you can generate less dense CPU side physics meshes then render on GPU in higher detail.

I also tossed in a preview of a simple 2 texture triplanar 'cave' material for the same shader.

Wednesday, August 21, 2013

Hey guys. It's been a long time since I posted anything about my engine kagura. I've started working on Physically-Based Lighting, and Clustered Deferred Shading with Forward+ will be the next big renderer change. Yes, I do enjoy rewriting my renderer fairly often it may seem. That's why I architected a plugable renderer! ;)
First a screenshot of the latest alpha build with some horrible debug spew all over the place:

Currently I have Lambert with a Normalized Blinn-Phong enabled as I have stopped toying with the Oren-Nayar to get to some real business -- Removing the MDR system to replace with a standard HDR system with filmic tone mapping.

Still using random assets from the web and what I can do with blender. Really need to contract a professional artist do do a rigged character model with a walk cycle soon.

Also the editor has fully generic property mappings now. This means you can bind script from native code or script to procedurally generate the UI on the target device such as a desktop webbrowser, nexus 7, or galaxy note in my case(s). It's not pretty, but it gets the job done. From native code this is how a bind looks:

This is then processed in javascript into HTML widgets with signals, updated values, and handlers. A preprocessor in javascript allows for Lua script expansion to save time yeilding something like this for the KaTelemetry callback ( html->js->lua on the remote host/game ) :
KaTelemetry( "KaCameraComponent.Exposure( KaGameObject.GetComponent( KaGameObject.FindByGuid( 0 ), "KaCameraComponent" ), 1.97 )" )

All this happens while you drag your exposure slider around. Yeah I decided to put in on the camera instead of in the Image Filter material while I was testing the tone mapping and linear color changes. This also allows for very complex scripting across the HTML editor and game host / remote server, but this is a simple example. I need to clean it up and optimize it, so I can do a full study and write-up at some point. :D