Welcome, Guest.
Username: Password: Remember me

TOPIC: Can Someone port these ?

Can Someone port these ? 1 year 7 months ago #1

  • Kleio420
  • Kleio420's Avatar
  • Offline
  • Posts: 216
  • Thank you received: 28
If someone wouldn't mind porting these over.These were orginally ported to work for oblivion graphics mod.DLAA was used in starwars force unleashed and nfaa was posted on a game website few years ago.

DLAA
// .x - 1 / width
// .y - 1 / height
// .z - width * height
// .w - width / height
float4 oblv_ReciprocalResolution_MAINPASS;
 
// the current frame from before any effects are applied from this file
texture lastpass;
 
sampler2D currentFrameSampler = sampler_state
{
	texture = <lastpass>;
 
	AddressU = CLAMP;
	AddressV = CLAMP;
 
	MINFILTER = POINT;
	MAGFILTER = POINT;
};
 
struct VSOUT
{
	float4 vertPos : POSITION;
	float2 UVCoord : TEXCOORD0;
};
 
struct VSIN
{
	float4 vertPos : POSITION0;
	float2 UVCoord : TEXCOORD0;
};
 
VSOUT FrameVS(VSIN IN)
{
	VSOUT OUT = (VSOUT)0.0f;	// initialize to zero, avoid complaints.
 
	OUT.vertPos = IN.vertPos;
	OUT.UVCoord = IN.UVCoord;
 
	return OUT;
}
 
//
// Directionally Localized Anti-Aliasing (DLAA)
// by Dmitry Andreev
// Copyright (C) LucasArts 2010-2011
//
 
#define TFU2_HIGH_PASS
#define VECTORIZED_SEARCH
 
#define LD(o, dx, dy) o = tex2D(currentFrameSampler, tc + float2(dx, dy) * oblv_ReciprocalResolution_MAINPASS.xy);
 
static const bool bAA = 1;
static const bool bPreserveHf = 0;
 
//
 
float GetIntensity( const float3 rgb )
{
//  return dot( rgb, float3( 0.333f, 0.334f, 0.333f ) );
    return dot( rgb, float3( 0.299f, 0.587f, 0.114f ) );
}
 
//
 
float4 PreProcessPS(in float2 tc : TEXCOORD0) : COLOR0
{
    //
 
    float4 center, left, right, top, bottom;
 
    LD( center, 0,  0 )
    LD( left,  -1,  0 )
    LD( right,  1,  0 )
    LD( top,    0, -1 )
    LD( bottom, 0,  1 )
 
    float4 edges = 4.0f * abs( ( left + right + top + bottom ) - 4.0f * center );
    float  edges_lum = GetIntensity( edges.xyz );
 
    return float4( center.xyz, edges_lum );
}
 
//
 
float4 PostProcessPS(in float2 tc : TEXCOORD0) : COLOR0
{
    const float lambda = 3.0f;
    const float epsilon = 0.1f;
 
    //
    // Short Edges
    //
 
    float4 center, left_01, right_01, top_01, bottom_01;
 
    // sample 5x5 cross
    LD( center,      0,   0 )
    LD( left_01,  -1.5,   0 )
    LD( right_01,  1.5,   0 )
    LD( top_01,      0,-1.5 )
    LD( bottom_01,   0, 1.5 )
 
    if ( !bAA ) return center;
 
    float4 w_h = 2.0f * ( left_01 + right_01 );
    float4 w_v = 2.0f * ( top_01 + bottom_01 );
 
    #ifdef TFU2_HIGH_PASS
 
        // Softer (5-pixel wide high-pass)
        float4 edge_h = abs( w_h - 4.0f * center ) / 4.0f;
        float4 edge_v = abs( w_v - 4.0f * center ) / 4.0f;
 
    #else
 
        // Sharper (3-pixel wide high-pass)
        float4 left, right, top, bottom;
 
        LD( left,  -1,  0 )
        LD( right,  1,  0 )
        LD( top,    0, -1 )
        LD( bottom, 0,  1 )
 
        float4 edge_h = abs( left + right - 2.0f * center ) / 2.0f;
        float4 edge_v = abs( top + bottom - 2.0f * center ) / 2.0f;
 
    #endif
 
    float4 blurred_h = ( w_h + 2.0f * center ) / 6.0f;
    float4 blurred_v = ( w_v + 2.0f * center ) / 6.0f;
 
    float edge_h_lum = GetIntensity( edge_h.xyz );
    float edge_v_lum = GetIntensity( edge_v.xyz );
    float blurred_h_lum = GetIntensity( blurred_h.xyz );
    float blurred_v_lum = GetIntensity( blurred_v.xyz );
 
    float edge_mask_h = saturate( ( lambda * edge_h_lum - epsilon ) / blurred_v_lum );
    float edge_mask_v = saturate( ( lambda * edge_v_lum - epsilon ) / blurred_h_lum );
 
    float4 clr = center;
    clr = lerp( clr, blurred_h, edge_mask_v );
    clr = lerp( clr, blurred_v, edge_mask_h * 0.5f ); // TFU2 uses 1.0f instead of 0.5f
 
    //
    // Long Edges
    //
 
    float4 h0, h1, h2, h3, h4, h5, h6, h7;
    float4 v0, v1, v2, v3, v4, v5, v6, v7;
 
    // sample 16x16 cross (sparse-sample on X360, incremental kernel update on SPUs)
    LD( h0, 1.5, 0 ) LD( h1, 3.5, 0 ) LD( h2, 5.5, 0 ) LD( h3, 7.5, 0 ) LD( h4, -1.5,0 ) LD( h5, -3.5,0 ) LD( h6, -5.5,0 ) LD( h7, -7.5,0 )
    LD( v0, 0, 1.5 ) LD( v1, 0, 3.5 ) LD( v2, 0, 5.5 ) LD( v3, 0, 7.5 ) LD( v4, 0,-1.5 ) LD( v5, 0,-3.5 ) LD( v6, 0,-5.5 ) LD( v7, 0,-7.5 )
 
    float long_edge_mask_h = ( h0.a + h1.a + h2.a + h3.a + h4.a + h5.a + h6.a + h7.a ) / 8.0f;
    float long_edge_mask_v = ( v0.a + v1.a + v2.a + v3.a + v4.a + v5.a + v6.a + v7.a ) / 8.0f;
 
    long_edge_mask_h = saturate( long_edge_mask_h * 2.0f - 1.0f );
    long_edge_mask_v = saturate( long_edge_mask_v * 2.0f - 1.0f );
 
//  if ( long_edge_mask_h > 0 || long_edge_mask_v > 0 )		// faster but less resistant to noise (TFU2 X360)
    if ( abs( long_edge_mask_h - long_edge_mask_v ) > 0.2f )	// resistant to noise (TFU2 SPUs)
    {
        float4 left, right, top, bottom;
 
        LD( left,  -1,  0 )
        LD( right,  1,  0 )
        LD( top,    0, -1 )
        LD( bottom, 0,  1 )
 
        float4 long_blurred_h = ( h0 + h1 + h2 + h3 + h4 + h5 + h6 + h7 ) / 8.0f;
        float4 long_blurred_v = ( v0 + v1 + v2 + v3 + v4 + v5 + v6 + v7 ) / 8.0f;
 
        float lb_h_lum   = GetIntensity( long_blurred_h.xyz );
        float lb_v_lum   = GetIntensity( long_blurred_v.xyz );
 
        float center_lum = GetIntensity( center.xyz );
        float left_lum   = GetIntensity( left.xyz );
        float right_lum  = GetIntensity( right.xyz );
        float top_lum    = GetIntensity( top.xyz );
        float bottom_lum = GetIntensity( bottom.xyz );
 
        float4 clr_v = center;
        float4 clr_h = center;
 
        #ifdef VECTORIZED_SEARCH
 
            // vectorized search (X360 GPU and SPU implementation friendly)
            float hx = saturate( 0 + ( lb_h_lum - top_lum    ) / ( center_lum - top_lum    ) );
            float hy = saturate( 1 + ( lb_h_lum - center_lum ) / ( center_lum - bottom_lum ) );
            float vx = saturate( 0 + ( lb_v_lum - left_lum   ) / ( center_lum - left_lum   ) );
            float vy = saturate( 1 + ( lb_v_lum - center_lum ) / ( center_lum - right_lum  ) );
 
            float4 vhxy = float4( vx, vy, hx, hy );
            vhxy = vhxy == float4( 0, 0, 0, 0 ) ? float4( 1, 1, 1, 1 ) : vhxy;
 
            clr_v = lerp( left  , clr_v, vhxy.x );
            clr_v = lerp( right , clr_v, vhxy.y );
            clr_h = lerp( top   , clr_h, vhxy.z );
            clr_h = lerp( bottom, clr_h, vhxy.w );
 
        #else
 
            // naive search
            float hx = saturate( ( lb_h_lum - top_lum    ) / ( center_lum - top_lum    ) );
            float hy = saturate( ( lb_h_lum - center_lum ) / ( bottom_lum - center_lum ) );
            float vx = saturate( ( lb_v_lum - left_lum   ) / ( center_lum - left_lum   ) );
            float vy = saturate( ( lb_v_lum - center_lum ) / ( right_lum  - center_lum ) );
 
            if ( hx == 0 ) hx = 1;
            if ( vx == 0 ) vx = 1;
 
            clr_v = lerp( left, clr_v, vx );
            if ( vy < 1 ) clr_v = lerp( clr_v, right, vy );
 
            clr_h = lerp( top, clr_h, hx );
            if ( hy < 1 ) clr_h = lerp( clr_h, bottom, hy );
 
        #endif
 
        clr = lerp( clr, clr_v, long_edge_mask_v );
        clr = lerp( clr, clr_h, long_edge_mask_h );
    }
 
    //
    // Preserve high frequencies (not used in TFU2)
    //
 
    if ( bPreserveHf )
    {
        float4 r0, r1;
        float4 r2, r3;
 
        LD( r0, -1.5, -1.5 )
        LD( r1,  1.5, -1.5 )
        LD( r2, -1.5,  1.5 )
        LD( r3,  1.5,  1.5 )
 
        // faster version
        //r0 = top_01;
        //r1 = bottom_01;
        //r2 = left_01;
        //r3 = right_01;
 
        float4 r = ( 4.0f * ( r0 + r1 + r2 + r3 ) + center + top_01 + bottom_01 + left_01 + right_01 ) / 25.0f;
        clr = lerp( clr, center, saturate( r.a * 3.0f - 1.5f ) );
    }
 
    return clr;
}
 
technique PostProcess
<
	int group = EFFECTGROUP_PRE;
	int fxclass = EFFECTCLASS_NEUTRAL;
>
{
    pass p0
    {
        VertexShader = compile vs_3_0 FrameVS();
        PixelShader = compile ps_3_0 PreProcessPS();
    }
 
    pass p1
    {
        VertexShader = compile vs_3_0 FrameVS();
        PixelShader = compile ps_3_0 PostProcessPS();
    }
 
}



NFAA(normal map filtering aa)
///////////////////////////////////////////////////////////////////////////
////////////////////////// NORMAL Filter AA SHADER ////////////////////////
///////////////////////////////////////////////////////////////////////////
 
// The Normal Filter Anti Aliasing (NFAA) shader attempts to reduce obvious
// alising by searching for contrasting luminosity changes in the final
// render image. It then builds a normal displament map to apply a
// per-pixel blur filter in high contrast alised areas.
 
// Based on Styves implimentation at GemeDev.net
// http://www.gamedev.net/community/forums/topic.asp?topic_id=580517
 
// OBGEv2 port by Dracusis aka Cameron Owen
// Version 1.1 2010/10/29
 
///////////////////////////////////////////////////
// EDIT THE VALUES BELOW TO CUSTOMISE THE FILTER //
///////////////////////////////////////////////////
 
// Filter Strength Adjusts the overall power of the filter.
// Values in the range of 0.5 to 1.5 should provide good results without
// blurring the overal image too much. Anything higher will also likely
// cause ugly blocky or spikey artifacts.
// Default Value = 1.0;
 
extern float filterStrength = 1.0;
 
 
// Filter Spread controls how large an area the filter tries to sample
// and fix aliasing within. This has a direct relationship to the angle
// of lines the filter can smooth well. A 45 degree line will be perfectly
// alised with a spread of 2.0, steeper lines will need higher
// values. The tradeoff for setting a high spread value is the overall
// softness of the image. Values between 2.0 and 5.0 work best.
// Default Value = 3.0;
 
extern float filterSpread = 3.0;
 
// This adjusts whether or not the filter works on pixel color or pixel
// luminance. Using pixel color gives better results with lower
// contrasting aliasing areas but can over soften the whole scene a bit.
// Set to false to use pixel luminance method if you're only concerned
// with high contrast aliasing or if you find the colour version
// makes everything too blurry.
// Default Value = true;
 
#define USE_COLOR
 
// Set Debug to true to see the normal map used to apply the blur filter.
// Use this with the OBSE.ini bRenderHalfScreen=1 setting to get a feel
// for how the filter works. Default Value = false;
 
#undef	TEST_MODE
 
 
////////////////////////////////////////
// DO NOT EDIT VALUES PAST THIS POINT //
////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
 
#define	rcpres	oblv_ReciprocalResolution_MAINPASS.xy
// .x - 1 / width
// .y - 1 / height
// .z - width / height
// .w - width * height
float4 oblv_ReciprocalResolution_MAINPASS;
 
 
texture  obge_LastRendertarget0_EFFECTPASS;
 
sampler FrameSampler = sampler_state {
	texture = <obge_LastRendertarget0_EFFECTPASS>;
 
	AddressU = CLAMP;
	AddressV = CLAMP;
 
	MINFILTER = LINEAR;
	MAGFILTER = LINEAR;
	MIPFILTER = NONE;
};
 
///////////////////
// VERTEX SHADER //
///////////////////
 
struct VSOUT
{
	float4 vertPos : POSITION;
	float2 UVCoord : TEXCOORD0;
};
 
struct VSIN
{
	float4 vertPos : POSITION0;
	float2 UVCoord : TEXCOORD0;
};
 
VSOUT FrameVS(VSIN IN)
{
	VSOUT OUT = (VSOUT)0.0f;	// initialize to zero, avoid complaints.
	OUT.vertPos = IN.vertPos;
	OUT.UVCoord = IN.UVCoord;
	return OUT;
}
 
 
//////////////////
// PIXEL SHADER //
//////////////////
 
 
// Luminance Conversion
float GetColorLuminance( float3 i_vColor ) {
	return dot( i_vColor, float3( 0.2126f, 0.7152f, 0.0722f ) );
}
 
float2 findContrastByLuminance(float2 XYCoord, float filterStrength2) {
 
	// Normal offsets, scale by filter spread
	float2 upOffset    = float2(0, rcpres.y) * filterSpread;
	float2 rightOffset = float2(rcpres.x, 0) * filterSpread;
 
	float topHeight         = GetColorLuminance( tex2D( FrameSampler, XYCoord +               upOffset).rgb );
	float bottomHeight      = GetColorLuminance( tex2D( FrameSampler, XYCoord -               upOffset).rgb );
	float rightHeight       = GetColorLuminance( tex2D( FrameSampler, XYCoord + rightOffset           ).rgb );
	float leftHeight        = GetColorLuminance( tex2D( FrameSampler, XYCoord - rightOffset           ).rgb );
	float leftTopHeight     = GetColorLuminance( tex2D( FrameSampler, XYCoord - rightOffset + upOffset).rgb );
	float leftBottomHeight  = GetColorLuminance( tex2D( FrameSampler, XYCoord - rightOffset - upOffset).rgb );
	float rightBottomHeight = GetColorLuminance( tex2D( FrameSampler, XYCoord + rightOffset + upOffset).rgb );
	float rightTopHeight    = GetColorLuminance( tex2D( FrameSampler, XYCoord + rightOffset - upOffset).rgb );
 
	// Normal map creation
	float sum0 = rightTopHeight    + bottomHeight + leftTopHeight;
	float sum1 = leftBottomHeight  + topHeight    + rightBottomHeight;
	float sum2 = leftTopHeight     + rightHeight  + leftBottomHeight;
	float sum3 = rightBottomHeight + leftHeight   + rightTopHeight;
 
	// Subtract the opposite sample set for final vectors
	float vec1 = (sum0 - sum1) * filterStrength2;
	float vec2 = (sum3 - sum2) * filterStrength2;
 
	float2 Vectors = float2(vec1,vec2);
 
	return  Vectors;
 
}
 
float2 findContrastByColor(float2 XYCoord, float filterStrength2) {
 
	// Normal offsets, scale by filter spread
	float2 upOffset    = float2(0, rcpres.y) * filterSpread;
	float2 rightOffset = float2(rcpres.x, 0) * filterSpread;
 
	float3 topHeight         = tex2D( FrameSampler, XYCoord +               upOffset).rgb;
	float3 bottomHeight      = tex2D( FrameSampler, XYCoord -               upOffset).rgb;
	float3 rightHeight       = tex2D( FrameSampler, XYCoord + rightOffset           ).rgb;
	float3 leftHeight        = tex2D( FrameSampler, XYCoord - rightOffset           ).rgb;
	float3 leftTopHeight     = tex2D( FrameSampler, XYCoord - rightOffset + upOffset).rgb;
	float3 leftBottomHeight  = tex2D( FrameSampler, XYCoord - rightOffset - upOffset).rgb;
	float3 rightBottomHeight = tex2D( FrameSampler, XYCoord + rightOffset + upOffset).rgb;
	float3 rightTopHeight    = tex2D( FrameSampler, XYCoord + rightOffset - upOffset).rgb;
 
	// Normal map creation
	float3 sum0 = rightTopHeight    + bottomHeight + leftTopHeight;
	float3 sum1 = leftBottomHeight  + topHeight    + rightBottomHeight;
	float3 sum2 = leftTopHeight     + rightHeight  + leftBottomHeight;
	float3 sum3 = rightBottomHeight + leftHeight   + rightTopHeight;
 
	// Subtract the opposite sample set for final vectors
	float vec1 = length(sum0 - sum1) * filterStrength2;
	float vec2 = length(sum3 - sum2) * filterStrength2;
 
	float2 Vectors = float2(vec1,vec2);
 
	return  Vectors;
 
}
 
float4 NormalAAPS(VSOUT IN) : COLOR0 {
 
	float filterStrength2 = filterStrength + (filterSpread/2);
 
#ifdef USE_COLOR
	// Find Contrast By Colour
	float2 Vectors = findContrastByColor(IN.UVCoord.xy, filterStrength2);
#else
	// Find Contrast By Luminance
	float2 Vectors = findContrastByLuminance(IN.UVCoord.xy, filterStrength2);
#endif
 
	float filterClamp = filterStrength2/filterSpread;
 
	Vectors.xy = clamp(Vectors, -float2(filterClamp,filterClamp), float2(filterClamp,filterClamp));
 
	float2 Normal = float2(Vectors.x,Vectors.y) * rcpres;
//	Normal.xy *= 2;
 
	float4 Scene0 = tex2D( FrameSampler, IN.UVCoord.xy );
	float4 Scene1 = tex2D( FrameSampler, IN.UVCoord.xy + Normal.xy );
	float4 Scene2 = tex2D( FrameSampler, IN.UVCoord.xy - Normal.xy );
	float4 Scene3 = tex2D( FrameSampler, IN.UVCoord.xy + float2(Normal.x, -Normal.y) );
	float4 Scene4 = tex2D( FrameSampler, IN.UVCoord.xy - float2(Normal.x, -Normal.y) );
 
	// Final color
	float4 o_Color = (Scene0 + Scene1 + Scene2 + Scene3 + Scene4) * 0.2;
 
#ifdef	TEST_MODE
	// Debug Output
	o_Color.xyz = normalize(float3(Vectors.x, Vectors.y, 1) * 0.5 + 0.5);
#endif
 
	return o_Color;
 
}
 
 
 
///////////////////
// RENDER PASSES //
///////////////////
 
technique t0
<
	int group = EFFECTGROUP_PRE;
	int fxclass = EFFECTCLASS_NEUTRAL;
>
{
	pass p0 {
		VertexShader = compile vs_3_0 FrameVS();
		PixelShader  = compile ps_3_0 NormalAAPS();
	}
}
Last Edit: 1 year 7 months ago by Kleio420.
The administrator has disabled public write access.

Can Someone port these ? 1 year 6 months ago #2

  • Kleio420
  • Kleio420's Avatar
  • Offline
  • Posts: 216
  • Thank you received: 28
idk if anyone else would find use for these , user on unity forums has added a updated NFAA he says he improved it i wouldnt know but here is the code new or not.

@script ExecuteInEditMode

@script RequireComponent (Camera)
@script AddComponentMenu ("Image Effects/NFAA")

class NFAA extends PostEffectsBase {
	
	public var edgeDetectHqShader : Shader;
	private var _edgeDetectHqMaterial : Material = null;	
	public var sensitivityDepth : float = 100.0f;


	function CreateMaterials () 
	{
	_edgeDetectHqMaterial = CheckShaderAndCreateMaterial(edgeDetectHqShader,_edgeDetectHqMaterial);	
	}
	
	function Start () 
	{
		CreateMaterials();
		CheckSupport(false);
	}
	


	function OnRenderImage (source : RenderTexture, destination : RenderTexture)
	{	
		CreateMaterials ();

			_edgeDetectHqMaterial.SetFloat("_texWidth", Screen.width);
		_edgeDetectHqMaterial.SetFloat("_texHeight", Screen.height);
		_edgeDetectHqMaterial.SetFloat ("sensitivity", sensitivityDepth);
		Graphics.Blit (source, destination, _edgeDetectHqMaterial);	

		
			}
	}


Shader "Hidden/NFAA" {
Properties {
	_MainTex ("Base (RGB)", 2D) = "white" {}
		_BlurTex ("Base (RGB)", 2D) = "white" {}

}

SubShader {
	Pass {
		ZTest Always Cull Off ZWrite Off
		Fog { Mode off }

CGPROGRAM



#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest 

#include "UnityCG.cginc"

uniform sampler2D _MainTex;


sampler2D _CameraDepthNormalsTexture;
uniform float4 _MainTex_TexelSize;
uniform float _debug;
uniform float sensitivity; 
uniform float _texWidth; 
uniform float _texHeight; 


struct v2f {
	float4 pos : POSITION;
	float4 uv1 : TEXCOORD0;
};

v2f vert( appdata_img v )
{
	v2f o;
	o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
	float2 uv = v.texcoord.xy;
	o.uv1.xy = uv;
	
	#if SHADER_API_D3D9
	if (_MainTex_TexelSize.y < 0)
		uv.y = 1-uv.y;
	#endif

	return o;
}



half4 frag (v2f i) : COLOR
{
float2 vPixelViewport = float2( 1.0f / _texWidth, 1.0f / _texHeight );
half4 center = tex2D(_CameraDepthNormalsTexture, i.uv1.xy);
float Depth = DecodeFloatRG (center.zw);
float2 upOffset = float2( 0.0f,vPixelViewport.y)*0.009;
float2 rightOffset = float2(vPixelViewport.x, 0.0f )*0.009;





float topHeight = Luminance( tex2D( _MainTex, i.uv1.xy+upOffset).rgb );
float bottomHeight = Luminance( tex2D( _MainTex, i.uv1.xy-upOffset).rgb );
float rightHeight = Luminance( tex2D( _MainTex, i.uv1.xy+rightOffset).rgb );
float leftHeight = Luminance( tex2D( _MainTex, i.uv1.xy-rightOffset).rgb );
float leftTopHeight =Luminance( tex2D( _MainTex, i.uv1.xy-rightOffset+upOffset).rgb );
float leftBottomHeight = Luminance( tex2D( _MainTex, i.uv1.xy-rightOffset-upOffset).rgb );
float rightBottomHeight = Luminance( tex2D( _MainTex, i.uv1.xy+rightOffset+upOffset).rgb );
float rightTopHeight = Luminance( tex2D(_MainTex, i.uv1.xy+rightOffset-upOffset).rgb );

//float sum0 = rightTopHeight+ topHeight + rightBottomHeight;
//float sum1 = leftTopHeight + bottomHeight + leftBottomHeight;
//float sum2 = leftTopHeight + leftHeight + rightTopHeight;
//float sum3 = leftBottomHeight + rightHeight + rightBottomHeight ;

float sum0 = rightTopHeight+ bottomHeight + leftTopHeight;
float sum1 = leftBottomHeight + topHeight + rightBottomHeight;
float sum2 = leftTopHeight + rightHeight + leftBottomHeight;
float sum3 = rightBottomHeight + leftHeight + rightTopHeight ;


float vec1 = (sum0 - sum1) * sensitivity.x;
float vec2 = (sum3 - sum2) * sensitivity.x;

float2 Normal = float2( vec1, vec2) *vPixelViewport*(2-Depth);
//Normal.xy = clamp(Normal,-float2(1.0,1.0)*0.01,float2(1.0,1.0)*0.01);
float4 Scene0 = tex2D( _MainTex, i.uv1.xy );
float4 Scene1 = tex2D(  _MainTex, i.uv1.xy + Normal.xy );
float4 Scene2 = tex2D(  _MainTex, i.uv1.xy - Normal.xy );
float4 Scene3 = tex2D(  _MainTex, i.uv1.xy + float2(Normal.x, -Normal.y) );
float4 Scene4 = tex2D(  _MainTex, i.uv1.xy - float2(Normal.x, -Normal.y) );


// Final color
float4 o_Color = (Scene0 + Scene1 + Scene2 + Scene3 + Scene4) * 0.2;

// using vec1 and vec2 for the debug output as Normal won't display anything (due to the pixel scale applied to it).
return o_Color;
}
ENDCG
	}
}

Fallback off

}
The administrator has disabled public write access.