#include
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "scene";
string ScriptOrder = "postprocess";
string ScriptOutput = "color";
string Script = "Technique=Main;";
> = 0.8; // version #
float4 ClearColor <
string UIWidget = "color";
string UIName = "Background";
> = {0.1,0.1,0.1,0.0};
float ClearDepth = 1.0;
///////////////////////////////////////////////////////////
/////////////////////////////////////// Textures //////////
///////////////////////////////////////////////////////////
DECLARE_QUAD_TEX(SceneTexture,SceneSampler,"A8R8G8B8")
DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer,"D24S8")
//////////////////////////////////////////////////////
/////////////////////////////////// pixel shader /////
//////////////////////////////////////////////////////
QUAD_REAL4 FromCMYK(QuadVertexOutput IN) : COLOR
{
CREAL4 cmyk = tex2D(SceneSampler, IN.UV);
return QUAD_REAL4(cmyk2rgb(cmyk),1); // we lose alpha....
}
////////////////////////////////////////////////////////////
/////////////////////////////////////// techniques /////////
////////////////////////////////////////////////////////////
technique Main <
string Script =
"RenderColorTarget0=SceneTexture;"
"RenderDepthStencilTarget=DepthBuffer;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"
"Pass=Convert;";
> {
pass Convert <
string Script = "RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"Draw=Buffer;";
> {
VertexShader = compile vs_2_0 ScreenQuadVS();
ZEnable = false;
AlphaBlendEnable = false;
PixelShader = compile ps_2_a FromCMYK();
}
}
]]>; \
sampler SampName = sampler_state { \
texture = ; \
AddressU = AddrMode; \
AddressV = AddrMode; \
MipFilter = LINEAR; \
MinFilter = LINEAR; \
MagFilter = LINEAR; \
};
//
// Simple 2D File Textures
//
// example usage: FILE_TEXTURE_2D(GlowMap,GlowSampler,"myfile.dds")
//
#define FILE_TEXTURE_2D(TextureName,SamplerName,Diskfile) FILE_TEXTURE_2D_MODAL(TextureName,SamplerName,(Diskfile),WRAP)
//
// Use this variation of DECLARE_QUAD_TEX() if you want a *scaled* render target
//
// example usage: DECLARE_SIZED_QUAD_TEX(GlowMap,GlowSampler,"A8R8G8B8",1.0)
#define DECLARE_SIZED_QUAD_TEX(TexName,SampName,PixFmt,Multiple) texture TexName : RENDERCOLORTARGET < \
float2 ViewPortRatio = {Multiple,Multiple}; \
int MipLevels = 1; \
string Format = PixFmt ; \
string UIWidget = "None"; \
>; \
sampler SampName = sampler_state { \
texture = ; \
AddressU = CLAMP; \
AddressV = CLAMP; \
MipFilter = POINT; \
MinFilter = LINEAR; \
MagFilter = LINEAR; \
};
//
// Use this macro to easily declare typical color render targets
//
// example usage: DECLARE_QUAD_TEX(ObjMap,ObjSampler,"A8R8G8B8")
#define DECLARE_QUAD_TEX(TextureName,SamplerName,PixelFormat) DECLARE_SIZED_QUAD_TEX(TextureName,SamplerName,(PixelFormat),1.0)
//
// Use this macro to easily declare variable-sized depth render targets
//
// example usage: DECLARE_SIZED_QUAD_DEPTH_BUFFER(DepthMap,"D24S8",0.5)
#define DECLARE_SIZED_QUAD_DEPTH_BUFFER(TextureName,PixelFormat,Multiple) texture TextureName : RENDERDEPTHSTENCILTARGET < \
float2 ViewPortRatio = {Multiple,Multiple}; \
string Format = (PixelFormat); \
string UIWidget = "None"; \
>;
//
// Use this macro to easily declare typical depth render targets
//
// example usage: DECLARE_QUAD_DEPTH_BUFFER(DepthMap,"D24S8")
#define DECLARE_QUAD_DEPTH_BUFFER(TexName,PixFmt) DECLARE_SIZED_QUAD_DEPTH_BUFFER(TexName,PixFmt,1.0)
//
// declare exact-sized arbitrary texture
//
// example usage: DECLARE_SIZED_TEX(BlahMap,BlahSampler,"R32F",128,1)
#define DECLARE_SIZED_TEX(Tex,Samp,Fmt,Wd,Ht) texture Tex : RENDERCOLORTARGET < \
float2 Dimensions = { Wd, Ht }; \
string Format = Fmt ; \
string UIWidget = "None"; \
int miplevels=1;\
>; \
sampler Samp = sampler_state { \
texture = ; \
AddressU = CLAMP; \
AddressV = CLAMP; \
MipFilter = NONE; \
MinFilter = LINEAR; \
MagFilter = LINEAR; \
};
//
// declare exact-sized square texture, as for shadow maps
//
// example usage: DECLARE_SQUARE_QUAD_TEX(ShadMap,ShadObjSampler,"A16R16G16B16F",512)
#define DECLARE_SQUARE_QUAD_TEX(TexName,SampName,PixFmt,Size) DECLARE_SIZED_TEX(TexName,SampName,(PixFmt),Size,Size)
//
// likewise for shadow depth targets
//
// example usage: DECLARE_SQUARE_QUAD_DEPTH_BUFFER(ShadDepth,"D24S8",512)
#define DECLARE_SQUARE_QUAD_DEPTH_BUFFER(TextureName,PixelFormat,Size) texture TextureName : RENDERDEPTHSTENCILTARGET < \
float2 Dimensions = { Size, Size }; \
string Format = (PixelFormat) ; \
string UIWidget = "None"; \
>;
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// Utility Functions ////////
////////////////////////////////////////////////////////////////////////////
//
// Scale inputs for use with texture-based lookup tables. A value ranging from zero to one needs
// a slight scaling and offset to be sure to point at the centers of the first and last pixels
// of that lookup texture. Pass the integer size of the table in TableSize
// For now we'll assume that all tables are 1D, square, or cube-shaped -- all axes of equal size
//
// Cost of this operation for pixel shaders: two const-register
// entries and a MAD (one cycle)
QUAD_REAL scale_lookup(QUAD_REAL Value,const QUAD_REAL TableSize)
{
QUAD_REAL scale = ((TableSize - 1.0)/TableSize);
QUAD_REAL shift = (0.5 / TableSize);
return (scale*Value + shift);
}
QUAD_REAL2 scale_lookup(QUAD_REAL2 Value,const QUAD_REAL TableSize)
{
QUAD_REAL scale = ((TableSize - 1.0)/TableSize);
QUAD_REAL shift = (0.5 / TableSize);
return (scale.xx*Value + shift.xx);
}
QUAD_REAL3 scale_lookup(QUAD_REAL3 Value,const QUAD_REAL TableSize)
{
QUAD_REAL scale = ((TableSize - 1.0)/TableSize);
QUAD_REAL shift = (0.5 / TableSize);
return (scale.xxx*Value + shift.xxx);
}
// pre-multiply and un-pre-mutliply functions. The precision
// of thse operatoions is often limited to 8-bit so don't
// always count on them!
// The macro value of NV_ALPHA_EPSILON, if defined, is used to
// avoid IEEE "NaN" values that may occur when erroneously
// dividing by a zero alpha (thanks to Pete Warden @ Apple
// Computer for the suggestion in GPU GEMS II)
// multiply color by alpha to turn an un-premultipied
// pixel value into a premultiplied one
QUAD_REAL4 premultiply(QUAD_REAL4 C)
{
return QUAD_REAL4((C.w*C.xyz),C.w);
}
#define NV_ALPHA_EPSILON 0.0001
// given a premultiplied pixel color, try to undo the premultiplication.
// beware of precision errors
QUAD_REAL4 unpremultiply(QUAD_REAL4 C)
{
#ifdef NV_ALPHA_EPSILON
QUAD_REAL a = C.w + NV_ALPHA_EPSILON;
return QUAD_REAL4((C.xyz / a),C.w);
#else /* ! NV_ALPHA_EPSILON */
return QUAD_REAL4((C.xyz / C.w),C.w);
#endif /* ! NV_ALPHA_EPSILON */
}
/////////////////////////////////////////////////////////////////////////////////////
// Structure Declaration ////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
struct QuadVertexOutput {
QUAD_REAL4 Position : POSITION;
QUAD_REAL2 UV : TEXCOORD0;
};
/////////////////////////////////////////////////////////////////////////////////////
// Hidden tweakables declared by this .fxh file /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
#ifndef NO_TEXEL_OFFSET
#ifdef TWEAKABLE_TEXEL_OFFSET
QUAD_REAL QuadTexOffset = 0.5;
#else /* !TWEAKABLE_TEXEL_OFFSET */
QUAD_REAL QuadTexOffset < string UIWidget="None"; > = 0.5;
#endif /* !TWEAKABLE_TEXEL_OFFSET */
QUAD_REAL2 QuadScreenSize : VIEWPORTPIXELSIZE < string UIWidget="None"; >;
#endif /* NO_TEXEL_OFFSET */
////////////////////////////////////////////////////////////
////////////////////////////////// vertex shaders //////////
////////////////////////////////////////////////////////////
QuadVertexOutput ScreenQuadVS(
QUAD_REAL3 Position : POSITION,
QUAD_REAL3 TexCoord : TEXCOORD0
) {
QuadVertexOutput OUT;
OUT.Position = QUAD_REAL4(Position, 1);
#ifdef NO_TEXEL_OFFSET
OUT.UV = TexCoord.xy;
#else /* NO_TEXEL_OFFSET */
QUAD_REAL2 off = QUAD_REAL2(QuadTexOffset/(QuadScreenSize.x),QuadTexOffset/(QuadScreenSize.y));
OUT.UV = QUAD_REAL2(TexCoord.xy+off);
#endif /* NO_TEXEL_OFFSET */
return OUT;
}
//////////////////////////////////////////////////////
////////////////////////////////// pixel shaders /////
//////////////////////////////////////////////////////
// add glow on top of model
QUAD_REAL4 TexQuadPS(QuadVertexOutput IN,uniform sampler2D InputSampler) : COLOR
{
QUAD_REAL4 texCol = tex2D(InputSampler, IN.UV);
return texCol;
}
QUAD_REAL4 TexQuadBiasPS(QuadVertexOutput IN,uniform sampler2D InputSampler,QUAD_REAL TBias) : COLOR
{
QUAD_REAL4 texCol = tex2Dbias(InputSampler, QUAD_REAL4(IN.UV,0,TBias));
return texCol;
}
//////////////////////////////////////////////////////////////////
/// Macros to define passes within Techniques ////////////////////
//////////////////////////////////////////////////////////////////
// older HLSL syntax
#define TEX_TECH(TechName,SamplerName) technique TechName { \
pass TexturePass { \
VertexShader = compile vs_2_0 ScreenQuadVS(); \
AlphaBlendEnable = false; ZEnable = false; \
PixelShader = compile ps_2_a TexQuadPS(SamplerName); } }
#define TEX_BLEND_TECH(TechName,SamplerName) technique TechName { \
pass TexturePass { \
VertexShader = compile vs_2_0 ScreenQuadVS(); \
ZEnable = false; AlphaBlendEnable = true; \
SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; \
PixelShader = compile ps_2_a TexQuadPS(SamplerName); } }
// newer HLSL syntax
#define TEX_TECH2(TechName,SamplerName,TargName) technique TechName { \
pass TexturePass < \
string ScriptFunction = "RenderColorTarget0=" (TargName) ";" \
"DrawInternal=Buffer;"; \
> { \
VertexShader = compile vs_2_0 ScreenQuadVS(); \
AlphaBlendEnable = false; ZEnable = false; \
PixelShader = compile ps_2_a TexQuadPS(SamplerName); } }
#define TEX_BLEND_TECH2(TechName,SamplerName) technique TechName { \
pass TexturePass < \
string ScriptFunction = "RenderColorTarget0=" (TargName) ";" \
"DrawInternal=Buffer;"; \
> { \
VertexShader = compile vs_2_0 ScreenQuadVS(); \
ZEnable = false; AlphaBlendEnable = true; \
SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha; \
PixelShader = compile ps_2_a TexQuadPS(SamplerName); } }
#endif /* _QUAD_FXH */
////////////// eof ///
]]>
#include
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "scene";
string ScriptOrder = "postprocess";
string ScriptOutput = "color";
string Script = "Technique=Main;";
> = 0.8; // version #
float4 ClearColor <
string UIWidget = "color";
string UIName = "Background";
> = {0.1,0.1,0.1,0.0};
float ClearDepth = 1.0;
///////////////////////////////////////////////////////////
/////////////////////////////////////// Textures //////////
///////////////////////////////////////////////////////////
DECLARE_QUAD_TEX(SceneTexture,SceneSampler,"A8R8G8B8")
DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer,"D24S8")
//////////////////////////////////////////////////////
/////////////////////////////////// pixel shader /////
//////////////////////////////////////////////////////
QUAD_REAL4 ToCMYK(QuadVertexOutput IN) : COLOR
{
CREAL3 rgb = tex2D(SceneSampler, IN.UV).xyz;
return rgb2cmyk(rgb); // lose alpha
}
////////////////////////////////////////////////////////////
/////////////////////////////////////// techniques /////////
////////////////////////////////////////////////////////////
technique Main <
string Script =
"RenderColorTarget0=SceneTexture;"
"RenderDepthStencilTarget=DepthBuffer;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"
"Pass=Convert;";
> {
pass Convert <
string Script = "RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"Draw=Buffer;";
> {
VertexShader = compile vs_2_0 ScreenQuadVS();
ZEnable = false;
AlphaBlendEnable = false;
PixelShader = compile ps_2_a ToCMYK();
}
}
]]> = 0.8; // version #
#include
float4 ClearColor : DIFFUSE = {0.3,0.3,0.3,1.0};
float ClearDepth
<
string UIWidget = "none";
> = 1.0;
float nColors <
string UIWidget = "slider";
string UIName = "# colors";
float UIMin = 2.0;
float UIMax = 255.0;
float UIStep = 1.0;
> = 16;
float gamma <
string UIWidget = "slider";
string UIName = "Gamma";
float UIMin = 0.1;
float UIMax = 10.0;
float UIStep = 0.1;
> = 1.0;
///////////////////////////////////////////////////////////
///////////////////////////// Render-to-Texture Data //////
///////////////////////////////////////////////////////////
DECLARE_QUAD_TEX(SceneTexture,SceneSampler,"A8R8G8B8")
DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer, "D24S8")
////////////////////////////////////////////////////////////
/////////////////////////////////////// Shader /////////////
////////////////////////////////////////////////////////////
QUAD_REAL4 posterPS(QuadVertexOutput IN) : COLOR
{
QUAD_REAL4 texCol = tex2D(SceneSampler, IN.UV);
QUAD_REAL3 tc = texCol.xyz;
tc = pow(tc, gamma);
tc = tc * nColors;
tc = floor(tc);
tc = tc / nColors;
tc = pow(tc,1.0/gamma);
return float4(tc,texCol.w);
}
////////////////////////////////////////////////////////////
/////////////////////////////////////// techniques /////////
////////////////////////////////////////////////////////////
technique poster <
string Script =
"RenderColorTarget0=SceneTexture;"
"RenderDepthStencilTarget=DepthBuffer;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"
"Pass=p0;";
> {
pass p0 <
string Script = "RenderColorTarget0=;"
"RenderDepthStencilTarget=;"
"Draw=Buffer;";
> {
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 ScreenQuadVS();
PixelShader = compile ps_2_0 posterPS();
}
}
////////////// eof ///
]]>
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "scene";
string ScriptOrder = "preprocess";
string ScriptOutput = "color";
string Script = "Technique=TexBg;";
> = 0.8; // version #
float ClearDepth = 1.0;
///////// Textures ///////////////
texture BgTexture
<
string ResourceName = "Veggie.dds";
string ResourceType = "2D";
string UIName = "Background Texture";
>;
sampler2D BgSampler = sampler_state
{
Texture = ;
MinFilter = Point;
MagFilter = Point;
MipFilter = None;
};
////////////////////////
technique TexBg <
string Script =
"ClearSetDepth=ClearDepth;"
"Clear=Depth;"
"Pass=Bg;"
"ScriptExternal=Scene;";
> {
pass Bg <
string Script = "Draw=Buffer;";
> {
VertexShader = compile vs_1_1 ScreenQuadVS();
AlphaBlendEnable = false;
ZEnable = false;
PixelShader = compile ps_1_1 TexQuadPS(BgSampler);
}
}
/***************************** eof ***/
]]> = 0.8;
///////////////////////////////////////////////////////////
/////////////////////////////////////// Tweakables ////////
///////////////////////////////////////////////////////////
float SceneIntensity <
string UIName = "Scene intensity";
string UIWidget = "slider";
float UIMin = 0.0f;
float UIMax = 2.0f;
float UIStep = 0.1f;
> = 0.5f;
float GlowIntensity <
string UIName = "Glow intensity";
string UIWidget = "slider";
float UIMin = 0.0f;
float UIMax = 2.0f;
float UIStep = 0.1f;
> = 0.5f;
float HighlightThreshold <
string UIName = "Highlight threshold";
string UIWidget = "slider";
float UIMin = 0.0f;
float UIMax = 1.0f;
float UIStep = 0.1f;
> = 0.9f;
float HighlightIntensity <
string UIName = "Highlight intensity";
string UIWidget = "slider";
float UIMin = 0.0f;
float UIMax = 10.0f;
float UIStep = 0.1f;
> = 0.5f;
///////////////////////////////////////////////////////////
///////////////////////////// Render-to-Texture Data //////
///////////////////////////////////////////////////////////
float2 WindowSize : VIEWPORTPIXELSIZE < string UIWidget = "none"; >;
float downsampleScale = 0.25;
float BlurWidth <
string UIName = "Blur width";
string UIWidget = "slider";
float UIMin = 0.0f;
float UIMax = 10.0f;
float UIStep = 0.5f;
> = 2.0f;
texture SceneMap : RENDERCOLORTARGET
<
float2 ViewportRatio = { 1.0, 1.0 };
int MIPLEVELS = 1;
string format = "X8R8G8B8";
>;
texture DepthMap : RENDERDEPTHSTENCILTARGET
<
float2 ViewportRatio = { 1.0, 1.0 };
string format = "D24S8";
>;
sampler SceneSampler = sampler_state
{
texture = ;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = NONE;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
texture DownsampleMap : RENDERCOLORTARGET
<
float2 ViewportRatio = { 0.25, 0.25 };
int MIPLEVELS = 1;
string format = "A8R8G8B8";
>;
sampler DownsampleSampler = sampler_state
{
texture = ;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = NONE;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
texture HBlurMap : RENDERCOLORTARGET
<
float2 ViewportRatio = { 0.25, 0.25 };
int MIPLEVELS = 1;
string format = "A8R8G8B8";
>;
sampler HBlurSampler = sampler_state
{
texture = ;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = NONE;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
texture FinalBlurMap : RENDERCOLORTARGET
<
float2 ViewportRatio = { 0.25, 0.25 };
int MIPLEVELS = 1;
string format = "A8R8G8B8";
>;
sampler FinalBlurSampler = sampler_state
{
texture = ;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
MIPFILTER = NONE;
MINFILTER = LINEAR;
MAGFILTER = LINEAR;
};
///////////////////////////////////////////////////////////
/////////////////////////////////// data structures ///////
///////////////////////////////////////////////////////////
struct VS_OUTPUT_BLUR
{
float4 Position : POSITION;
float2 TexCoord[8]: TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Position : POSITION;
float2 TexCoord0 : TEXCOORD0;
float2 TexCoord1 : TEXCOORD1;
};
struct VS_OUTPUT_DOWNSAMPLE
{
float4 Position : POSITION;
float2 TexCoord[4]: TEXCOORD0;
};
////////////////////////////////////////////////////////////
////////////////////////////////// vertex shaders //////////
////////////////////////////////////////////////////////////
// generate texture coordinates to sample 4 neighbours
VS_OUTPUT_DOWNSAMPLE VS_Downsample(float4 Position : POSITION,
float2 TexCoord : TEXCOORD0)
{
VS_OUTPUT_DOWNSAMPLE OUT;
float2 texelSize = downsampleScale / WindowSize;
float2 s = TexCoord;
OUT.Position = Position;
OUT.TexCoord[0] = s;
OUT.TexCoord[1] = s + float2(2, 0)*texelSize;
OUT.TexCoord[2] = s + float2(2, 2)*texelSize;
OUT.TexCoord[3] = s + float2(0, 2)*texelSize;
return OUT;
}
// generate texcoords for blur
VS_OUTPUT_BLUR VS_Blur(float4 Position : POSITION,
float2 TexCoord : TEXCOORD0,
uniform int nsamples,
uniform float2 direction
)
{
VS_OUTPUT_BLUR OUT = (VS_OUTPUT_BLUR)0;
OUT.Position = Position;
float2 texelSize = BlurWidth / WindowSize;
float2 s = TexCoord - texelSize*(nsamples-1)*0.5*direction;
for(int i=0; i
{
pass DownSample
<
string Script = "RenderColorTarget0=DownsampleMap;"
"ClearSetColor=ClearColor;"
"Clear=Color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Downsample();
PixelShader = compile ps_2_0 PS_Downsample(SceneSampler);
}
pass GlowH
<
string Script = "RenderColorTarget0=HBlurMap;"
"ClearSetColor=ClearColor;"
"Clear=Color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Blur(7, float2(1, 0));
// PixelShader = compile ps_2_0 PS_Blur7(SceneSampler, weights7);
PixelShader = compile ps_2_0 PS_Blur7(DownsampleSampler, weights7);
}
pass GlowV
<
string Script = "RenderColorTarget0=FinalBlurMap;"
"ClearSetColor=ClearColor;"
"Clear=color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Blur(7, float2(0, 1));
PixelShader = compile ps_2_0 PS_Blur7(HBlurSampler, weights7);
}
pass GlowH_Central
<
string Script = "RenderColorTarget0=HBlurMap;"
"ClearSetColor=ClearColor;"
"Clear=Color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Blur(7, float2(1, 0));
PixelShader = compile ps_2_0 PS_Blur7(DownsampleSampler, weights7_Central);
}
pass GlowV_Central
<
string Script = "RenderColorTarget0=FinalBlurMap;"
"ClearSetColor=ClearColor;"
"Clear=Color;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Blur(7, float2(0, 1));
PixelShader = compile ps_2_0 PS_Blur7(HBlurSampler, weights7_Central);
}
pass FinalComp
<
string Script = "RenderColorTarget=;"
"RenderDepthStencilTarget=;"
"Draw=Buffer;";
>
{
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
VertexShader = compile vs_2_0 VS_Quad();
PixelShader = compile ps_2_0 PS_Comp(SceneSampler, FinalBlurSampler);
}
}
]]> = 0.8;
/************* TWEAKABLES **************/
float4 AmbiColor : Ambient
<
string UIName = "Ambient Light Color";
string UIWidget = "Color";
> = {0.2f, 0.2f, 0.2f, 1.0f};
float4 SurfColor : DIFFUSE
<
string UIName = "Surface Color";
string UIWidget = "Color";
> = {1.0f, 1.0f, 1.0f, 1.0f};
float RepeatS
<
string UIWidget = "slider";
float UIMin = 1.0;
float UIMax = 32.0;
float UIStep = 0.1;
> = 1.0;
float RepeatT
<
string UIWidget = "slider";
float UIMin = 1.0;
float UIMax = 32.0;
float UIStep = 0.1;
> = 1.0;
float Angle
<
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 360.0;
float UIStep = 1.0;
string UIName = "Degrees";
> = 0.0;
float OffsetS
<
string UIWidget = "slider";
float UIMin = -10.0;
float UIMax = 10.0;
float UIStep = 0.01;
> = 0.0;
float OffsetT
<
string UIWidget = "slider";
float UIMin = -10.0;
float UIMax = 10.0;
float UIStep = 0.01;
> = 0.0;
float RotCenterS
<
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 1.0;
float UIStep = 0.01;
> = 0.5;
float RotCenterT
<
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 1.0;
float UIStep = 0.01;
> = 0.5;
/************** model textures **************/
texture colorTexture : DIFFUSE
<
string ResourceName = "default_color.dds";
string ResourceType = "2D";
>;
sampler2D colorTextureSampler = sampler_state
{
Texture = ;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
/************** light info **************/
float4 LightPos : Position
<
string Object = "PointLight";
string Space = "World";
> = {100.0f, 100.0f, 100.0f, 0.0f};
float4 LightColor : Specular <
string UIName = "Light Color";
> = {1.0f, 1.0f, 1.0f, 1.0f};
/***********************************************/
/*** automatically-tracked "tweakables" ********/
/***********************************************/
float4x4 WorldIT : WorldInverseTranspose < string UIWidget="None"; >;
float4x4 WorldViewProj : WorldViewProjection < string UIWidget="None"; >;
float4x4 World : World < string UIWidget="None"; >;
float4x4 WorldI : WorldInverse < string UIWidget="None"; >;
/**************************************/
/***** SHARED STRUCT ******************/
/**** Data from app vertex buffer *****/
/**** for all passes *****/
/**************************************/
struct appdata {
float3 Position : POSITION;
float4 UV : TEXCOORD0;
float4 Tangent : TANGENT0;
float4 Binormal : BINORMAL0;
float4 Normal : NORMAL;
};
/****************************************/
/*** LIGHTING PASS - DIFFUSE ************/
/****************************************/
struct vertexOutput {
float4 HPosition : POSITION;
float2 UV : TEXCOORD0;
float4 diffCol : COLOR0;
};
vertexOutput DiffTexVS(appdata IN) {
vertexOutput OUT;
float4 objPos = float4(IN.Position.x,IN.Position.y,IN.Position.z,1.0);
float4 worldSpacePos = mul(objPos, World);
float4 LightVec = normalize(LightPos - worldSpacePos);
float4 objSpaceLightVec = normalize(mul(LightVec, WorldI));
float4 Nn = normalize(IN.Normal);
float ldn = dot(objSpaceLightVec,Nn);
OUT.diffCol = max(0,ldn).xxxx * SurfColor + AmbiColor;
OUT.diffCol.w = 1.0;
OUT.HPosition = mul(objPos, WorldViewProj);
float a = radians(Angle);
float ca = cos(a);
float sa = sin(a);
float2 off = float2(RotCenterS,RotCenterT);
float2 nuv = IN.UV.xy - off;
float2 ruv = float2(nuv.x*ca-nuv.y*sa,nuv.x*sa+nuv.y*ca);
nuv = ruv + off;
OUT.UV = float2(max(0.001,RepeatS) * nuv.x + OffsetS,
max(0.001,RepeatT) * nuv.y + OffsetT);
return OUT;
}
float4 DiffTexPS(vertexOutput IN) : COLOR
{
float4 map = tex2D(colorTextureSampler,IN.UV);
float4 final = (IN.diffCol * map);
return final;
}
/****************************************************/
/********** TECHNIQUES ******************************/
/****************************************************/
technique ps11 <
string Script = "Pass=p1d;";
> {
pass p1d <
string Script = "Draw=geometry;";
> {
VertexShader = compile vs_1_1 DiffTexVS();
ZEnable = true;
ZWriteEnable = true;
CullMode = None;
PixelShader = compile ps_1_1 DiffTexPS();
}
}
/***************************** eof ***/
]]>