Simple diffuse shader using ShaderLab in Unity

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "Custom/SimpleShader" {
	Properties {
		_AmbientLightColor("Ambient Light", Color) = (1,1,1,1)
		_AmbientLightIntensity("Ambient Light Intensity", Range(0.0,1.0)) = 1.0

		_DiffuseDirection("Diffuse Light Direction", Vector) = (0.2,0.8,0.7,1)
		_DiffuseColor("Diffuse Light Color", Color)=(1,1,1,1)
		_DiffuseIntensity("Diffuse Light Intensity", Range(0.0,1.0))=1.0
	}

	SubShader
	{
		Pass
		{
			CGPROGRAM

			#pragma vertex vertexShader
			#pragma fragment fragmentShader

			fixed4 _AmbientLightColor;
			float _AmbientLightIntensity;
			float3 _DiffuseDirection;
			float4 _DiffuseColor;
			float _DiffuseIntensity;

			struct VertexShaderInput{
				float4 position : POSITION;
				float3 normal : NORMAL;
			};

			struct VertexShaderOutput{
				float4 position : SV_POSITION;
				float3 normal : NORMAL;
			};

			//Input : VertexShaderInput
			//Output: VertexShaderOutput
			VertexShaderOutput vertexShader(VertexShaderInput vIn)
			{
				//The vertex position is multiplied
				//with the MVP matrices of Unity.
;				VertexShaderOutput vOut;
				vOut.position = UnityObjectToClipPos(vIn.position);
				vOut.normal = vIn.normal;

				return vOut;
			}

			//OUTPUT : A render target
			float4 fragmentShader(VertexShaderOutput vOut) : SV_Target
			{
				float diffuseFactor = saturate(dot(_DiffuseDirection, vOut.normal));
				return (_AmbientLightColor * _AmbientLightIntensity) +
						(diffuseFactor * _DiffuseColor *  _DiffuseIntensity);
			}

			ENDCG
		}
	}
}

Simple ShaderLab code for Flat color material


// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'</code>

Shader "Custom/SimpleShader" {
Properties {
  _AmbientLightColor("Ambient Light", Color) = (1,1,1,1)
  _AmbientLightIntensity("Ambient Light Intensity", Range(0.0,1.0)) = 1.0
}
SubShader
{
  Pass
  {
   CGPROGRAM

   #pragma vertex vertexShader
   #pragma fragment fragmentShader

   fixed4 _AmbientLightColor;
   float _AmbientLightIntensity;

   //Input : POSITION
   //Output: SV_POSITION
   float4 vertexShader(float4 v:POSITION) : SV_POSITION
   {
     //The vertex position is multiplied
     //with the MVP matrices of Unity.

     return UnityObjectToClipPos(v);
   }

   //OUTPUT : A render target
   fixed4 fragmentShader() : SV_Target
   {
     return _AmbientLightColor * _AmbientLightIntensity;
   }

   ENDCG
  }
 }
}

Function Pointers inside Struct in C

#include <stdio.h>

typedef struct{
	int x;
	int y;
	int (*addXPoints) (int x,int y);
	int (*subXPoints) (int x,int y);
}Point;

int addPoints_x(int p1, int p2)
{
		return (p1+p2);
}	

int subtracteXPoints(int p1,int p2)
{
		return (p1-p2);
}

void printPointDetails(Point* temp)
{
		printf("Point [x,y] : %d , %d \n", temp->x, temp->y);
}

int main()
{
	Point p1={30,30};
	
	//another way to initialize
	//p1.x=10; 
	//p1.y=20;
	p1.addXPoints=addPoints_x;
	p1.subXPoints=subtracteXPoints;
	
	printPointDetails(&p1);
	
	printf("Total X Value of p1,p2 : %d\n",p1.addXPoints(p1.x,p1.x));
	printf("Total X Value of p1,p2 : %d\n",p1.subXPoints(p1.x,p1.x));
	

	return 0;
}

Constant pointers and Pointers to constant in C

#include <stdio.h>
int main()
{
	int val = 250;
	int val2 =300;

        // ptrInt is a pointer to integer constant
        const int* ptrInt = &val; //Pointer to Constant

        // ptrInt1 is a constant pointer to integer
        int* const ptrInt1 = &val; //Constant Pointer

        *ptrInt = 500; //pointer to constant wont allow

	ptrInt1 = &val2; //constant pointer wont allow

	return 0;
}

Dual Assault

It is an endless top-down shooter game.The main objective of the game is to prevent the enemies from capturing the territory. Made using Unity3d.

 

Learn Sheet music

 

screenshotscreenshot (1)

screenshot (2)

Game screenshot

 

Made this android application for understanding game programming for mobile devices mainly Android. Used the core android sdk with eclipse. This educational game is for people who want to learn basics of staff sheet music. The user has to tell the name of the note as it appears on different lines in the staff. Score is calculated based on the percentage of correct answers.

Download link   :   Sheet Music for Android

Learn Music Notes – Cheat sheet

Staff notes.

Staff notes.

Alien shooter : A HTML 5 game

This game is developed in HTML 5 using canvas and Javascript. The objective of the game is to shoot all the enemies. The enemies also shoot at the player. The background is scrolled in order to give a fast moving action feel. Sprites are self made.

 

introScreen

This is the main menu

 

 

Game screen

Game screen

Download : https://app.box.com/s/7ualzgwo88nuqf5720ha

Tic Tac Toe game in C++

This is a tic tac toe game made in C++. The game starts with player choosing the symbol O (letter) or X.

The A.I is pretty much basic.

screenshot

Download Link:

https://app.box.com/s/dwdcz3uwnd5qfafypjrp

Rooting Lava Xtron android tablet

WARNING : It worked for me but still, do at your our risk. 

Lava Xtron is the only cheapest android tablet which has performance equalling nexus 7.  See the flipkart link below for more details

http://www.flipkart.com/lava-e-tab-xtron-tablet/p/itmdgjwxm7zfpxwc?pid=TABDHVNGHZGHYNME&ref=e7fa0475-6e55-491a-a704-9565f7810e15&srno=t_1&otracker=from-search&query=lava%20xtron

But the problem is that you dont get usb drivers for connecting it to your windows pc. More worse for developers, since it is impossible to perform adb tasks, app debugging ,etc.

Just follow these steps to root your xtron tablet.

A . Getting USB drivers

1.First, we need usb drivers so that our device gets detected.Install Moborobo which is an software for managing your device sms,videos,pics,etc

http://www.moborobo.com/products/moborobo.html

2.After installing it, connect your tablet and wait for it check your device for downloading necessary drivers.

3.Once connected vid USB, you should be able to see your device files, sd-card size in the moborobo desktop application.

NOTE : In moborobo software, Device model of the tablet will not be shown when detected. Its just a bug.Ignore it.

B . Rooting the device

1. Download the software  ZhuoDaShi-2.2.0-setup.exe . Sometimes your antivirus might block this. Deal with them.

https://hotfile.com/dl/165309989/766c52f/ZhuoDaShi-2.2.0-setup.exe.html

2.Since it is a japanese/chinese software, you may see some crazy instrution text while installing. Follow the screenshots below…

Installcaption

Screen 1

Screen 2

Screen 2

Screen 3

Screen 3

Screen 4

Screen 4

Screen 5

Screen 5

Screen 6

Screen 6

Screen 7: Installation is done

Screen 7: Installation is done

Screen 8 : This is the main screen. Click the mentioned icon

Screen 8 : This is the main screen. Click the mentioned icon. My AV is sneeking around..:-/..dont mind it

Screen 9 : When clicked, an app is intalled and opened on your device. You dont need to select anything on your device screen. Just follow the desktop instructions

Screen 9 : When clicked, an app is intalled and opened on your device. You dont need to select anything on your device screen. Just follow the desktop instructions

Screen 10: Click  root. On the next screen, you will see the script in action.

Screen 10: Click root. On the next screen, you will see the script in action.

Screen 11: At last ,rooting is done.

Screen 11: At last ,rooting is done.

Go to Play and download any root checking software to confirm your root status. Thats it….

Update: This tablet is out of production(Incase, you are planning to buy :/ )