Shader updates and inspectors

It’s been a busy few weeks. I’ve been knocked out a bit with a cold/flu thing and PAX. So there’s not as much to report as I would like but here’s the highlights.

PAX was great. Being in the bigger venue meant we could actually get to panels without waiting multiple hours in the cold and rain. Got to see lots of panels with indie devs and talk to them on the show floor. Numerous people told me GCAP is probably what I actually wanted to go to and their not wrong. It just wasn’t going to work out this year. Next year hopefully.

Shaders

updated substances and all the maps shader

I’ve updated the shader in a bunch of ways. It’s more optimised, previously it was just using a separate texture for each map, now its all packed in channels. Considerably less total gpu ram usage and runs faster, few things that were previously floatx and how just single floats and things that used to be separate samples are now just swizzles. This simple sample scene is running comfortable at hunders of frames even on my mac air.

ao sample grey scale

Grey AO

ao sample colour

Coloured AO

I was talking to Tony at work about what I’d been messing with and he mentioned that it really bugged him that AO was always grey scale. So I have a first draft coloured AO in the shader and a node to generate it from diffuse, ao and height in Substance Designer. The early results are interesting, its kind of a very local faked GI or PRT. In any event I like the way it looks, it makes everything appear much richer instead of washed out.

custom material inspector

Next up was a custom material inspector for the shader, just so it can hide properties that aren’t being used, eg. here lightramp textures are not shown as they are not turned on, same with occlusion strength. Also I wanted to have both sliders and numbers showing for float ranges.

Also created a simple light ramp and gradient ramp texture creator (the yellow and blue ball above is using a dual colour ramp shader) so I didn’t have to keep going back n forth to photoshop etc. to create ramps. This is done by creating a custom editor window.

texture ramp creator

 

Generators

I wanted to be able to chain together and merge different patterns and randoms etc. to generate dynamic anim curve style data. Specifically so I could not have to create custom animations for things like moving/flickering lights in the scene I’m working on. My first attempt worked great and code made sense and was a small and easy to maintain and extend. Unfortunately the way I was using inher didn’t play nice with unity inspector. So I redeveloped it as flat (and right now just a single class). The code is not as nice (it’s not soul code anymore) but it is entirely configurable from within the unity inspector.

custom generator inspector

This required both a custom inspector for GenerateDriver class and PropertyDrawer for Generator class. I’m particularly fond if the real time preview. This head bob a few of these moving different local pos axis and lerping between idle and moving bob based on velocity, ~10 lines.

headbob_generator

 

Finally here is some very early stuff I’ve been working on for the Red Room. Mostly just upping my proficiency with Substance Designer.

redroomwall_preview

redroomfloor_preview

 

Parallax Offset

So sometime last week, while playing Substance Designer for a I’m working on, I put some height maps into Unity’s Parallax Bump Spec shader. This sent me down an interesting rabbit hole. First off Unity’s parallax is an interesting hack/shortcut.

 

No parallax

normalmaponly

Unity’s parallax

unity para

That’s it. Very cheap and for low heights the effect is still impressive. But at large heights and longer objects the textures begin to slide, thing start to look like they’re made out of chrome and their texture is actually the environment map. Why? Well its not how Parallax offset mapping/parallax occlusion mapping/Steep parallax offset mapping/relief mapping etc. work. They all rely on some form of ray marching through texels of a height field/map. Basically we have some starting point, the uv being render, we then move in the view direction across the surface of the texture incrementally. The distance per step is determined by viewing angle. Each step it samples height, if the height is less, we’ve intersected the height field surface. When it can be afforded a binary search is then performed between the previous and current sample to find a more accurate height for this frag, it greatly reduces height banding. This gives us a new ‘depth’ of the frag and a uv offset to sample all other maps with. here http://graphics.cs.brown.edu/games/SteepParallax/ and here give good overviews http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/a-closer-look-at-parallax-occlusion-mapping-r3262

Parallax Offset

para

Well occlusion had to come next didn’t it. Its expensive. It uses the same principle. Once you find the offset, you then use the same ray marching ideas to move towards the surface of the height field in the direction of the light dir. If you make it to the surface without dipping below the height then not occluded, if you do hit something the light doesn’t reach you.

Smoothing these out was needed, I wanted to find a cheap way to remove the misses and the aliasing. My current method is to use lower mips. One of the recommendations for height map aliasing is smoother maps in the first place, which I have also played with a bit in my demo scene. Mips will smooth for me automatically (they’re already there I just needed to use them) and will still allow for extreme close ups to have that detail. Unfortunately it was not as easy as tex2dlod, unity surface shaders don’t support it it seems. But they do support tex2dGrad. This worked, much of the aliasing and sparkling was gone the very sharp edge remained. To smooth it (or rather make it less regular), compare the sample to that of an even lower lod and fade based on difference between the two.

Parallax Occlusion

para occ

The solution is not overly accurate but it is smooth, consistent and predictable. There is little to no, sliding, popping or sparkling. Also it only works in dx11 mode in Unity. I wanted to see if it was possible using only Unity’s surface shaders instead of writing glsl or cg from scratch, it is but it means changing renderer causes it to fail, due to using tex2dgrad inside control flow statements: X6077. This strikes me as odd as I’m fairly sure what I’m doing is legal, esp since unity graphics emulation thinks it’ll work on openGL ES 2.0. It might be pure related to Unity’s conversion from surface shader to cg is renderer dependant and is stumbling somewhere.

Some of the problems with this method;
Everything is pushed in (away from surface norm), so things shrink.
For great heights texels on slopes get pulled in ways they were never intended to, could try to remedy this with tangent space tri-planar mapping, at least add some noise over the stretch.
Its expensive, some quick numbers out of the Unity viewport, para occ is ~450fps, para without occ is ~650fps, Unity’s offset is 2000-400fps. That’s on a gtx670 in a window that is about 1600×900.

After much fiddling with tuning paras, like min and max steps, I was happy… for a time. I wanted to see what else I could push with the other map types out of Substance. Ambient Occlusion was the next map of interest. I’ve previously used AO in substance as an information source for the diffuse map. I tried mixing AO with both depth and nDotL (normal . light). The results again and not accurate at all but the effect was surprisingly good, to me at least. It gave fake soft shadows across the surface.

Directional Ambient Occlusion

amb dir only

Final result.

all

This is by no means the best, most complete or most performant way to accomplish these tasks. Displacement mapping would most likely be much faster and produce smoother results.

 

Different angle

Normal map only

none skew

 

Unity Parallax

unity skew

 

Parallax Occlusion with Directional Ambient

para all skew

 

JSD PA4

Updated JSD or in a few hours according to android dev console. Game now pulls data from live google spreadsheets and uses NGUI for much slicker GUI. You can now also incrementally refund any upgrades purchased instead of just refunding everything ever.

jsdpa4 new gui 1JSDPA4 new gui 2

Shaky Cam WIP 2

Threw together a quick demo to show the variance possible in the shaky cam setup I described earlier. It sends the shame shake vectors to all cameras, the different results are due to different spring constants and different rigidbody linear dampening values.

Try it here

Totally not peggle – Part 3

Playable here

Didn’t get to spend as much time on it tonight as the last two but managed to get camera shake and beginnings of some basic emotion. Some pegs spawn with eyes, right now all they do is ‘panic’ (pupil shrinks) and look at a ball if one is close. Otherwise they just blink randomly and look around. Looks cool though.

Shaky cam

Build here

Quick job of putting together a 3 dim of freedom spring with linear limits. I tried using the built in springs but they were a little crazy. At the moment it still relies on the rb to maintain velocity and dampening, I’m not sure I like that so I’ll probably move that out so it simulates itself in isolation of whatever the physics engine may want to do.

Totally not peggle – Part 2

Playable here

Completed this after work, apart from a short break here and there ( for dinner and such). Lots of basic juice as been added. Music is from Incompetech. Sound effects created in Bfxr. Easing is done using a little Easing utility I wrote a while back. I’m pretty happy with it for what is all up only about a day worth of work.

The big things I haven’t gotten to yet are; cracks in the pegs, proper menu and world map, camera shake and touch friendly input. Perhaps tomorrow.

Just Shmup Dammit PA3

Just pushed out Alpha 3 update last night. So I had to rewrite the upgrade storage system because it was driving me crazy not its basically a readonly Dict<string, double[]> stored for look up. Player stats then look at this and store a local cached copy appropriate for their level and only look at that again when they level up a stat. Much easier to work with.

2013-11-27 10.15.17

Also got rid of the intuition numbers and am now pulling data out of calculated spreadsheet data. And moved to Unity 4.3, so now all the bullets are sprites not just quads. It didn’t really seem to change the median performance but it may have smoothed it out a bit.

Missiles now indicate their target enemy with a blue laser sight and they slow down over time, which leads into the 2 new upgrades missile speed and missile agility.

Slomo indicator, hourglass on the left, so that you can tell at what speed and if you have slomo activated. Also smoothed out the timescale changes so it doesn’t jump from 1 to .6 in 1 frame, now it lerps between them.

On the horizon: facebook integration, analytics, more meshes, more textures, more bullet patterns, landscape support.

Just Shmup Dammit: Presentations

The other CSU subject I was undertaking this semester was Mobile Application Development. In this subject we were to present an idea and explain the platform it was targeting, why and an overview of how we were going to implement it.

jsd_ps2_clipped

The second was essentially a progress milestone showing off what you had accomplished in the short time, ~12 weeks but only about 8 hours a week. I managed to get a small shmup-upgrader made with Unity3D completed in this time, it is not at alpha yet but is mostly complete game loop, with all original assets created by me in Blender, Photoshop and Substance Designer.

These presentations are available here and the game (in its second Pre-Alpha release) is on the Google Play here.

Just Another Card Game: physical prototype

The last project style assessment the Games subject had was a physical game prototype and high concept document. Since making a physical (paper) prototype was mandated I choose to create a card game. This was spurred on by primarily playing SolForge on iOS and seeing others play Magic: Duels of the planeswalkers, HearthStone etc.

card game play test

I approached this by creating a game that is a chaotic collision of Solforge’s combat, deck building (a la Dominion) and the joy of being a jerk in games like Uno.

The brainstorming started with distilling the rules a player would have to know down, so removing things like action and buy limits and then designing 3 unique card types. Monster’s being the obvious one, the other two are to alter the state of play for players. A duration card is like a weather or headline from Arkham Horror, it changes or adds new rules to everyone’s turn. An Instant card, as the name implies, is instant and can be played by any player at any time for free. The goal of these cards is to make the simple rule set always seem fresh and to keep all player’s attention on the game and avoid the “let me know when its my turn again” problem many turn based games face.

Next was a long list of all the possible effects and giving them approx. utility to player’s and thus deriving the card’s cost and relative worth. The initial list was well over 100 different effect types, this was found to be way too many and some were far too similar.

I’ve tided up and shared the folder with the draft cards, the pdf that was printed out, questionnaire results, rules and High Concept Doc that was submitted.

 

View Files

Far cry 3 game overview/deconstruction

I’ve tided up the folder containing all the work I did for one of the earlier assessments for my CSU Games subject, the goal was to choose a AAA game and identify and analyse its basic elements; Dramatic, systematic and gameplay.

fc3fireArmPS

This was done primarily by following the prescribed text ‘Game Design Workshop: A Playcentric Approach‘ and also some other basic ideas; concept docs, Caillois‘s modes of play, extended version of Bartle’s player types, Koster’s Theory of fun and an attempt at using Dan Cook’s Skill Atoms. I was fairly pleased with the result.

 

View Files

Just Shmup Dammit PA2

A friend managed to clear the ‘last’ level of the enemy waves so I felt obliged to push some of the minor work I’ve done since a1 went up.

A2:
added versioning to upgrade data and splash
changed missile launch pattern
player grace period after hit
clamp inside screen
vibrate on dmg

On the horizon;
All new progression based on spreadsheets not gut instinct
more upgradable stuff
More waves
better spawning
More Textures
More feedback