Black and White

From GameStudio Wiki

Jump to: navigation, search

Lite-C:


The material for the effect:

// Black and White
MATERIAL* BlackAndWhite_mat =
{
	effect = "blackandwhite.fx";
}

The blackandwhite.fx file:

/////////////////////////////////
/////black and white effect//////
/////////////////////////////////

texture TargetMap;
sampler smpSource = sampler_state { texture = <TargetMap>; };

float4 BlackWhite_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
	float4 Color;

	Color.a = 1.0f;
	Color = tex2D( smpSource, Tex.xy);
	Color.rgb = (Color.r+Color.g+Color.b)/3.0f;

	if (Color.r < 0.5)
		Color.r = 0.0f;
	else
		Color.r = 1.0f;

	Color.gb = Color.r;
	
	return Color;
}

technique tech_00
{
	pass pass_00
	{
		VertexShader = null;
		PixelShader = compile ps_2_0 BlackWhite_PS();
	}
}

technique fallback { pass one { } }


C-Script


The material for the effect:

// Black and White
material BlackAndWhite_mat
{
	effect = "blackandwhite.fx";
}

The blackandwhite.fx file:

/////////////////////////////////
/////black and white effect//////
/////////////////////////////////

texture entSkin1;
sampler postTex = sampler_state
{
   texture = (entSkin1);
   MinFilter = linear;
   MagFilter = linear;
   MipFilter = linear;
   AddressU = Clamp;
   AddressV = Clamp;
};

float4 BlackWhite_PS( float2 Tex : TEXCOORD0 ) : COLOR0
{
	float4 Color;

	Color.a = 1.0f;
	Color = tex2D( postTex, Tex.xy);
	Color.rgb = (Color.r+Color.g+Color.b)/3.0f;

	if (Color.r < 0.5)
		Color.r = 0.0f;
	else
		Color.r = 1.0f;

	Color.gb = Color.r;
	
	return Color;
}

technique tech_00
{
	pass pass_00
	{
		VertexShader = null;
		PixelShader = compile ps_2_0 BlackWhite_PS();
	}
}

technique tech_01
{
	pass pass_00
	{
		Texture[0] = <entSkin1>;
	}
}

--Slin 23:34, 10 November 2007 (CET)

Personal tools