Помогите подключить шейдер к xors3d
вот в архиве есть шейдер
http://moka.ucoz.ru/load/0-0-0-84-20
//==================================================
// Varriables
const float4x4 matworldviewproj;
const float4x4 matworld;
const bool eff[4];
const float3 lightPos;
const float3 camPos;
const float4 clrAmb;
const float4 clrLig;
const float4 clrSpc;
static float height;
static float bias;
static float bumplight;
static float specular;
const float2 vdepth;
const float2 vdist;
static float3 cn;
//static float4 cs;
static float cp;
static float4 ccolor;
static float3 reflv;
static float fRdotL;
static float3 pos;
static float3 vview;
static float falloff;
static float2 dist;
static float3 vlight;
const float2 texScale;
//==================================================
// Textures
texture tdiffuse;
sampler texdiffuse=sampler_state {
Texture = <tdiffuse>;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
ADDRESSW = WRAP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
texture tnormal;
sampler texnormal=sampler_state {
Texture = <tnormal>;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
ADDRESSW = WRAP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
texture tdisplace;
sampler texdisplace=sampler_state {
Texture = <tdisplace>;
ADDRESSU = WRAP;
ADDRESSV = WRAP;
ADDRESSW = WRAP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
//==================================================
// Vertex Shader Input Structure
struct vi {
float4 position : POSITION;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float3 binormal : BINORMAL;
float3 texcoords: TEXCOORD0;
};
// Pixel Shader Input Structure
struct pi {
float4 position : POSITION;
float2 texcoords: TEXCOORD0;
float3 normal : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 wpos : TEXCOORD4;
//float3 vlight : TEXCOORD1;
//float3 vview : TEXCOORD2;
//float falloff : TEXCOORD4;
//float2 dist : TEXCOORD3;
};
//==================================================
// Vertex Shader Main Functions
void vs(in vi IN, out pi OUT) {
OUT.position = mul(IN.position, matworldviewproj);
OUT.wpos = mul(IN.position, matworld);
OUT.tangent = mul(IN.tangent, matworld);
OUT.binormal = mul(IN.binormal, matworld);
OUT.normal = mul(IN.normal, matworld);
OUT.texcoords=IN.texcoords/texScale;
};
//==================================================
// Pixel Shader Main Functions
float4 ps(in pi IN) : COLOR {
bias=vdepth.x/2;
if (eff[0]+eff[1]+eff[2]>0) {
float3x3 matTangentSpace=float3x3(IN.tangent,IN.binormal,IN.normal);
matTangentSpace = transpose(matTangentSpace);
vview = normalize(camPos-IN.wpos);
falloff = dot(vview,IN.normal);
vview = normalize(mul(vview,matTangentSpace));
//dist.y = 1-(distance(camPos,IN.wpos)/vdist.y);
if (eff[0]==true) {
dist.y = 1-(distance(camPos,IN.wpos)/vdist.y);
if (dist.y>.05) {
cp = tex2D(texdisplace,IN.texcoords).r;
height = (vdepth.x*cp-bias);
IN.texcoords = IN.texcoords+height*vview.xy*dist.y;
}
}
ccolor=tex2D(texdiffuse,IN.texcoords);
if (eff[1]+eff[2]>0) {
dist.x = 1-(distance(lightPos,IN.wpos)/vdist.x);
if (dist.x>.01) {
vlight = normalize(mul(lightPos-IN.wpos,matTangentSpace));
cn = normalize(tex2D(texnormal,IN.texcoords)*2-1);
if (eff[1]==true) {
bumplight = max(dot(cn,vlight)+0.1f,0.0f)*dist.x;
ccolor = ccolor*(clrAmb*(1-saturate(dist.x)))+ccolor*bumplight*clrLig;
} else {
ccolor = ccolor*clrAmb;
}
if (eff[2]==true) {
reflv = normalize(dot(vview,cn)*cn-vview);
fRdotL = saturate(dot(reflv,vlight));
specular = saturate(pow(fRdotL,vdepth.y))*(1-pow(1-dist.x,2));
ccolor +=ccolor*specular*pow(1-falloff,1.5)*clrSpc.w*clrSpc;
}
} else {
ccolor=ccolor*clrAmb;
}
}
} else {
ccolor=tex2D(texdiffuse,IN.texcoords);
}
return ccolor;
};
//==================================================
// Techniques
technique main {
pass p0 {
vertexshader = compile vs_1_1 vs();
pixelshader = compile ps_3_0 ps();
}
};