本文整理汇总了C++中Pass::SetPixelShader方法的典型用法代码示例。如果您正苦于以下问题:C++ Pass::SetPixelShader方法的具体用法?C++ Pass::SetPixelShader怎么用?C++ Pass::SetPixelShader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pass
的用法示例。
在下文中一共展示了Pass::SetPixelShader方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Material
Material* MaterialCache2D::CreateMaterial(Texture2D* texture, BlendMode blendMode)
{
Material* material = new Material(context_);
if (texture)
material->SetName(texture->GetName() + "_" + blendModeNames[blendMode]);
else
material->SetName(blendModeNames[blendMode]);
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass(PASS_ALPHA);
pass->SetBlendMode(blendMode);
pass->SetVertexShader("Basic");
pass->SetVertexShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetPixelShader("Basic");
pass->SetPixelShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
material->SetTexture(TU_DIFFUSE, texture);
return material;
}
示例2: ret
ea::shared_ptr<Technique> Technique::Clone(const ea::string& cloneName) const
{
ea::shared_ptr<Technique> ret(context_->CreateObject<Technique>());
ret->SetIsDesktop(isDesktop_);
ret->SetName(cloneName);
// Deep copy passes
for (auto i = passes_.begin(); i != passes_.end(); ++i)
{
Pass* srcPass = i->get();
if (!srcPass)
continue;
Pass* newPass = ret->CreatePass(srcPass->GetName());
newPass->SetBlendMode(srcPass->GetBlendMode());
newPass->SetDepthTestMode(srcPass->GetDepthTestMode());
newPass->SetLightingMode(srcPass->GetLightingMode());
newPass->SetDepthWrite(srcPass->GetDepthWrite());
newPass->SetAlphaToCoverage(srcPass->GetAlphaToCoverage());
newPass->SetIsDesktop(srcPass->IsDesktop());
newPass->SetVertexShader(srcPass->GetVertexShader());
newPass->SetPixelShader(srcPass->GetPixelShader());
newPass->SetVertexShaderDefines(srcPass->GetVertexShaderDefines());
newPass->SetPixelShaderDefines(srcPass->GetPixelShaderDefines());
newPass->SetVertexShaderDefineExcludes(srcPass->GetVertexShaderDefineExcludes());
newPass->SetPixelShaderDefineExcludes(srcPass->GetPixelShaderDefineExcludes());
}
return ret;
}
示例3: ret
SharedPtr<Technique> Technique::Clone(const String& cloneName) const
{
SharedPtr<Technique> ret(new Technique(context_));
ret->SetIsDesktop(isDesktop_);
ret->SetName(cloneName);
// Deep copy passes
for (Vector<SharedPtr<Pass> >::ConstIterator i = passes_.Begin(); i != passes_.End(); ++i)
{
Pass* srcPass = i->Get();
if (!srcPass)
continue;
Pass* newPass = ret->CreatePass(srcPass->GetName());
newPass->SetBlendMode(srcPass->GetBlendMode());
newPass->SetDepthTestMode(srcPass->GetDepthTestMode());
newPass->SetLightingMode(srcPass->GetLightingMode());
newPass->SetDepthWrite(srcPass->GetDepthWrite());
newPass->SetAlphaToCoverage(srcPass->GetAlphaToCoverage());
newPass->SetIsDesktop(srcPass->IsDesktop());
newPass->SetVertexShader(srcPass->GetVertexShader());
newPass->SetPixelShader(srcPass->GetPixelShader());
newPass->SetVertexShaderDefines(srcPass->GetVertexShaderDefines());
newPass->SetPixelShaderDefines(srcPass->GetPixelShaderDefines());
newPass->SetVertexShaderDefineExcludes(srcPass->GetVertexShaderDefineExcludes());
newPass->SetPixelShaderDefineExcludes(srcPass->GetPixelShaderDefineExcludes());
}
return ret;
}
示例4: material
void Drawable2D::CreateDefaultMaterial()
{
SharedPtr<Material> material(new Material(context_));
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass(PASS_ALPHA);
pass->SetVertexShader("Basic");
pass->SetVertexShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetPixelShader("Basic");
pass->SetPixelShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
batches_[0].material_ = material;
}
示例5: Drawable
Renderer2D::Renderer2D(Context* context) :
Drawable(context, DRAWABLE_GEOMETRY),
material_(new Material(context)),
indexBuffer_(new IndexBuffer(context_)),
viewMask_(DEFAULT_VIEWMASK)
{
material_->SetName("Urho2D");
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass("alpha");
pass->SetVertexShader("Urho2D");
pass->SetPixelShader("Urho2D");
pass->SetDepthWrite(false);
cachedTechniques_[BLEND_REPLACE] = tech;
material_->SetTechnique(0, tech);
material_->SetCullMode(CULL_NONE);
frame_.frameNumber_ = 0;
SubscribeToEvent(E_BEGINVIEWUPDATE, URHO3D_HANDLER(Renderer2D, HandleBeginViewUpdate));
}
示例6: Geometry
void Text3D::UpdateTextMaterials(bool forceUpdate)
{
batches_.Resize(uiBatches_.Size());
geometries_.Resize(uiBatches_.Size());
for (unsigned i = 0; i < batches_.Size(); ++i)
{
if (!geometries_[i])
{
Geometry* geometry = new Geometry(context_);
geometry->SetVertexBuffer(0, vertexBuffer_, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1);
batches_[i].geometry_ = geometries_[i] = geometry;
}
if (!batches_[i].material_ || forceUpdate)
{
// If material not defined, create a reasonable default from scratch
if (!material_)
{
Material* material = new Material(context_);
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass(PASS_ALPHA);
pass->SetVertexShader("Basic");
pass->SetVertexShaderDefines("DIFFMAP VERTEXCOLOR");
pass->SetPixelShader("Basic");
pass->SetPixelShaderDefines("ALPHAMAP VERTEXCOLOR");
pass->SetBlendMode(BLEND_ALPHA);
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
batches_[i].material_ = material;
}
else
batches_[i].material_ = material_->Clone();
}
Material* material = batches_[i].material_;
material->SetTexture(TU_DIFFUSE, uiBatches_[i].texture_);
}
}
示例7: tech
SharedPtr<Material> Renderer2D::CreateMaterial(Texture2D* texture, BlendMode blendMode)
{
SharedPtr<Material> newMaterial = material_->Clone();
HashMap<int, SharedPtr<Technique> >::Iterator techIt = cachedTechniques_.Find((int)blendMode);
if (techIt == cachedTechniques_.End())
{
SharedPtr<Technique> tech(new Technique(context_));
Pass* pass = tech->CreatePass("alpha");
pass->SetVertexShader("Urho2D");
pass->SetPixelShader("Urho2D");
pass->SetDepthWrite(false);
pass->SetBlendMode(blendMode);
techIt = cachedTechniques_.Insert(MakePair((int)blendMode, tech));
}
newMaterial->SetTechnique(0, techIt->second_.Get());
newMaterial->SetName(texture->GetName() + "_" + blendModeNames[blendMode]);
newMaterial->SetTexture(TU_DIFFUSE, texture);
return newMaterial;
}
示例8: BeginLoad
bool Technique::BeginLoad(Deserializer& source)
{
passes_.Clear();
SetMemoryUse(sizeof(Technique));
SharedPtr<XMLFile> xml(new XMLFile(context_));
if (!xml->Load(source))
return false;
XMLElement rootElem = xml->GetRoot();
if (rootElem.HasAttribute("sm3"))
isSM3_ = rootElem.GetBool("sm3");
String globalVS = rootElem.GetAttribute("vs");
String globalPS = rootElem.GetAttribute("ps");
String globalVSDefines = rootElem.GetAttribute("vsdefines");
String globalPSDefines = rootElem.GetAttribute("psdefines");
// End with space so that the pass-specific defines can be appended
if (!globalVSDefines.Empty())
globalVSDefines += ' ';
if (!globalPSDefines.Empty())
globalPSDefines += ' ';
bool globalAlphaMask = false;
if (rootElem.HasAttribute("alphamask"))
globalAlphaMask = rootElem.GetBool("alphamask");
unsigned numPasses = 0;
XMLElement passElem = rootElem.GetChild("pass");
while (passElem)
{
if (passElem.HasAttribute("name"))
{
StringHash nameHash(passElem.GetAttribute("name"));
Pass* newPass = CreatePass(nameHash);
++numPasses;
if (passElem.HasAttribute("sm3"))
newPass->SetIsSM3(passElem.GetBool("sm3"));
// Append global defines only when pass does not redefine the shader
if (passElem.HasAttribute("vs"))
{
newPass->SetVertexShader(passElem.GetAttribute("vs"));
newPass->SetVertexShaderDefines(passElem.GetAttribute("vsdefines"));
}
else
{
newPass->SetVertexShader(globalVS);
newPass->SetVertexShaderDefines(globalVSDefines + passElem.GetAttribute("vsdefines"));
}
if (passElem.HasAttribute("ps"))
{
newPass->SetPixelShader(passElem.GetAttribute("ps"));
newPass->SetPixelShaderDefines(passElem.GetAttribute("psdefines"));
}
else
{
newPass->SetPixelShader(globalPS);
newPass->SetPixelShaderDefines(globalPSDefines + passElem.GetAttribute("psdefines"));
}
if (passElem.HasAttribute("lighting"))
{
String lighting = passElem.GetAttributeLower("lighting");
newPass->SetLightingMode((PassLightingMode)GetStringListIndex(lighting.CString(), lightingModeNames,
LIGHTING_UNLIT));
}
if (passElem.HasAttribute("blend"))
{
String blend = passElem.GetAttributeLower("blend");
newPass->SetBlendMode((BlendMode)GetStringListIndex(blend.CString(), blendModeNames, BLEND_REPLACE));
}
if (passElem.HasAttribute("depthtest"))
{
String depthTest = passElem.GetAttributeLower("depthtest");
if (depthTest == "false")
newPass->SetDepthTestMode(CMP_ALWAYS);
else
newPass->SetDepthTestMode((CompareMode)GetStringListIndex(depthTest.CString(), compareModeNames, CMP_LESS));
}
if (passElem.HasAttribute("depthwrite"))
newPass->SetDepthWrite(passElem.GetBool("depthwrite"));
if (passElem.HasAttribute("alphamask"))
newPass->SetAlphaMask(passElem.GetBool("alphamask"));
else
newPass->SetAlphaMask(globalAlphaMask);
}
else
LOGERROR("Missing pass name");
passElem = passElem.GetNext("pass");
}
// Calculate memory use now
//.........这里部分代码省略.........
示例9: BeginLoad
bool Technique::BeginLoad(Deserializer& source)
{
passes_.clear();
cloneTechniques_.clear();
SetMemoryUse(sizeof(Technique));
ea::shared_ptr<XMLFile> xml(context_->CreateObject<XMLFile>());
if (!xml->Load(source))
return false;
XMLElement rootElem = xml->GetRoot();
if (rootElem.HasAttribute("desktop"))
isDesktop_ = rootElem.GetBool("desktop");
ea::string globalVS = rootElem.GetAttribute("vs");
ea::string globalPS = rootElem.GetAttribute("ps");
ea::string globalVSDefines = rootElem.GetAttribute("vsdefines");
ea::string globalPSDefines = rootElem.GetAttribute("psdefines");
// End with space so that the pass-specific defines can be appended
if (!globalVSDefines.empty())
globalVSDefines += ' ';
if (!globalPSDefines.empty())
globalPSDefines += ' ';
XMLElement passElem = rootElem.GetChild("pass");
while (passElem)
{
if (passElem.HasAttribute("name"))
{
Pass* newPass = CreatePass(passElem.GetAttribute("name"));
if (passElem.HasAttribute("desktop"))
newPass->SetIsDesktop(passElem.GetBool("desktop"));
// Append global defines only when pass does not redefine the shader
if (passElem.HasAttribute("vs"))
{
newPass->SetVertexShader(passElem.GetAttribute("vs"));
newPass->SetVertexShaderDefines(passElem.GetAttribute("vsdefines"));
}
else
{
newPass->SetVertexShader(globalVS);
newPass->SetVertexShaderDefines(globalVSDefines + passElem.GetAttribute("vsdefines"));
}
if (passElem.HasAttribute("ps"))
{
newPass->SetPixelShader(passElem.GetAttribute("ps"));
newPass->SetPixelShaderDefines(passElem.GetAttribute("psdefines"));
}
else
{
newPass->SetPixelShader(globalPS);
newPass->SetPixelShaderDefines(globalPSDefines + passElem.GetAttribute("psdefines"));
}
newPass->SetVertexShaderDefineExcludes(passElem.GetAttribute("vsexcludes"));
newPass->SetPixelShaderDefineExcludes(passElem.GetAttribute("psexcludes"));
if (passElem.HasAttribute("lighting"))
{
ea::string lighting = passElem.GetAttributeLower("lighting");
newPass->SetLightingMode((PassLightingMode)GetStringListIndex(lighting.c_str(), lightingModeNames,
LIGHTING_UNLIT));
}
if (passElem.HasAttribute("blend"))
{
ea::string blend = passElem.GetAttributeLower("blend");
newPass->SetBlendMode((BlendMode)GetStringListIndex(blend.c_str(), blendModeNames, BLEND_REPLACE));
}
if (passElem.HasAttribute("cull"))
{
ea::string cull = passElem.GetAttributeLower("cull");
newPass->SetCullMode((CullMode)GetStringListIndex(cull.c_str(), cullModeNames, MAX_CULLMODES));
}
if (passElem.HasAttribute("depthtest"))
{
ea::string depthTest = passElem.GetAttributeLower("depthtest");
if (depthTest == "false")
newPass->SetDepthTestMode(CMP_ALWAYS);
else
newPass->SetDepthTestMode((CompareMode)GetStringListIndex(depthTest.c_str(), compareModeNames, CMP_LESS));
}
if (passElem.HasAttribute("depthwrite"))
newPass->SetDepthWrite(passElem.GetBool("depthwrite"));
if (passElem.HasAttribute("alphatocoverage"))
newPass->SetAlphaToCoverage(passElem.GetBool("alphatocoverage"));
}
else
URHO3D_LOGERROR("Missing pass name");
passElem = passElem.GetNext("pass");
}
//.........这里部分代码省略.........
示例10: shadowOffset
void Text3D::UpdateTextMaterials(bool forceUpdate)
{
batches_.Resize(uiBatches_.Size());
geometries_.Resize(uiBatches_.Size());
for (unsigned i = 0; i < batches_.Size(); ++i)
{
if (!geometries_[i])
{
Geometry* geometry = new Geometry(context_);
geometry->SetVertexBuffer(0, vertexBuffer_, MASK_POSITION | MASK_COLOR | MASK_TEXCOORD1);
batches_[i].geometry_ = geometries_[i] = geometry;
}
if (!batches_[i].material_ || forceUpdate)
{
// If material not defined, create a reasonable default from scratch
if (!material_)
{
Material* material = new Material(context_);
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass(PASS_ALPHA);
pass->SetVertexShader("Text");
pass->SetPixelShader("Text");
if (GetFont()->IsSDFFont())
{
switch (GetTextEffect())
{
case TE_NONE:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD");
break;
case TE_SHADOW:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_SHADOW");
break;
case TE_STROKE:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_STROKE");
break;
}
}
pass->SetBlendMode(BLEND_ALPHA);
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
batches_[i].material_ = material;
}
else
batches_[i].material_ = material_->Clone();
}
Material* material = batches_[i].material_;
Texture* texture = uiBatches_[i].texture_;
material->SetTexture(TU_DIFFUSE, texture);
if (GetFont()->IsSDFFont())
{
switch (GetTextEffect())
{
case TE_SHADOW:
if (texture)
{
Vector2 shadowOffset(0.5f / texture->GetWidth(), 0.5f / texture->GetHeight());
material->SetShaderParameter("ShadowOffset", shadowOffset);
}
material->SetShaderParameter("ShadowColor", GetEffectColor());
break;
case TE_STROKE:
material->SetShaderParameter("StrokeColor", GetEffectColor());
break;
default:
break;
}
}
}
}
示例11: Load
bool Technique::Load(Deserializer& source)
{
PROFILE(LoadTechnique);
SharedPtr<XMLFile> xml(new XMLFile(context_));
if (!xml->Load(source))
return false;
XMLElement rootElem = xml->GetRoot();
if (rootElem.HasAttribute("sm3"))
isSM3_ = rootElem.GetBool("sm3");
unsigned numPasses = 0;
XMLElement passElem = rootElem.GetChild("pass");
while (passElem)
{
if (passElem.HasAttribute("name"))
{
StringHash nameHash(passElem.GetAttribute("name"));
Pass* newPass = CreatePass(nameHash);
++numPasses;
if (passElem.HasAttribute("vs"))
newPass->SetVertexShader(passElem.GetAttribute("vs"));
if (passElem.HasAttribute("ps"))
newPass->SetPixelShader(passElem.GetAttribute("ps"));
if (passElem.HasAttribute("lighting"))
{
String lighting = passElem.GetAttributeLower("lighting");
newPass->SetLightingMode((PassLightingMode)GetStringListIndex(lighting.CString(), lightingModeNames,
LIGHTING_UNLIT));
}
if (passElem.HasAttribute("blend"))
{
String blend = passElem.GetAttributeLower("blend");
newPass->SetBlendMode((BlendMode)GetStringListIndex(blend.CString(), blendModeNames, BLEND_REPLACE));
}
if (passElem.HasAttribute("depthtest"))
{
String depthTest = passElem.GetAttributeLower("depthtest");
if (depthTest == "false")
newPass->SetDepthTestMode(CMP_ALWAYS);
else
newPass->SetDepthTestMode((CompareMode)GetStringListIndex(depthTest.CString(), compareModeNames, CMP_LESS));
}
if (passElem.HasAttribute("depthwrite"))
newPass->SetDepthWrite(passElem.GetBool("depthwrite"));
if (passElem.HasAttribute("alphamask"))
newPass->SetAlphaMask(passElem.GetBool("alphamask"));
}
else
LOGERROR("Missing pass name");
passElem = passElem.GetNext("pass");
}
// Calculate memory use
unsigned memoryUse = sizeof(Technique) + numPasses * sizeof(Pass);
SetMemoryUse(memoryUse);
return true;
}
示例12: shadowOffset
void Text3D::UpdateTextMaterials(bool forceUpdate)
{
Font* font = GetFont();
bool isSDFFont = font ? font->IsSDFFont() : false;
batches_.Resize(uiBatches_.Size());
geometries_.Resize(uiBatches_.Size());
for (unsigned i = 0; i < batches_.Size(); ++i)
{
if (!geometries_[i])
{
Geometry* geometry = new Geometry(context_);
geometry->SetVertexBuffer(0, vertexBuffer_);
batches_[i].geometry_ = geometries_[i] = geometry;
}
if (!batches_[i].material_ || forceUpdate || isSDFFont != usingSDFShader_)
{
// If material not defined, create a reasonable default from scratch
if (!material_)
{
Material* material = new Material(context_);
Technique* tech = new Technique(context_);
Pass* pass = tech->CreatePass("alpha");
pass->SetVertexShader("Text");
pass->SetPixelShader("Text");
if (isSDFFont)
{
switch (GetTextEffect())
{
case TE_NONE:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD");
break;
case TE_SHADOW:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_SHADOW");
break;
case TE_STROKE:
pass->SetPixelShaderDefines("SIGNED_DISTANCE_FIELD TEXT_EFFECT_STROKE");
break;
}
}
pass->SetBlendMode(BLEND_ALPHA);
pass->SetDepthWrite(false);
material->SetTechnique(0, tech);
material->SetCullMode(CULL_NONE);
batches_[i].material_ = material;
}
else
batches_[i].material_ = material_->Clone();
// Note: custom material is assumed to use the right kind of shader; it is not modified to define SIGNED_DISTANCE_FIELD
usingSDFShader_ = isSDFFont;
}
Material* material = batches_[i].material_;
Texture* texture = uiBatches_[i].texture_;
material->SetTexture(TU_DIFFUSE, texture);
if (isSDFFont)
{
switch (GetTextEffect())
{
case TE_SHADOW:
if (texture)
{
Vector2 shadowOffset(0.5f / texture->GetWidth(), 0.5f / texture->GetHeight());
material->SetShaderParameter("ShadowOffset", shadowOffset);
}
material->SetShaderParameter("ShadowColor", GetEffectColor());
break;
case TE_STROKE:
material->SetShaderParameter("StrokeColor", GetEffectColor());
break;
default:
break;
}
}
}
}