当前位置: 首页>>代码示例>>C++>>正文


C++ PixelShader::SetConstant方法代码示例

本文整理汇总了C++中PixelShader::SetConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelShader::SetConstant方法的具体用法?C++ PixelShader::SetConstant怎么用?C++ PixelShader::SetConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PixelShader的用法示例。


在下文中一共展示了PixelShader::SetConstant方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例2: VertexShader

//----------------------------------------------------------------------------
LightPntPerPixEffect::LightPntPerPixEffect ()
{
	VertexShader* vshader = new0 VertexShader("Wm5.LightPntPerPix",
	                        2, 3, 1, 0, false);
	vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
	                  Shader::VS_POSITION);
	vshader->SetInput(1, "modelNormal", Shader::VT_FLOAT3,
	                  Shader::VS_NORMAL);
	vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
	                   Shader::VS_POSITION);
	vshader->SetOutput(1, "vertexPosition", Shader::VT_FLOAT3,
	                   Shader::VS_TEXCOORD0);
	vshader->SetOutput(2, "vertexNormal", Shader::VT_FLOAT3,
	                   Shader::VS_TEXCOORD1);
	vshader->SetConstant(0, "PVWMatrix", 4);
	vshader->SetBaseRegisters(msVRegisters);
	vshader->SetPrograms(msVPrograms);

	PixelShader* pshader = new0 PixelShader("Wm5.LightPntPerPix",
	                                        2, 1, 11, 0, false);
	pshader->SetInput(0, "vertexPosition", Shader::VT_FLOAT3,
	                  Shader::VS_TEXCOORD0);
	pshader->SetInput(1, "vertexNormal", Shader::VT_FLOAT3,
	                  Shader::VS_TEXCOORD1);
	pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
	                   Shader::VS_COLOR0);
	pshader->SetConstant(0, "WMatrix", 4);
	pshader->SetConstant(1, "CameraModelPosition", 1);
	pshader->SetConstant(2, "MaterialEmissive", 1);
	pshader->SetConstant(3, "MaterialAmbient", 1);
	pshader->SetConstant(4, "MaterialDiffuse", 1);
	pshader->SetConstant(5, "MaterialSpecular", 1);
	pshader->SetConstant(6, "LightModelPosition", 1);
	pshader->SetConstant(7, "LightAmbient", 1);
	pshader->SetConstant(8, "LightDiffuse", 1);
	pshader->SetConstant(9, "LightSpecular", 1);
	pshader->SetConstant(10, "LightAttenuation", 1);
	pshader->SetBaseRegisters(msPRegisters);
	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);
}
开发者ID:bazhenovc,项目名称:WildMagic,代码行数:55,代码来源:Wm5LightPntPerPixEffect.cpp

示例3: PixelShader

//----------------------------------------------------------------------------
PixelShader* GpuGaussianBlur2::CreateBlurPixelShader ()
{
    PixelShader* pshader = new0 PixelShader("Wm5.GaussianBlur2",
        1, 1, 2, 1, false);
    pshader->SetInput(0, "vertexTCoord", Shader::VT_FLOAT2,
        Shader::VS_TEXCOORD0);
    pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
        Shader::VS_COLOR0);
    pshader->SetConstant(0, "Delta", 1);
    pshader->SetConstant(1, "Weight", 1);
    pshader->SetSampler(0, "StateSampler", Shader::ST_2D);
    pshader->SetBaseRegisters(msPRegisters);
    pshader->SetTextureUnits(msPTextureUnits);
    pshader->SetPrograms(msPPrograms);
    return pshader;
}
开发者ID:rasslingcats,项目名称:calico,代码行数:17,代码来源:GpuGaussianBlur2.cpp


注:本文中的PixelShader::SetConstant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。