本文整理汇总了C++中PixelShader::SetFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelShader::SetFilter方法的具体用法?C++ PixelShader::SetFilter怎么用?C++ PixelShader::SetFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelShader
的用法示例。
在下文中一共展示了PixelShader::SetFilter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VertexShader
//----------------------------------------------------------------------------
JunglerMaterial::JunglerMaterial ()
{
VertexShader* vshader = new0 VertexShader("PX2.JunglerMaterial",
3, 3, 8, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelNormal", Shader::VT_FLOAT3,
Shader::VS_NORMAL);
vshader->SetInput(2, "modelTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(2, "vertexTCoord1", Shader::VT_FLOAT4,
Shader::VS_TEXCOORD1);
vshader->SetConstant(0, "gPVWMatrix", 4);
vshader->SetConstant(1, "gShineEmissive", 1);
vshader->SetConstant(2, "gShineAmbient", 1);
vshader->SetConstant(3, "gShineDiffuse", 1);
vshader->SetConstant(4, "gLightColour", 1);
vshader->SetConstant(5, "gLightAttenuation", 1);
vshader->SetConstant(6, "gLightModelDirection", 1);
vshader->SetConstant(7, "gUser", 1);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("PX2.JunglerMaterial",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetInput(1, "vertexTCoord1", Shader::VT_FLOAT4,
Shader::VS_TEXCOORD1);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "gDiffuseSampler", Shader::ST_2D);
pshader->SetFilter(0, Shader::SF_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(0, 1, Shader::SC_REPEAT);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
MaterialPass* pass = new0 MaterialPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaProperty(new0 AlphaProperty());
pass->SetCullProperty(new0 CullProperty());
pass->SetDepthProperty(new0 DepthProperty());
pass->SetOffsetProperty(new0 OffsetProperty());
pass->SetStencilProperty(new0 StencilProperty());
pass->SetWireProperty(new0 WireProperty());
MaterialTechnique* technique = new0 MaterialTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}
示例2:
//----------------------------------------------------------------------------
VisualEffectInstance* Texture2ColorBlendEffect::CreateUniqueInstance (
Texture2D* texture0, Shader::SamplerFilter filter0,
Shader::SamplerCoordinate coordinate00,
Shader::SamplerCoordinate coordinate01, Texture2D* texture1,
Shader::SamplerFilter filter1, Shader::SamplerCoordinate coordinate10,
Shader::SamplerCoordinate coordinate11)
{
Texture2ColorBlendEffect* effect = new0 Texture2ColorBlendEffect();
PixelShader* pshader = effect->GetPixelShader();
pshader->SetFilter(0, filter0);
pshader->SetCoordinate(0, 0, coordinate00);
pshader->SetCoordinate(0, 1, coordinate01);
pshader->SetFilter(1, filter1);
pshader->SetCoordinate(1, 0, coordinate10);
pshader->SetCoordinate(1, 1, coordinate11);
return effect->CreateInstance(texture0, texture1);
}
示例3: VisualEffect
//----------------------------------------------------------------------------
MRTEffect::MRTEffect (const std::string& effectFile)
:
VisualEffect(effectFile)
{
// TODO: Once WmfxCompiler parses the Cg FX files, we will not need to
// set the sampler state.
PixelShader* pshader = GetPixelShader(0, 0);
// Sampler0
pshader->SetFilter(0, Shader::SF_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_CLAMP_EDGE);
pshader->SetCoordinate(0, 1, Shader::SC_CLAMP_EDGE);
// Sampler1
pshader->SetFilter(1, Shader::SF_LINEAR);
pshader->SetCoordinate(1, 0, Shader::SC_CLAMP_EDGE);
pshader->SetCoordinate(1, 1, Shader::SC_CLAMP_EDGE);
}
示例4: VisualEffect
//----------------------------------------------------------------------------
SimpleBumpMapEffect::SimpleBumpMapEffect (const std::string& effectFile)
:
VisualEffect(effectFile)
{
// TODO: Once WmfxCompiler parses the Cg FX files, we will not need to
// set the sampler state.
PixelShader* pshader = GetPixelShader(0, 0);
// BaseSampler
pshader->SetFilter(0, Shader::SF_LINEAR_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(0, 1, Shader::SC_REPEAT);
// NormalSampler
pshader->SetFilter(1, Shader::SF_LINEAR_LINEAR);
pshader->SetCoordinate(1, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(1, 1, Shader::SC_REPEAT);
}
示例5: PixelShader
//----------------------------------------------------------------------------
void Smoke2D::CreateFluidUpdateEffect (VisualEffect*& effect,
VisualEffectInstance*& instance)
{
PixelShader* pshader = new0 PixelShader("Wm5.FluidUpdate2",
1, 1, 3, 3, false);
pshader->SetInput(0, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetConstant(0, "SpaceParam", 1);
pshader->SetConstant(1, "TimeParam", 1);
pshader->SetConstant(2, "ViscParam", 1);
pshader->SetSampler(0, "StateSampler", Shader::ST_2D);
pshader->SetSampler(1, "AdvectionSampler", Shader::ST_2D);
pshader->SetSampler(2, "SourceSampler", Shader::ST_2D);
pshader->SetFilter(1, Shader::SF_LINEAR);
pshader->SetBaseRegisters(msFluidUpdatePRegisters);
pshader->SetTextureUnits(msFluidUpdatePTextureUnits);
pshader->SetPrograms(msFluidUpdatePPrograms);
mIP->CreateEffect(pshader, effect, instance);
ShaderFloat* spaceParamConstant = new0 ShaderFloat(1);
float* spaceParam = spaceParamConstant->GetData();
spaceParam[0] = mDx;
spaceParam[1] = mDy;
spaceParam[2] = 1.0f/(float)mIMax;
spaceParam[3] = 1.0f/(float)mJMax;
instance->SetPixelConstant(0, "SpaceParam", spaceParamConstant);
ShaderFloat* timeParamConstant = new0 ShaderFloat(1);
float* timeParam = timeParamConstant->GetData();
timeParam[0] = mDtDivDx;
timeParam[1] = mDtDivDy;
timeParam[2] = mDt;
instance->SetPixelConstant(0, "TimeParam", timeParamConstant);
ShaderFloat* viscParamConstant = new0 ShaderFloat(1);
float* viscParam = viscParamConstant->GetData();
viscParam[0] = mDenLambdaX;
viscParam[1] = mDenLambdaY;
viscParam[2] = mVelLambdaX;
viscParam[3] = mVelLambdaY;
instance->SetPixelConstant(0, "ViscParam", viscParamConstant);
mSourceTexture = new0 Texture2D(Texture::TF_A32B32G32R32F, mIMaxP1,
mJMaxP1, 1);
ComputeSource();
instance->SetPixelTexture(0, "StateSampler",
mIP->GetTarget(1)->GetColorTexture(0));
instance->SetPixelTexture(0, "AdvectionSampler",
mIP->GetTarget(4)->GetColorTexture(0));
instance->SetPixelTexture(0, "SourceSampler", mSourceTexture);
mRenderer->Bind(mSourceTexture);
}
示例6:
//----------------------------------------------------------------------------
VisualEffectInstance* Texture2DEffect::CreateUniqueInstance (
Texture2D* texture, Shader::SamplerFilter filter,
Shader::SamplerCoordinate coordinate0,
Shader::SamplerCoordinate coordinate1)
{
Texture2DEffect* effect = new0 Texture2DEffect();
PixelShader* pshader = effect->GetPixelShader();
pshader->SetFilter(0, filter);
pshader->SetCoordinate(0, 0, coordinate0);
pshader->SetCoordinate(0, 1, coordinate1);
return effect->CreateInstance(texture);
}
示例7: VertexShader
//----------------------------------------------------------------------------
VertexColor4TextureEffect::VertexColor4TextureEffect (
Shader::SamplerFilter filter, Shader::SamplerCoordinate coordinate0,
Shader::SamplerCoordinate coordinate1)
{
VertexShader* vshader = new0 VertexShader("Wm5.VertexColorTexture",
3, 3, 1, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetInput(2, "modelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(2, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetConstant(0, "PVWMatrix", 4);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("Wm5.VertexColorTexture",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetInput(1, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "BaseSampler", Shader::ST_2D);
pshader->SetFilter(0, filter);
pshader->SetCoordinate(0, 0, coordinate0);
pshader->SetCoordinate(0, 1, coordinate1);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
VisualPass* pass = new0 VisualPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaState(new0 AlphaState());
pass->SetCullState(new0 CullState());
pass->SetDepthState(new0 DepthState());
pass->SetOffsetState(new0 OffsetState());
pass->SetStencilState(new0 StencilState());
pass->SetWireState(new0 WireState());
VisualTechnique* technique = new0 VisualTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}
示例8: VertexShader
//----------------------------------------------------------------------------
UIMaterial::UIMaterial ()
{
VertexShader* vshader = new0 VertexShader("PX2.UI",
3, 3, 1, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelColor0", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetInput(2, "modelTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexColor0", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetOutput(2, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetConstant(0, "gPVWMatrix", 4);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("PX2.UI",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexColor0", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetInput(1, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "gDiffuseSampler", Shader::ST_2D);
pshader->SetFilter(0, Shader::SF_NEAREST);
pshader->SetCoordinate(0, 0, Shader::SC_CLAMP_EDGE);
pshader->SetCoordinate(0, 1, Shader::SC_CLAMP_EDGE);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
MaterialPass* pass = new0 MaterialPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaProperty(new0 AlphaProperty());
pass->SetCullProperty(new0 CullProperty());
pass->SetDepthProperty(new0 DepthProperty());
pass->SetOffsetProperty(new0 OffsetProperty());
pass->SetStencilProperty(new0 StencilProperty());
pass->SetWireProperty(new0 WireProperty());
pass->GetAlphaProperty()->BlendEnabled = true;
MaterialTechnique* technique = new0 MaterialTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}
示例9: VisualEffect
//----------------------------------------------------------------------------
BlendedTerrainEffect::BlendedTerrainEffect (const std::string& effectFile)
:
VisualEffect(effectFile)
{
// TODO: Once WmfxCompiler parses the Cg FX files, we will not need to
// set the sampler state.
PixelShader* pshader = GetPixelShader(0, 0);
// GrassSampler
pshader->SetFilter(0, Shader::SF_LINEAR_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(0, 1, Shader::SC_REPEAT);
// StoneSampler
pshader->SetFilter(1, Shader::SF_LINEAR_LINEAR);
pshader->SetCoordinate(1, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(1, 1, Shader::SC_REPEAT);
// BlendSampler
pshader->SetFilter(2, Shader::SF_LINEAR);
pshader->SetCoordinate(2, 0, Shader::SC_REPEAT);
// CloudSampler
pshader->SetFilter(3, Shader::SF_LINEAR_LINEAR);
pshader->SetCoordinate(3, 0, Shader::SC_REPEAT);
pshader->SetCoordinate(3, 1, Shader::SC_REPEAT);
// Create a 1-dimensional texture whose intensities are proportional to
// height.
const int numTexels = 256;
mBlendTexture = new0 Texture1D(Texture::TF_L8, numTexels, 1);
unsigned char* data = (unsigned char*)mBlendTexture->GetData(0);
for (int i = 0; i < numTexels; ++i)
{
*data++ = i;
}
}
示例10: VertexShader
//----------------------------------------------------------------------------
Texture2DMaterial::Texture2DMaterial (Shader::SamplerFilter filter,
Shader::SamplerCoordinate coordinate0,
Shader::SamplerCoordinate coordinate1)
{
VertexShader* vshader = new0 VertexShader("PX2.Texture2D",
2, 2, 1, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetConstant(0, "gPVWMatrix", 4);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("PX2.Texture2D",
1, 1, 0, 1, false);
pshader->SetInput(0, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "gDiffuseSampler", Shader::ST_2D);
pshader->SetFilter(0, filter);
pshader->SetCoordinate(0, 0, coordinate0);
pshader->SetCoordinate(0, 1, coordinate1);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
MaterialPass* pass = new0 MaterialPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaProperty(new0 AlphaProperty());
pass->SetCullProperty(new0 CullProperty());
pass->SetDepthProperty(new0 DepthProperty());
pass->SetOffsetProperty(new0 OffsetProperty());
pass->SetStencilProperty(new0 StencilProperty());
pass->SetWireProperty(new0 WireProperty());
MaterialTechnique* technique = new0 MaterialTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}
示例11: VisualEffectInstance
//----------------------------------------------------------------------------
SMUnlitEffect::SMUnlitEffect (const std::string& effectName,
ProjectorMatrixConstant* lightPVMatrix, ShaderFloat* lightBSMatrix,
ShaderFloat* depthBias, ShaderFloat* texelSize, Texture2D* shadowTexture)
{
VisualEffect* effect = VisualEffect::LoadWMFX(effectName);
// TODO: Once WmfxCompiler parses the Cg FX files, we will not need to
// set the sampler state.
PixelShader* pshader = effect->GetPixelShader(0, 0);
// ShadowSampler
pshader->SetFilter(0, Shader::SF_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_CLAMP_EDGE);
pshader->SetCoordinate(0, 1, Shader::SC_CLAMP_EDGE);
mInstance = new0 VisualEffectInstance(effect, 0);
mInstance->SetVertexConstant(0, 0, new0 PVWMatrixConstant());
mInstance->SetVertexConstant(0, 1, new0 WMatrixConstant());
mInstance->SetVertexConstant(0, 2, lightPVMatrix);
mInstance->SetVertexConstant(0, 3, lightBSMatrix);
mInstance->SetPixelConstant(0, 0, depthBias);
mInstance->SetPixelConstant(0, 1, texelSize);
mInstance->SetPixelTexture(0, 0, shadowTexture);
}
示例12: CreateEffectInstance
//----------------------------------------------------------------------------
VisualEffectInstance* GeodesicHeightField::CreateEffectInstance ()
{
// Create the vertex shader.
VertexShader* vshader = new0 VertexShader("Wm5.DLight2MatTex",
3, 3, 16, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelNormal", Shader::VT_FLOAT3,
Shader::VS_NORMAL);
vshader->SetInput(2, "modelTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetOutput(2, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetConstant( 0, "PVWMatrix", 4);
vshader->SetConstant( 1, "CameraModelPosition", 1);
vshader->SetConstant( 2, "MaterialEmissive", 1);
vshader->SetConstant( 3, "MaterialAmbient", 1);
vshader->SetConstant( 4, "MaterialDiffuse", 1);
vshader->SetConstant( 5, "MaterialSpecular", 1);
vshader->SetConstant( 6, "Light0ModelDirection", 1);
vshader->SetConstant( 7, "Light0Ambient", 1);
vshader->SetConstant( 8, "Light0Diffuse", 1);
vshader->SetConstant( 9, "Light0Specular", 1);
vshader->SetConstant(10, "Light0Attenuation", 1);
vshader->SetConstant(11, "Light1ModelDirection", 1);
vshader->SetConstant(12, "Light1Ambient", 1);
vshader->SetConstant(13, "Light1Diffuse", 1);
vshader->SetConstant(14, "Light1Specular", 1);
vshader->SetConstant(15, "Light1Attenuation", 1);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
// Create the pixel shader.
PixelShader* pshader = new0 PixelShader("Wm5.DLight2MatTex",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetInput(1, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "BaseSampler", Shader::ST_2D);
pshader->SetFilter(0, Shader::SF_LINEAR /*_LINEAR */);
pshader->SetCoordinate(0, 0, Shader::SC_CLAMP_EDGE);
pshader->SetCoordinate(0, 1, Shader::SC_CLAMP_EDGE);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
VisualPass* pass = new0 VisualPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaState(new0 AlphaState());
pass->SetCullState(new0 CullState());
pass->SetDepthState(new0 DepthState());
pass->SetOffsetState(new0 OffsetState());
pass->SetStencilState(new0 StencilState());
pass->SetWireState(new0 WireState());
// Create the effect.
VisualTechnique* technique = new0 VisualTechnique();
technique->InsertPass(pass);
VisualEffect* effect = new0 VisualEffect();
effect->InsertTechnique(technique);
// Create the material for the effect.
Float4 black(0.0f, 0.0f, 0.0f, 1.0f);
Float4 white(1.0f, 1.0f, 1.0f, 1.0f);
Material* material = new0 Material();
material->Emissive = black;
material->Ambient = Float4(0.24725f, 0.2245f, 0.0645f, 1.0f);
material->Diffuse = Float4(0.34615f, 0.3143f, 0.0903f, 1.0f);
material->Specular = Float4(0.797357f, 0.723991f, 0.208006f, 83.2f);
// Create the lights for the effect.
Light* light0 = new0 Light(Light::LT_DIRECTIONAL);
light0->SetDirection(AVector(0.0f, 0.0f, -1.0f));
light0->Ambient = white;
light0->Diffuse = white;
light0->Specular = black;
Light* light1 = new0 Light(Light::LT_DIRECTIONAL);
light1->SetDirection(AVector(0.0f, 0.0f, 1.0f));
light1->Ambient = white;
light1->Diffuse = white;
light1->Specular = black;
// Create a texture for the effect.
mTexture = new0 Texture2D(Texture::TF_A8R8G8B8, 512, 512, 0);
unsigned char* data = (unsigned char*)mTexture->GetData(0);
memset(data, 0xFF, mTexture->GetNumLevelBytes(0));
// Create an instance of the effect.
VisualEffectInstance* instance = new0 VisualEffectInstance(effect, 0);
instance->SetVertexConstant(0, 0,
new0 PVWMatrixConstant());
//.........这里部分代码省略.........
示例13: VertexShader
//----------------------------------------------------------------------------
StandardESMaterial_AlphaTest::StandardESMaterial_AlphaTest ()
{
VertexShader* vshader = new0 VertexShader("PX2.StandardESMaterial_AlphaTest",
3, 3, 7, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelNormal", Shader::VT_FLOAT3,
Shader::VS_NORMAL);
vshader->SetInput(2, "modelTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(2, "vertexTCoord1", Shader::VT_FLOAT4,
Shader::VS_TEXCOORD1);
vshader->SetConstant(0, "gPVWMatrix", 4);
vshader->SetConstant(1, "gShineEmissive", 1);
vshader->SetConstant(2, "gShineAmbient", 1);
vshader->SetConstant(3, "gShineDiffuse", 1);
vshader->SetConstant(4, "gLightAmbient", 1);
vshader->SetConstant(5, "gLightDiffuse", 1);
vshader->SetConstant(6, "gLightModelDirection", 1);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("PX2.StandardESMaterial_AlphaTest",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexTCoord0", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetInput(1, "vertexTCoord1", Shader::VT_FLOAT4,
Shader::VS_TEXCOORD1);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "gDiffuseSampler", Shader::ST_2D);
pshader->SetFilter(0, Shader::SF_LINEAR);
pshader->SetCoordinate(0, 0, Shader::SC_CLAMP);
pshader->SetCoordinate(0, 1, Shader::SC_CLAMP);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
vshader->SetShaderKey(SKT_STANNDES_ALPHATEST);
pshader->SetShaderKey(SKT_STANNDES_ALPHATEST);
MaterialPass* pass = new0 MaterialPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaProperty(new0 AlphaProperty());
pass->SetCullProperty(new0 CullProperty());
pass->SetDepthProperty(new0 DepthProperty());
pass->SetOffsetProperty(new0 OffsetProperty());
pass->SetStencilProperty(new0 StencilProperty());
pass->SetWireProperty(new0 WireProperty());
pass->GetAlphaProperty()->CompareEnabled = true;
pass->GetAlphaProperty()->Compare = PX2::AlphaProperty::CM_GREATER;
pass->GetAlphaProperty()->Reference = 0.25f;
MaterialTechnique* technique = new0 MaterialTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}