本文整理汇总了C++中VisualEffectInstance::SetPixelConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualEffectInstance::SetPixelConstant方法的具体用法?C++ VisualEffectInstance::SetPixelConstant怎么用?C++ VisualEffectInstance::SetPixelConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualEffectInstance
的用法示例。
在下文中一共展示了VisualEffectInstance::SetPixelConstant方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInstance
//----------------------------------------------------------------------------
VisualEffectInstance* LightDirPerPixEffect::CreateInstance (Light* light,
Material* material) const
{
VisualEffectInstance* instance = new0 VisualEffectInstance(this, 0);
instance->SetVertexConstant(0, 0,
new0 PVWMatrixConstant());
instance->SetPixelConstant(0, 0,
new0 CameraModelPositionConstant());
instance->SetPixelConstant(0, 1,
new0 MaterialEmissiveConstant(material));
instance->SetPixelConstant(0, 2,
new0 MaterialAmbientConstant(material));
instance->SetPixelConstant(0, 3,
new0 MaterialDiffuseConstant(material));
instance->SetPixelConstant(0, 4,
new0 MaterialSpecularConstant(material));
instance->SetPixelConstant(0, 5,
new0 LightModelDVectorConstant(light));
instance->SetPixelConstant(0, 6,
new0 LightAmbientConstant(light));
instance->SetPixelConstant(0, 7,
new0 LightDiffuseConstant(light));
instance->SetPixelConstant(0, 8,
new0 LightSpecularConstant(light));
instance->SetPixelConstant(0, 9,
new0 LightAttenuationConstant(light));
return instance;
}
示例2: CreateInstance
//----------------------------------------------------------------------------
VisualEffectInstance* DLitMatTexEffect::CreateInstance (
Light* directionalLight, Material* material, Texture2D* diffuseTexture)
{
VisualEffectInstance* instance = new0 VisualEffectInstance(this, 0);
instance->SetVertexConstant(0, 0,
new0 PVWMatrixConstant());
instance->SetPixelConstant(0, 0,
new0 CameraModelPositionConstant());
instance->SetPixelConstant(0, 1,
new0 MaterialAmbientConstant(material));
instance->SetPixelConstant(0, 2,
new0 MaterialSpecularConstant(material));
instance->SetPixelConstant(0, 3,
new0 LightModelDVectorConstant(directionalLight));
instance->SetPixelConstant(0, 4,
new0 LightAmbientConstant(directionalLight));
instance->SetPixelTexture(0, 0, diffuseTexture);
return instance;
}
示例3: CreateInstance
//----------------------------------------------------------------------------
VisualEffectInstance* SMBlurEffect::CreateInstance (ShaderFloat* weights,
ShaderFloat* offsets, Texture2D* baseTexture) const
{
VisualEffectInstance* instance = new0 VisualEffectInstance(this, 0);
instance->SetVertexConstant(0, 0, new0 PVWMatrixConstant());
instance->SetPixelConstant(0, 0, weights);
instance->SetPixelConstant(0, 1, offsets);
instance->SetPixelTexture(0, 0, baseTexture);
return instance;
}
示例4: ShaderFloat
//----------------------------------------------------------------------------
void GpuGaussianBlur2::SetBlurInput ()
{
VisualEffectInstance* instance = mIP->GetMainEffectInstance();
float dCol = mIP->GetColSpacing();
float dRow = mIP->GetRowSpacing();
ShaderFloat* deltaConstant = new0 ShaderFloat(1);
float* delta = deltaConstant->GetData();
delta[0] = dCol;
delta[1] = dRow;
instance->SetPixelConstant(0, "Delta", deltaConstant);
ShaderFloat* weightConstant = new0 ShaderFloat(1);
float* weight = weightConstant->GetData();
weight[0] = 0.01f; // = kappa*DeltaT/DeltaX^2
weight[1] = 0.01f; // = kappa*DeltaT/DeltaY^2
weight[2] = 1.0f - 2.0f*weight[0] - 2.0f*weight[1]; // must be positive
instance->SetPixelConstant(0, "Weight", weightConstant);
}
示例5: CreateInstance
//----------------------------------------------------------------------------
VisualEffectInstance* BlendedTerrainEffect::CreateInstance (
ShaderFloat* flowDirection, ShaderFloat* powerFactor,
Texture2D* grassTexture, Texture2D* stoneTexture, Texture2D* cloudTexture)
{
VisualEffectInstance* instance = new0 VisualEffectInstance(this, 0);
instance->SetVertexConstant(0, 0, new0 PVWMatrixConstant());
instance->SetVertexConstant(0, 1, flowDirection);
instance->SetPixelConstant(0, 0, powerFactor);
instance->SetPixelTexture(0, 0, grassTexture);
instance->SetPixelTexture(0, 1, stoneTexture);
instance->SetPixelTexture(0, 2, mBlendTexture);
instance->SetPixelTexture(0, 3, cloudTexture);
return instance;
}
示例6: CreateInstance
//----------------------------------------------------------------------------
VisualEffectInstance* SMSceneEffect::CreateInstance (
ProjectorWorldPositionConstant* lightWorldPosition,
ProjectorMatrixConstant* lightPVMatrix, ShaderFloat* lightBSMatrix,
ShaderFloat* screenBSMatrix, ShaderFloat* lightColor,
Texture2D* baseTexture, Texture2D* blurTexture,
Texture2D* projectedTexture) const
{
VisualEffectInstance* instance = new0 VisualEffectInstance(this, 0);
instance->SetVertexConstant(0, 0, new0 PVWMatrixConstant());
instance->SetVertexConstant(0, 1, new0 WMatrixConstant());
instance->SetVertexConstant(0, 2, lightPVMatrix);
instance->SetVertexConstant(0, 3, lightBSMatrix);
instance->SetVertexConstant(0, 4, screenBSMatrix);
instance->SetVertexConstant(0, 5, lightWorldPosition);
instance->SetVertexConstant(0, 6, new0 CameraWorldPositionConstant());
instance->SetPixelConstant(0, 0, lightColor);
instance->SetPixelTexture(0, 0, baseTexture);
instance->SetPixelTexture(0, 1, blurTexture);
instance->SetPixelTexture(0, 2, projectedTexture);
return instance;
}
示例7: ShaderFloat
//----------------------------------------------------------------------------
void GpuGaussianBlur3::SetBlurInput ()
{
VisualEffectInstance* instance = mIP->GetMainEffectInstance();
int bound0M1 = mIP->GetBound0() - 1;
int bound1M1 = mIP->GetBound1() - 1;
int bound2M1 = mIP->GetBound2() - 1;
float dCol = mIP->GetColSpacing();
float dRow = mIP->GetRowSpacing();
ShaderFloat* deltaConstant = new0 ShaderFloat(1);
float* delta = deltaConstant->GetData();
delta[0] = dCol;
delta[1] = 0.0f;
delta[2] = 0.0f;
delta[3] = dRow;
instance->SetPixelConstant(0, "Delta", deltaConstant);
ShaderFloat* weightConstant = new0 ShaderFloat(1);
float* weight = weightConstant->GetData();
weight[0] = 0.01f; // = kappa*DeltaT/DeltaX^2
weight[1] = 0.01f; // = kappa*DeltaT/DeltaY^2
weight[2] = 0.01f; // = kappa*DeltaT/DeltaZ^2
weight[3] = 1.0f - 2.0f*(weight[0] + weight[1] + weight[2]); // w[3] > 0
instance->SetPixelConstant(0, "Weight", weightConstant);
Texture2D* offsetTexture = new Texture2D(Texture::TF_A32B32G32R32F,
1024, 1024, 1);
Float4* offset = (Float4*)offsetTexture->GetData(0);
memset(offset, 0, 1024*1024*sizeof(Float4));
// Interior voxels. The offsets at the boundary are all zero, so the
// finite differences are incorrect at those locations. However, the
// boundary effect will overwrite those voxels, so it is irrelevant
// about the finite difference approximations at those locations.
for (int z = 1; z < bound2M1; ++z)
{
for (int y = 1; y < bound1M1; ++y)
{
for (int x = 1; x < bound0M1; ++x)
{
// Get the 2D location of the voxel.
int u, v;
mIP->Map3Dto2D(x, y, z, u, v);
// Get the 2D location of the z+ neighbor.
int upos, vpos;
mIP->Map3Dto2D(x, y, z+1, upos, vpos);
// Get the 2D location of the z- neighbor.
int uneg, vneg;
mIP->Map3Dto2D(x, y, z-1, uneg, vneg);
Float4& color = offset[mIP->Index(u, v)];
color[0] = (upos - u)*dCol;
color[1] = (vpos - v)*dRow;
color[2] = (uneg - u)*dCol;
color[3] = (vneg - v)*dRow;
}
}
}
instance->SetPixelTexture(0, "OffsetSampler", offsetTexture);
}