Skip to main content


Showing posts from May, 2018

UI Wooble Shader - Unity Shader

UI Wobble Shader A shader that will a add a bit of liveliness to your UI is always a good thing, especially when you are making a mobile game where grabbing and holding user attention is top priority. This effect is known to hypnotize users into spending big bucks in your game (sarcasm). Anyway this shader is based on the optimized UI shader provided by Unity.
This optimized, mobile friendly UI shader can be found HERE.
Masking, Clipping and some other fancy stuff is not available when using this shader on UI components.
Let's get to making out jiggly wiggly UI shader.
We will look at the properties being declared :
Properties { [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {} _Color("Tint", Color) = (1,1,1,1) _WobblesPerSecond("Wobbles per Second ", Float) = 2 _WobblePeriod("Wobble Period (pixels)", Float) = 45 _WobbleAmplitude("Wobble Amplitude (pixels)", Float) = 3.2 } Here are the…

Useful Unity C# Extension Methods

Get The Most Flexibility Out Of Unity With Extension Methods Unity3D comes with a lot of helpful classes and functions but sometimes you will encounter cases where custom implementations are required.
Rather than writing those functionalities as completely separate from the classes that already exist, We can just 'extended' those classes to have our custom functionalities. This leads to code that is easily discoverable, clean and that can be re-used across multiple projects.
This is not a tutorial on extension methods, For that go, HERE. In this tutorial we will go over some really useful cases where we can improve on the default Unity code base with extension methods.

1. Converting from Vector3 to Vector3Int public static Vector3Int ConvertToVector3(this Vector3 vec3) { return new Vector3Int((int)vec3.x, (int)vec3.y, (int)vec3.z); } 2. Resetting the Transform
public static void ResetTransformation(this Transform trans) { trans.position =; trans.localRotat…

C# Intermediate - Extension Methods

What Are Extension Methods? Extension methods are a way of enabling you to add methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original class, struct or interface. An extension method is a special kind of static method but they can be called in a way that an instance methods would be called.
Extension methods can drastically improve code readability and maintainability of a code base ( if done correctly ).
How To Use Extension Methods? An extension method is a static method of a static class, where the "this" modifier is applied to the first parameter. The type that is to be extended should be the first parameter of the method.
The extension methods are only available for use if it is in scope, So make sure the namespace is imported into your source code with a using directive.

We will look at 3 examples of possible use cases.
Use case 1: Extending the Int type 
using System; namespace BitshiftProgrammer { public…

Dithering Image Effect - Unity Shader

Dithering Image Effect We will be making this effect : This effect can handle both color depth reduction ( reducing number of colors gets displayed ) as well as the dithering ( our main objective )
As this is an image effect go ahead and create a new image effect in Unity.
There is no vertex shader code as this is an image effect.
So now let's look at the properties that we have for the shader :
Properties { _MainTex ("Texture", 2D) = "white" {} } That's all? well.. we have more but these are not exposed as public. So we do not declare them in the properties section.
These are the properties declared in the CG PROGRAM
sampler2D _MainTex; int _ColourDepth; float _DitherStrength; We will come to see what _ColourDepth and _DitherStrength are later on.
Now we will look at the Dither Table that we will be using :
static const float4x4 ditherTable = float4x4 ( -4.0, 0.0, -3.0, 1.0, 2.0, -2.0, 3.0, -1.0, -3.0, 1.0, -4.0, 0.0, 3.0, -1.0, 2.0, -2.0 ); Declar…

Pixelation Shader - Unity Shader

Pixelation Shader This is the correct way (one of many) of showing pixelation as a post-processing effect. This effect will work in any aspect ratio without any pixel size scaling issues as well as it is very minimal in terms of coding it up.

In order to get this to work 2 components have to be set up:
1) The pixelation image effect
2) The script - which will be attached to the camera

So let's get started by creating a new image effect shader.
We will take a look at our Shaderlab properties :
_MainTex("Texture", 2D) = "white" {} That's it, Everything else will be private and not shown in the editor.
Now we will see what are defined along with the _MainTex but are private.
sampler2D _MainTex; int _PixelDensity; float2 _AspectRatioMultiplier; We will pass _PixelDensity & _AspectRatioMultiplier values from the script.
As this is an image effect there is no need to play around with the vertex shader.
Let's take a look at our fragment shader:
fixed4 frag (…

3D Art Assets / Packages / Sets Of The Month [ May, 2018 ]

The Best Art Assets Of The Month - May 2018 *Note: These assets are separated based on the category : ENVIRONMENT, CHARACTERS & PROPS
ENVIRONMENTS Stylized Nature Pack

PBR Graveyard & Nature Set 2.0

Tropical Forest Pack

Low Poly Town

Sci-fi Design Kit

CHARACTERS Underwater life deluxe

Kid From Space

Real Men Pack

BioMechanical Whale


PROPS Booze Haven Pack

Quest Markers 3D

HQ Modern Furniture Pack

Simple Shop Interiors - Cartoon Assets

Medieval Food & Drinks - Mega Pack
Check out more such Unity Asset Store Gems : HERE
Don't forget to share these wonderful assets with your colleagues and friends.
Support Bitshift Programmer by leaving a like on Bitshift Programmer Facebook Page and be updated as soon as there is a new blog post.
If you have any questions that you might have about shaders, C# or Unity development in general don't be shy and leave a message on my facebook page or down in the comments.

Productivity Upgrade - Unity Asset Store [ Paid Assets, May 2018 ]

Productivity Boost - Assets That Help Make A Better Game In Less Time *Note: These assets are not arranged in any way, no comparison is done. They are just really cool assets that will help make your entire workflow more streamlined as well as deliver output faster.😁

8.Nokobot Utilities- It comes with an assortment of utilities that can be standalone assets by themselves. A Meshbaker is included as well as a  Pivot Manipulator tool (which is a god send), Some more tools are included as well. Check this is asset out if you make 3D games as this one will fit perfectly into your workflow.
7.Odin - Inspector & Serializer - Puts your Unity workflow on steroids, It comes with it's own serializer which can essentially serialize anything. Along with that editor is overhauled and also custom editor extensions are really easy to make with it's API and on top of all this it even comes with input validation which is really useful designers and artists. Make the most of your valu…

Visual Upgrade - Unity Asset Store [ Paid Assets, May 2018 ]

Visual Overhaul - Assets That Turn Mediocre Into Drool Worthy *Note: These assets are not arranged in any way, no comparison is done. They are just really cool assets that will help make your game look at least a bit better.😁 .

8.Smoke & Ember FX- This is a collection of warzone inspired effects mostly embers and smoke (just like the title suggests). A perfect use case for this asset would be as a menu background or in a cutscene. The best thing about this asset is that small tweaks are all that is required to use this in various different scenarios.
7.2DxFX: 2D Sprite FX -This is the creme de la creme of 2D sprite effects. This contains almost everything you would ever need to drastically improve the look of a 2D game. The best thing about this is that it is draw call optimized so mobile games can take full advantage of 2DxFX.

6.Colorful FX-It's a collection of fast and customizable post-processing effects. It's easy to use, optimized and multiple platforms supported. Th…

Assets Worth Checking Out