float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "object";
string ScriptOrder = "standard";
string ScriptOutput = "color";
string Script = "Technique=vBomb;";
> = 0.8;
//////////////////////////////////////////////////////////////
// UNTWEAKABLES //////////////////////////////////////////////
//////////////////////////////////////////////////////////////
float timer : TIME ;
float4x4 WorldViewProj : WORLDVIEWPROJECTION ;
//////////////////////////////////////////////////////////////
// TWEAKABLES ////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
float Displacement <
string UIWidget = "slider";
float UIMin = 0.0;
float UIMax = 2.0;
float UIStep = 0.01;
> = 1.6f;
float Sharpness <
string UIWidget = "slider";
float UIMin = 0.1;
float UIMax = 5.0;
float UIStep = 0.1;
> = 1.90f;
float ColorSharpness <
string UIWidget = "slider";
float UIMin = 0.1;
float UIMax = 5.0;
float UIStep = 0.1;
> = 3.0f;
float Speed <
string UIWidget = "slider";
float UIMin = 0.01;
float UIMax = 1.0;
float UIStep = 0.001;
> = 0.3f;
float TurbDensity <
string UIWidget = "slider";
float UIMin = 0.01;
float UIMax = 8.0;
float UIStep = 0.001;
> = 2.27f;
float ColorRange <
string UIWidget = "slider";
float UIMin = -6.0;
float UIMax = 6.0;
float UIStep = 0.01;
> = -2.0f;
float4x4 NoiseMatrix = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
//float4 dd[5] = {
// 0,2,3,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5 };
//////////////////////////// texture ///////////////////////
texture GradeTex
<
string ResourceName = "1D\\FireGrade.bmp";
string ResourceType = "2D";
string UIName = "Fire Gradient";
>;
sampler2D GradeSampler = sampler_state
{
Texture = ;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = clamp;
};
///////////// functions
// this is the smoothstep function f(t) = 3t^2 - 2t^3, without the normalization
float3 s_curve(float3 t) { return t*t*( float3(3,3,3) - float3(2,2,2)*t); }
float2 s_curve(float2 t) { return t*t*( float2(3,3) - float2(2,2)*t); }
float s_curve(float t) { return t*t*(3.0-2.0*t); }
// 3D version
float noise(float3 v,
const uniform float4 pg[FULLSIZE])
{
v = v + float3(10000.0f, 10000.0f, 10000.0f); // hack to avoid negative numbers
float3 i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float3 f = frac(v); // fractional position
// lookup in permutation table
float2 p;
p.x = pg[ i[0] ].w;
p.y = pg[ i[0] + 1 ].w;
p = p + i[1];
float4 b;
b.x = pg[ p[0] ].w;
b.y = pg[ p[1] ].w;
b.z = pg[ p[0] + 1 ].w;
b.w = pg[ p[1] + 1 ].w;
b = b + i[2];
// compute dot products between gradients and vectors
float4 r;
r[0] = dot( pg[ b[0] ].xyz, f );
r[1] = dot( pg[ b[1] ].xyz, f - float3(1.0f, 0.0f, 0.0f) );
r[2] = dot( pg[ b[2] ].xyz, f - float3(0.0f, 1.0f, 0.0f) );
r[3] = dot( pg[ b[3] ].xyz, f - float3(1.0f, 1.0f, 0.0f) );
float4 r1;
r1[0] = dot( pg[ b[0] + 1 ].xyz, f - float3(0.0f, 0.0f, 1.0f) );
r1[1] = dot( pg[ b[1] + 1 ].xyz, f - float3(1.0f, 0.0f, 1.0f) );
r1[2] = dot( pg[ b[2] + 1 ].xyz, f - float3(0.0f, 1.0f, 1.0f) );
r1[3] = dot( pg[ b[3] + 1 ].xyz, f - float3(1.0f, 1.0f, 1.0f) );
// interpolate
f = s_curve(f);
r = lerp( r, r1, f[2] );
r = lerp( r.xyyy, r.zwww, f[1] );
return lerp( r.x, r.y, f[0] );
}
// 2D version
float noise(float2 v,
const uniform float4 pg[FULLSIZE])
{
v = v + float2(10000.0f, 10000.0f);
float2 i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float2 f = frac(v); // fractional position
// lookup in permutation table
float2 p;
p[0] = pg[ i[0] ].w;
p[1] = pg[ i[0]+1 ].w;
p = p + i[1];
// compute dot products between gradients and vectors
float4 r;
r[0] = dot( pg[ p[0] ].xy, f);
r[1] = dot( pg[ p[1] ].xy, f - float2(1.0f, 0.0f) );
r[2] = dot( pg[ p[0]+1 ].xy, f - float2(0.0f, 1.0f) );
r[3] = dot( pg[ p[1]+1 ].xy, f - float2(1.0f, 1.0f) );
// interpolate
f = s_curve(f);
r = lerp( r.xyyy, r.zwww, f[1] );
return lerp( r.x, r.y, f[0] );
}
// 1D version
float noise(float v,
const uniform float4 pg[FULLSIZE])
{
v = v + 10000.0f;
float i = frac(v * NOISEFRAC) * BSIZE; // index between 0 and BSIZE-1
float f = frac(v); // fractional position
// compute dot products between gradients and vectors
float2 r;
r[0] = pg[i].x * f;
r[1] = pg[i + 1].x * (f - 1.0f);
// interpolate
f = s_curve(f);
return lerp( r[0], r[1], f);
}
/////////////////////////////
struct appData
{
float4 Position : POSITION;
float4 Normal : NORMAL;
float4 TexCoord0 : TEXCOORD0;
};
// define outputs from vertex shader
struct vertexOutData
{
float4 HPosition : POSITION;
float4 Color0 : COLOR0;
};
////////
vertexOutData mainVS(appData IN) {
vertexOutData OUT;
float4 noisePos = TurbDensity*mul(IN.Position+(Speed*timer),NoiseMatrix);
float i = (noise(noisePos.xyz, NTab) + 1.0f) * 0.5f;
float cr = 1.0-(0.5+ColorRange*(i-0.5));
cr = pow(cr,ColorSharpness);
OUT.Color0 = float4((cr).xxx, 1.0f);
// displacement along normal
float ni = pow(abs(i),Sharpness);
i -= 0.5;
//i = sign(i) * pow(i,Sharpness);
// we will use our own "normal" vector because the default geom is a sphere
float4 Nn = float4(normalize(IN.Position).xyz,0);
float4 NewPos = IN.Position - (Nn * (ni-0.5) * Displacement);
//position.w = 1.0f;
OUT.HPosition = mul(NewPos,WorldViewProj);
return OUT;
}
float4 hotPS(vertexOutData IN) : COLOR {
float2 nuv = float2(IN.Color0.x,0);
float4 nc = tex2D(GradeSampler,nuv);
return nc;
}
//////////////////////
technique vBomb <
string Script = "Pass=p0;";
> {
pass p0 <
string Script = "Draw=geometry;";
> {
VertexShader = compile vs_2_0 mainVS();
ZEnable = true;
ZWriteEnable = true;
CullMode = None;
AlphaBlendEnable = false;
PixelShader = compile ps_2_a hotPS();
}
}
///////////////////////////////////////////////////////////////// eof //
]]> = {-0.854611,-0.453029,0.25378,0,
-0.84528,-0.456307,-0.278002,1,
-0.427197,0.847095,-0.316122,2,
0.670266,-0.496104,0.551928,3,
-0.675674,-0.713842,0.184102,4,
-0.0373602,-0.600265,0.798928,5,
-0.939116,-0.119538,0.322135,6,
0.818521,0.278224,0.502609,7,
0.105335,-0.765291,0.635007,8,
-0.634436,-0.298693,0.712933,9,
-0.532414,-0.603311,-0.593761,10,
0.411375,0.0976618,0.906219,11,
0.798824,-0.416379,-0.434175,12,
-0.691156,0.585681,-0.423415,13,
0.612298,0.0777332,0.786797,14,
0.264612,-0.262848,0.927842,15,
-0.70809,0.0548396,-0.703989,16,
0.933195,-0.294222,-0.206349,17,
0.788936,-0.466718,-0.399692,18,
-0.540183,-0.824413,0.168954,19,
0.469322,-0.184125,0.863617,20,
-0.84773,0.292229,-0.44267,21,
0.450832,0.650314,-0.611427,22,
0.906378,-0.247125,-0.342647,23,
-0.995052,0.0271277,-0.0955848,24,
-0.0252277,-0.778349,0.627325,25,
0.991428,0.128623,0.0229457,26,
-0.842581,-0.290688,0.453384,27,
-0.662511,-0.500545,-0.557256,28,
0.650245,-0.692099,-0.313338,29,
0.636901,0.768918,-0.0558766,30,
-0.437006,0.872104,-0.220138,31,
-0.854611,-0.453029,0.25378,0,
-0.84528,-0.456307,-0.278002,1,
-0.427197,0.847095,-0.316122,2,
0.670266,-0.496104,0.551928,3,
-0.675674,-0.713842,0.184102,4,
-0.0373602,-0.600265,0.798928,5,
-0.939116,-0.119538,0.322135,6,
0.818521,0.278224,0.502609,7,
0.105335,-0.765291,0.635007,8,
-0.634436,-0.298693,0.712933,9,
-0.532414,-0.603311,-0.593761,10,
0.411375,0.0976618,0.906219,11,
0.798824,-0.416379,-0.434175,12,
-0.691156,0.585681,-0.423415,13,
0.612298,0.0777332,0.786797,14,
0.264612,-0.262848,0.927842,15,
-0.70809,0.0548396,-0.703989,16,
0.933195,-0.294222,-0.206349,17,
0.788936,-0.466718,-0.399692,18,
-0.540183,-0.824413,0.168954,19,
0.469322,-0.184125,0.863617,20,
-0.84773,0.292229,-0.44267,21,
0.450832,0.650314,-0.611427,22,
0.906378,-0.247125,-0.342647,23,
-0.995052,0.0271277,-0.0955848,24,
-0.0252277,-0.778349,0.627325,25,
0.991428,0.128623,0.0229457,26,
-0.842581,-0.290688,0.453384,27,
-0.662511,-0.500545,-0.557256,28,
0.650245,-0.692099,-0.313338,29,
0.636901,0.768918,-0.0558766,30,
-0.437006,0.872104,-0.220138,31,
-0.854611,-0.453029,0.25378,0,
-0.84528,-0.456307,-0.278002,1};
///////////////////////////// eof ///
]]> = 0.8; // version #
///////////////////////////////////////////////////////////
/////////////////////////////////////// Tweakables ////////
///////////////////////////////////////////////////////////
float4 ClearColor <
string UIWidget = "color";
string UIName = "background";
> = {0,0,0,0.0};
float ClearDepth = 1.0;
#include
float NPixels <
string UIName = "Pixels Steps";
string UIWidget = "slider";
float UIMin = 1.0f;
float UIMax = 5.0f;
float UIStep = 0.5f;
> = 1.5f;
float Threshhold
<
string UIWidget = "slider";
float UIMin = 0.01f;
float UIMax = 0.5f;
float UIStep = 0.01f;
> = 0.2;
///////////////////////////////////////////////////////////
///////////////////////////// Render-to-Texture Data //////
///////////////////////////////////////////////////////////
DECLARE_QUAD_TEX(SceneTexture,SceneSampler,"X8R8G8B8")
DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer, "D24S8")
// QUAD_REAL Time : TIME ;
//////////////////////////// struct ///
struct EdgeVertexOutput
{
QUAD_REAL4 Position : POSITION;
QUAD_REAL2 UV00 : TEXCOORD0;
QUAD_REAL2 UV01 : TEXCOORD1;
QUAD_REAL2 UV02 : TEXCOORD2;
QUAD_REAL2 UV10 : TEXCOORD3;
QUAD_REAL2 UV12 : TEXCOORD4;
QUAD_REAL2 UV20 : TEXCOORD5;
QUAD_REAL2 UV21 : TEXCOORD6;
QUAD_REAL2 UV22 : TEXCOORD7;
};
EdgeVertexOutput edgeVS(
QUAD_REAL3 Position : POSITION,
QUAD_REAL3 TexCoord : TEXCOORD0
) {
EdgeVertexOutput OUT;
OUT.Position = QUAD_REAL4(Position, 1);
QUAD_REAL2 off = QUAD_REAL2(QuadTexOffset/(QuadScreenSize.x),QuadTexOffset/(QuadScreenSize.y));
QUAD_REAL2 ctr = QUAD_REAL2(TexCoord.xy+off);
QUAD_REAL2 ox = QUAD_REAL2(NPixels/QuadScreenSize.x,0.0);
QUAD_REAL2 oy = QUAD_REAL2(0.0,NPixels/QuadScreenSize.y);
OUT.UV00 = ctr - ox - oy;
OUT.UV01 = ctr - oy;
OUT.UV02 = ctr + ox - oy;
OUT.UV10 = ctr - ox;
OUT.UV12 = ctr + ox;
OUT.UV20 = ctr - ox + oy;
OUT.UV21 = ctr + oy;
OUT.UV22 = ctr + ox + oy;
return OUT;
}
//////////////////////////////////////////////////////
////////////////////////////////// pixel shader //////
//////////////////////////////////////////////////////
QUAD_REAL getGray(QUAD_REAL4 c)
{
return(dot(c.rgb,((0.33333).xxx)));
}
QUAD_REAL4 edgeDetectPS(EdgeVertexOutput IN,
uniform sampler2D ColorMap,
uniform QUAD_REAL T2
) : COLOR {
QUAD_REAL4 CC;
CC = tex2D(ColorMap,IN.UV00); QUAD_REAL g00 = getGray(CC);
CC = tex2D(ColorMap,IN.UV01); QUAD_REAL g01 = getGray(CC);
CC = tex2D(ColorMap,IN.UV02); QUAD_REAL g02 = getGray(CC);
CC = tex2D(ColorMap,IN.UV10); QUAD_REAL g10 = getGray(CC);
CC = tex2D(ColorMap,IN.UV12); QUAD_REAL g12 = getGray(CC);
CC = tex2D(ColorMap,IN.UV20); QUAD_REAL g20 = getGray(CC);
CC = tex2D(ColorMap,IN.UV21); QUAD_REAL g21 = getGray(CC);
CC = tex2D(ColorMap,IN.UV22); QUAD_REAL g22 = getGray(CC);
QUAD_REAL sx = 0;
sx -= g00;
sx -= g01 * 2;
sx -= g02;
sx += g20;
sx += g21 * 2;
sx += g22;
QUAD_REAL sy = 0;
sy -= g00;
sy += g02;
sy -= g10 * 2;
sy += g12 * 2;
sy -= g20;
sy += g22;
QUAD_REAL dist = (sx*sx+sy*sy);
QUAD_REAL result = 1;
if (dist>T2) { result = 0; }
return result.xxxx;
}
////////////////////////////////////////////////////////////
/////////////////////////////////////// techniques /////////
////////////////////////////////////////////////////////////
technique Main <
string ScriptClass = "scene";
string ScriptOrder = "postprocess";
string ScriptOutput = "color";
string Script =
"RenderColorTarget0=SceneTexture;"
"RenderDepthStencilTarget=DepthBuffer;"
"ClearSetColor=ClearColor;"
"ClearSetDepth=ClearDepth;"
"Clear=Color;"
"Clear=Depth;"
"ScriptExternal=color;"
"Pass=ImageProc;";
> {
pass ImageProc <
string Script = "RenderColorTarget0=;"
"Draw=Buffer;";
> {
cullmode = none;
ZEnable = false;
ZWriteEnable = false;
AlphaBlendEnable = false;
VertexShader = compile vs_1_1 edgeVS();
PixelShader = compile ps_2_0 edgeDetectPS(SceneSampler,(Threshhold*Threshhold));
}
}
////////////// eof ///
]]>; \
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 ///
]]>