///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
MATERIAL* my_technique_mat1 =
{
technique = "first";
effect = "technique.fx";
flags = AUTORELOAD;
}
MATERIAL* my_technique_mat2 =
{
technique = "second";
effect = "technique.fx";
flags = AUTORELOAD;
}
void main()
{
fps_max = 60;
level_load(NULL);
you = ent_create(SPHERE_MDL,vector(128,0,32),NULL);
your.material = my_technique_mat1;
me = ent_create(CUBE_MDL,vector(128,0,-32),NULL);
my.material = my_technique_mat2;
while(1)
{
my.pan += 5*time_step;
my.tilt += 5*time_step;
wait(1);
}
}
// technique.fx
const float4x4 matWorldViewProj;
const float4x4 matWorld;
const float fAmbient;
const float4 vecSunDir;
texture entSkin1;
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};
void DiffuseVS(
in float4 InPos: POSITION,
in float3 InNormal: NORMAL,
in float2 InTex: TEXCOORD0,
out float4 OutPos: POSITION,
out float2 OutTex: TEXCOORD0,
out float3 OutNormal: TEXCOORD1)
{
OutPos = mul(InPos, matWorldViewProj);
OutNormal = normalize(mul(InNormal, matWorld));
OutTex = InTex;
}
float4 DiffusePS(
in float2 InTex: TEXCOORD0,
in float3 InNormal: TEXCOORD1): COLOR
{
InNormal = normalize(InNormal);
float4 Diffuse = saturate(dot(-vecSunDir, InNormal)*2);
float4 Color = tex2D(ColorMapSampler, InTex);
float4 final = Color*Diffuse;
return (1+fAmbient) * final;
}
float4 SecondPS(
in float2 InTex: TEXCOORD0,
in float3 InNormal: TEXCOORD1): COLOR
{
InNormal = normalize(InNormal);
float4 Diffuse = saturate(dot(-vecSunDir, InNormal)*2);
float4 Color = tex2D(ColorMapSampler, InTex);
float4 final = Color*Diffuse;
return (1+fAmbient) * final*float4(1,0,0,1);
}
technique first
{
pass P0
{
VertexShader = compile vs_3_0 DiffuseVS();
PixelShader = compile ps_3_0 DiffusePS();
}
}
technique second
{
pass P0
{
VertexShader = compile vs_3_0 DiffuseVS();
PixelShader = compile ps_3_0 SecondPS();
}
}