#include <acknex.h>
#include <default.c>
VIEW *camGlow;
VIEW *camMix;
BMAP *bmpGlow;
BMAP *bmpCamera;
MATERIAL *mtlObject =
{
effect = "
float4x4 matWorldViewProj;
Texture entSkin1;
sampler entSkin1Sampler = sampler_state { Texture = <entSkin1>; MipFilter = Linear; };
void VS (
in float4 inPos : POSITION,
in float2 inTex : TEXCOORD0,
out float4 outPos : POSITION,
out float2 outTex : TEXCOORD0 )
{
outPos = mul ( inPos, matWorldViewProj );
outTex = inTex;
}
float4 PS ( in float2 inTex : TEXCOORD0 ): COLOR0
{
float4 Color = tex2D ( entSkin1Sampler, inTex );
Color.a = 1.0f;
return Color;
}
technique Solid
{
pass one
{
ZWriteEnable = true;
AlphaBlendEnable = true;
VertexShader = compile vs_2_0 VS ();
PixelShader = compile ps_2_0 PS ();
}
}
";
flags = PASS_SOLID;
}
MATERIAL *mtlGlow =
{
effect = "
float4x4 matWorldViewProj;
Texture entSkin1;
sampler entSkin1Sampler = sampler_state { Texture = <entSkin1>; MipFilter = Linear; };
void VS(
in float4 inPos : POSITION,
in float2 inTex : TEXCOORD0,
out float4 outPosition : POSITION,
out float2 outTex : TEXCOORD0 )
{
outPosition = mul ( inPos, matWorldViewProj );
outTex = inTex;
}
float4 PS ( in float2 inTex : TEXCOORD0 ): COLOR
{
float4 Color = tex2D ( entSkin1Sampler, inTex );
Color.rgb = lerp ( 0, Color.rgb, Color.a );
Color.a = 1;
return Color;
}
technique Glow
{
pass one
{
ZWriteEnable = true;
AlphaBlendEnable = false;
VertexShader = compile vs_2_0 VS ();
PixelShader = compile ps_2_0 PS ();
}
}
technique fallback { pass one { } }
";
}
MATERIAL *mtlMix =
{
effect = "
float4 vecViewPort;
float4 vecSkill1;
static const float fWeights[4] =
{
0.133333,
0.066666,
0.033333,
0.016666
};
Texture TargetMap;
Texture mtlSkin1;
sampler ColorSampler = sampler_state { Texture = <mtlSkin1>; MipFilter = Linear; };
sampler GlowSampler = sampler_state { Texture = <TargetMap>; MipFilter = Linear; AddressU=Clamp; AddressV=Clamp; };
float4 PS ( in float2 inTex : TEXCOORD0 ): COLOR
{
float2 Coord = inTex * vecSkill1.xy;
float4 Color = tex2D ( ColorSampler, Coord );
float3 Glow = 0.0f;
float2 vOffset = vecViewPort.zw * 2;
for ( int i=1; i<5; i++ )
{
float3 Glow2 = tex2D ( GlowSampler, Coord + vOffset * i ).rgb;
Glow2.rgb += tex2D ( GlowSampler, Coord - vOffset * i ).rgb;
vOffset.x = -vOffset.x;
Glow2.rgb += tex2D ( GlowSampler, Coord + vOffset * i ).rgb;
Glow2.rgb += tex2D ( GlowSampler, Coord - vOffset * i ).rgb;
vOffset.x = -vOffset.x;
Glow.rgb += Glow2.rgb * fWeights[i-1];
}
Color.rgb += Glow.rgb;
return Color;
}
technique Mix
{
pass one
{
AlphaBlendEnable = false;
VertexShader = null;
PixelShader = compile ps_2_0 PS ();
}
}
";
}
function main ()
{
wait(1);
level_load ( "" );
you = ent_create("techcont_5.mdl", vector(128, 0, -32), NULL);
you.material = mtlObject;
bmpCamera = bmap_createblack ( screen_size.x, screen_size.y, 24 );
bmpGlow = bmap_createblack ( screen_size.x*0.25, screen_size.y*0.25, 24 );
mtlMix.skill1 = floatv ( 0.25 );
mtlMix.skill2 = floatv ( 0.25 );
mtlMix.skin1 = bmpCamera;
camMix = view_create ( 1 );
camMix.material = mtlMix;
set ( camMix, PROCESS_TARGET );
camGlow = view_create ( 1 );
camGlow.bmap = bmpGlow;
camGlow.material = mtlGlow;
set ( camGlow, CHILD );
camera.bg = pixel_for_vec ( nullvector, 100, 8888 );
camera.bmap = bmpCamera;
camera.stage = camGlow;
camGlow.stage = camMix;
while ( !key_esc )
{
DEBUG_BMAP ( bmpCamera, 0, 0.125 );
DEBUG_BMAP ( bmpGlow, 130, 0.5 );
wait (1);
}
sys_exit ( NULL );
}