Instagram Shader

Here you can share your work with other users.

Moderator: Support

Post Reply
pyrrr
Posts: 34
Joined: 13 May 2012, 15:50

Instagram Shader

Post by pyrrr » 07 Jul 2012, 15:47

instagam.JPG
To create this kind of "look" you need to use a renderpass as texture for an overlay shows in the image below
overlay.JPG
the code for the shader are

Code: Select all


//
//		postwendend.com
//		kontakt@postwendend.com
//		published under:
//		http://creativecommons.org/licenses/by-sa/3.0/
//		


// variables
sampler2D post_img;

bool sw;

float r = 1;
float g = 1;
float b = 1;

float r_contrast = 1;
float g_contrast = 1;
float b_contrast = 1;

float brightness  = 1;
float contrast  = 1;

bool ca;
float ca_r = 0;
float ca_g = 0;
float ca_b = 0;

bool vigenttierung;
float radius = 10;
float darkness = 1;



// pixelshader

float4 cc( float2 Tex : TEXCOORD0 ) : color0
{
	
	// define the texture
	float4 color;
	
	if (ca) 
	{
		//input.UV = (input.UV - scaleCenter) * scale + scaleCenter;


		float2 tex_ca = Tex;
		float2 center = float2(0.5f, 0.5f);
		
		tex_ca = (Tex.xy - center ) * (ca_r/10+1.0f) + center;
		float4 color_r = tex2D( post_img, tex_ca);
		
		tex_ca = (Tex.xy - center ) * (ca_g/10+1.0f) + center;
		float4 color_b = tex2D( post_img, tex_ca);
		
		tex_ca = (Tex.xy - center ) * (ca_b/10+1.0f) + center;
		float4 color_g = tex2D( post_img, tex_ca);
		
		color.r = color_r.r;
		color.g = color_g.g;
		color.b = color_b.b;
		
		
		
	}
	else
	{
		color = tex2D( post_img, Tex.xy);
	}
	
	
	// brightness + contrast for each r g b channel
	color.r = (((color.r -0.5f) * max(r_contrast, 0)) + 0.5f)+(r-1.0f);  
	color.g = (((color.g -0.5f) * max(g_contrast, 0)) + 0.5f)+(g-1.0f);  
	color.b = (((color.b -0.5f) * max(b_contrast, 0)) + 0.5f)+(b-1.0f);  	
	
	// brightness + contrast for all channels
	color.rgb = (((color.rgb -0.5f) * max(contrast, 0)) + 0.5f)+(brightness-1.0f);  
	
	if (vigenttierung) {
		float2 inTex = Tex - 0.5; 
		float vignette  = 1 - dot(inTex, inTex);
		color.rgb    *= saturate(pow(vignette, radius) + darkness);
	}
	
	if (sw)
	{
		color.rgb = (color.r + color.g + color.b ) / 3;
	}
	
	
	
	return color;
}

technique post
{
	pass p1
	{
		VertexShader = null;
		PixelShader = compile ps_2_0 cc();
	}

}

Post Reply