锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
1錛屽皢effect婧愪唬鐮佹枃浠舵坊鍔犲埌欏圭洰涓紝姣斿鏄?Basic.fx
2錛屽湪Solution Explorer涓夋嫨Basic.fx錛?鍙抽敭錛岄夋嫨"Properties",
3錛屽湪General欏甸潰涓紝閫夋嫨Tool 涓?“Custom Build Tool”
4錛屽湪Custom Build Step欏甸潰涓紝緙栬緫Command Line涓?
fxc /Tfx_2_0 /Fo$(OutDir)/$(SafeInputName).fxo $(InputFileName)
濡傛灉緙栧啓鐨勬槸鐫鑹插櫒鑰屼笉鏄痚ffect錛屽垯瑕佹敞鎰忓湪fxc鍛戒護涓繕瑕佹寚瀹氱潃鑹插櫒鐨勫叆鍙e嚱鏁般俧xc鐨勫叿浣撶敤娉曞弬鑰僑DK鏂囨。銆?nbsp;
5錛岀紪杈慜utputs涓?br> $(OutDir)/$(SafeInputName).fxo
6錛岀紪璇戦」鐩紝榪欐椂IDE浼氬Basic.fx榪涜緙栬瘧錛屽鍚孋++鐨勭紪璇戜竴鏍鳳紝緙栬瘧鐨勭粨鏋滀篃浼氬湪IDE鐨刼utput紿楀彛鎵撳嵃鍑烘潵銆?br>
__global__
__host__
__device__
__constant__
__shared__
gridDim
blockIdx
blockDim
threadIdx
int1
uint1
int2
uint2
int3
uint3
int4
uint4
float1
float2
float3
float4
char1
char2
char3
char4
uchar1
uchar2
uchar3
uchar4
short1
short2
short3
short4
dim1
dim2
dim3
dim4
min
umin
fminf
fmin
max
umax
fmaxf
fmax
abs
fabsf
fabs
sinf
sin
cosf
cos
sqrtf
sqrt
expf
exp
logf
log
int2float
float2int
asm
asm_fragment
BINORMAL
BLENDINDICES0
BLENDWEIGHT0
bool
COLOR0
COLOR1
COLOR2
COLOR3
column_major
compile
compile_fragment
const
discard
decl1
do
double
else
extern
false
float
float2
float3
float3x3
float3x4
float4
float4x4
float4x3
for
half
half2
half3
half4
if
in
inline
inout
int
int2
int3
int4
matrix
out
pass1
pixelfragment
return
register
row_major
sampler
sampler1D
sampler2D
sampler3D
samplerCUBE
sampler_state
shared
stateblock
stateblock_state
static
string
struct
TANGENT
technique
texture
texture1D
texture2D
texture3D
textureCUBE
TEXCOORD0
TEXCOORD1
TEXCOORD2
TEXCOORD3
TEXCOORD4
TEXCOORD5
TEXCOORD6
TEXCOORD7
true
typedef
uniform
vector
vertexfragment
void
volatile
VPOS
while
struct VS_INPUT
{
float4 Position : POSITION0;
float2 Texcoord : TEXCOORD0;
float3 Normal : NORMAL0;//閫氬父鍙渶瑕佷袱涓悜閲忥紝鍥犱負鍙︿竴涓彲浠ュ弶涔樺緱鍒?br> float3 Binormal : BINORMAL0;
float3 Tangent : TANGENT0;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 Texcoord : TEXCOORD0;
float3 ViewDirection : TEXCOORD1;
float3 LightDirection: TEXCOORD2;
};
VS_OUTPUT vs_main( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Position = mul( Input.Position, matViewProjection );
Output.Texcoord = Input.Texcoord;
float3 fvObjectPosition = mul( Input.Position, matView );
float3 fvViewDirection = fvEyePosition - fvObjectPosition;
float3 fvLightDirection = fvLightPosition - fvObjectPosition;
float3 fvNormal = mul( Input.Normal, matView );
float3 fvTangent = mul( Input.Tangent, matView );
float3 fvBinormal = mul( Input.Binormal, matView );//閫氬父杈撳叆鍙渶瑕乶ornal鍜宼angent錛宐inormal鍙互鐢變袱鑰呭弶涔樺緱鍒?br> //fvBinormal = cross( fvNormal, fvTangent );
//灝嗚鏂瑰悜鍜屽厜綰挎柟鍚戦兘杞崲鍒版硶綰跨┖闂達紙鎴栬呯О鍒囩嚎絀洪棿錛?nbsp;
Output.ViewDirection.x = dot( fvTangent, fvViewDirection );
Output.ViewDirection.y = dot( fvBinormal, fvViewDirection );
Output.ViewDirection.z = dot( fvNormal, fvViewDirection );
Output.LightDirection.x = dot( fvTangent, fvLightDirection );
Output.LightDirection.y = dot( fvBinormal, fvLightDirection );
Output.LightDirection.z = dot( fvNormal, fvLightDirection );
return( Output );
}
//Pixel Shader
float4 fvAmbient;
float4 fvSpecular;
float4 fvDiffuse;
float fSpecularPower;
sampler2D baseMap;
sampler2D bumpMap;
struct PS_INPUT
{
float2 Texcoord : TEXCOORD0;
float3 ViewDirection : TEXCOORD1;
float3 LightDirection: TEXCOORD2;
};
float4 ps_main( PS_INPUT Input ) : COLOR0
{
float3 fvLightDirection = normalize( Input.LightDirection );
float3 fvNormal = normalize( ( tex2D( bumpMap, Input.Texcoord ).xyz * 2.0f ) - 1.0f );
float fNDotL = dot( fvNormal, fvLightDirection );
float3 fvReflection = normalize( ( ( 2.0f * fvNormal ) * ( fNDotL ) ) - fvLightDirection );
float3 fvViewDirection = normalize( Input.ViewDirection );
float fRDotV = max( 0.0f, dot( fvReflection, fvViewDirection ) );
float4 fvBaseColor = tex2D( baseMap, Input.Texcoord );
float4 fvTotalAmbient = fvAmbient * fvBaseColor;
float4 fvTotalDiffuse = fvDiffuse * fNDotL * fvBaseColor;
float4 fvTotalSpecular = fvSpecular * pow( fRDotV, fSpecularPower );
return( saturate( fvTotalAmbient + fvTotalDiffuse + fvTotalSpecular ) );
}