Latest Creation

Cartoon pirate captain.

Fun With Terrain

I’m not a fan of Unity’s build in terrain system. Although it is now supported on mobile platforms, it generates way too many draw calls for practical usage on devices where many draw calls can cripple performance. I did a simple test with only Unity native terrain and nothing else in the scene. The result was 72 draw calls. What is worse is that there is nothing in the settings that could alter this number. A better method for making terrain is to simply create it however you like in your content creation software of choice(3ds max in my case) and import it into Unity like any other mesh. There are a few advantages and disadvantages of using this method.

  • Can be rendered in 1 draw call. Even if created in multiple pieces, they can be static batched at run-time.
  • The mesh can be in any arbitrary shape and not limited to the height based grid system of native terrain.
  • Can use dedicated terrain generation software, such as Terragen or Vue(although the resulting mesh will need cleaning up).
  • Can’t use dynamic LOD like native terrain has.
  • Having too many vertices could be an issue, but there are mesh optimization techniques to reduce vertex count while largely maintaining shape.
  • Need a custom shader for texture blending.

Unfortunately, there are no texture blending shaders that ship with Unity that do what I want. So, I came up with one that blends three textures using the rgb vertex colors as a mask. It is unlit, but supports lightmaps and should run super fast.

Shader “Custom/Unlit3TextureVertexMask”
{
Properties
{
_Color (“Main Color”, Color) = (1,1,1,1) // only used for fallback
_MainTex (“Texture”, 2D) = “white” {}
_MainTex2 (“Texture”, 2D) = “white” {}
_MainTex3 (“Texture”, 2D) = “white” {}
}

SubShader
{
Tags { “RenderType”=”Opaque” }

Pass
{
CGPROGRAM
#include “UnityCG.cginc”
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile LIGHTMAP_ON LIGHTMAP_OFF

struct v2f
{
half4 color : COLOR;
fixed4 pos : SV_POSITION;
fixed2 uv1 : TEXCOORD0;
fixed2 uv2 : TEXCOORD1; //for lightmaps
};

sampler2D _MainTex;
sampler2D _MainTex2;
sampler2D _MainTex3;

fixed4 _MainTex_ST;

#ifdef LIGHTMAP_ON
fixed4 unity_LightmapST;
sampler2D unity_Lightmap;
#endif

v2f vert(appdata_full v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv1 = TRANSFORM_TEX(v.texcoord, _MainTex);

#ifdef LIGHTMAP_ON
o.uv2 = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
#endif

o.color = v.color;
return o;
}

fixed4 frag(v2f i) : COLOR
{
fixed4 c = tex2D(_MainTex, i.uv1) * i.color.r;
c += tex2D(_MainTex2, i.uv1) * i.color.g;
c += tex2D(_MainTex3, i.uv1) * i.color.b;

#ifdef LIGHTMAP_ON
c.rgb *= DecodeLightmap(tex2D(unity_Lightmap, i.uv2));
#endif

return c;
}
ENDCG
}
}
Fallback “Diffuse”
}

 

 

 

 

Hello, cruel world!

I’ve converted my old static website into a shiny new CMS’y  website with the hope that I can share my experiences with game development easier and faster while still keeping a portfolio of pretty polygons I’ve made. If you’re looking for said pretty polygons, they can be found here.

Currently I am working on a Unity game whose title I am juggling between “Pirate City Plunder” and “Scurvystorm“. As this is my first real game, I am aware of the temptation to aim too high in features and complexity, but at the same time I want to make a memorable and good-looking game that is set apart from the many less than stellar games in the indie market these days – especially in the endless cloud of  iOS and Android games out there. If I could, I would probably make something like an online muliplayer shooter, but the intricacies of client server architectures is a bag of poo that I don’t want to open. Deciding what a game should be is a delicate balance but I at least have the advantage from a visuals standpoint, as I’d like to think that I’m pretty good with art. After careful consideration and iterating through many ideas in head, I decided to go with a 3d side scrolling beat-em-up game that would be a mix of old-school classics Final Fight and River City Ransom. Yes, Pirate City Plunder is a pun name of River City Ransom.

So far, it is going well and I’ll keep updating my progress.

Return top

INFORMATION

I am an artist and I've been professionally involved in making games for over four years. This is my blog. Some of the cool stuff I've made is here.