Сделал шейдер
//Parallax_mapping
//float script : STANDARDSGLOBAL
//<
//string Script = "Technique=normal_mapping;";
//> = 0.8;
float4x4 gWorldXf ;
float4x4 gWorldITXf ;
float4x4 gWvpXf ;
float4x4 gViewIXf ;
float4x4 gViewXf ;
float4x4 gWorldViewXf ;
float3 gLamp0Point = {-0.5f,2.0f,1.25f};
float3 Lamp_0_color = {1.0f,1.0f,1.0f};
float gTileCount = 8;
float gDepth = 0.05;
float3 gAmbiColor = {0.07f,0.07f,0.07f};
float3 gSurfaceColor = {1,1,1};
float3 gSpecColor = {0.75,0.75,0.75};
float gPhongExp = 128.0;
//texture gColorTexture;
sampler2D gColorSampler = sampler_state {
Texture = diffuse_texture;
MinFilter = Linear;
MipFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
//texture gReliefTexture;
sampler2D gReliefSampler = sampler_state {
// Texture = gReliefTexture;
Texture = normal_texture;
MinFilter = Linear;
MipFilter = Linear;
MagFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
struct AppVertexData {
float4 pos : POSITION;
float3 normal : NORMAL;
float2 txcoord : TEXCOORD0;
float3 tangent : TANGENT0;
float3 binormal : BINORMAL0;
};
struct VertexOutput {
float4 hpos : POSITION;
float2 UV : TEXCOORD0;
float3 vpos : TEXCOORD1;
float3 tangent : TEXCOORD2;
float3 binormal : TEXCOORD3;
float3 normal : TEXCOORD4;
float4 lightpos : TEXCOORD5;
};
VertexOutput view_spaceVS(AppVertexData IN)
{
VertexOutput OUT = (VertexOutput)0;
float3x3 modelViewRotXf;
modelViewRotXf[0] = gWorldViewXf[0].xyz;
modelViewRotXf[1] = gWorldViewXf[1].xyz;
modelViewRotXf[2] = gWorldViewXf[2].xyz;
float4 Po = float4(IN.pos.xyz,1.0);
OUT.hpos = mul(Po,gWvpXf);
OUT.vpos = mul(Po,gWorldViewXf).xyz;
float4 Lw = float4(gLamp0Point.xyz,1);
OUT.lightpos = mul(Lw,gViewXf);
OUT.tangent = mul(IN.tangent,modelViewRotXf);
OUT.binormal = mul(IN.binormal,modelViewRotXf);
OUT.normal = mul(IN.normal,modelViewRotXf);
OUT.UV = gTileCount * IN.txcoord.xy;
return OUT;
}
float4 parallax_mapPS(VertexOutput IN
//PS_OUTPUT parallax_mapPS(VertexOutput IN
) : COLOR
{
// PS_OUTPUT Output;
float3 Vn = normalize(IN.vpos);
float3 Ln = normalize(IN.lightpos.xyz-IN.vpos); // LightDir
float2 uv = IN.UV;
//vyczislenie Parallax
float3x3 tbnXf = float3x3(IN.tangent,IN.binormal,IN.normal);
float4 reliefTex = tex2D(gReliefSampler,uv);
float height = reliefTex.w * 0.06 - 0.05;
uv += height * mul(tbnXf,Vn).xy;
float3 tNorm = reliefTex.xyz - float3(0.5,0.5,0.5);
tNorm = normalize(tNorm.x*IN.tangent -
tNorm.y*IN.binormal +
tNorm.z*IN.normal);
float3 texCol = tex2D(gColorSampler,uv).xyz;
float att = saturate(dot(Ln,IN.normal));
float diff = saturate(dot(Ln,tNorm));
float spec = saturate(dot(normalize(Ln-Vn),tNorm));
spec = pow(spec,gPhongExp);
float3 finalcolor = gAmbiColor*texCol +
att*(texCol*gSurfaceColor.xyz*
Lamp_0_color*diff+gSpecColor*spec);
return float4(finalcolor.rgb,1.0);
}
technique parallax_mapping
//<
// string Script = "Pass=p0;";
//>
{
pass p0
// <
// string Script = "Draw=geometry;";
// >
{
// VertexShader = compile vs_3_0 view_spaceVS();
VertexShader = compile vs_2_a view_spaceVS();
// ZEnable = true;
// ZWriteEnable = true;
// ZFunc = LessEqual;
// AlphaBlendEnable = false;
// CullMode = None;
// PixelShader = compile ps_3_0 parallax_mapPS(PCF_NONE);
PixelShader = compile ps_2_0 parallax_mapPS();
}
}
при компиляции:
Microsoft (R) Direct3D Shader Compiler 9.27.952.3012
Copyright (C) Microsoft Corporation 2002-2009. All rights reserved.
F:\Module_Shaders\mb.fx(5429,11): error X4510: maximum ps_2_0 sampler register i
ndex (16) exceeded
F:\Module_Shaders\mb.fx(5541,23): ID3DXEffectCompiler::CompileEffect: There was
an error compiling expression
ID3DXEffectCompiler: Compilation failed
compilation failed; no code produced
Microsoft (R) Direct3D Shader Compiler 9.27.952.3012
Copyright (C) Microsoft Corporation 2002-2009. All rights reserved.
F:\Module_Shaders\mb.fx(5429,11): error X4510: maximum ps_2_0 sampler register i
ndex (16) exceeded
F:\Module_Shaders\mb.fx(5541,23): ID3DXEffectCompiler::CompileEffect: There was
an error compiling expression
ID3DXEffectCompiler: Compilation failed
compilation failed; no code produced
Script processing has ended.
Press any key to exit. . .
В чем и где ошибка и как её исправить???