Last active
August 20, 2017 19:48
-
-
Save Enhex/158a37ad94cd06d6070fedbccf139c70 to your computer and use it in GitHub Desktop.
Urho3D render order in front
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node* planeNode = scene_->CreateChild("Plane"); | |
planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f)); | |
StaticModel* planeObject = planeNode->CreateComponent<StaticModel>(); | |
planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl")); | |
auto mat = cache->GetResource<Material>("Materials/StoneTiled.xml")->Clone(); | |
mat->SetRenderOrder(100); // Lower render order to render first | |
auto tecs = mat->GetTechniques(); | |
for (size_t i = 0; i < tecs.Size(); ++i) | |
{ | |
auto tec = mat->GetTechnique(i)->Clone(); | |
auto passes = tec->GetPasses(); | |
for (auto pass : passes) | |
pass->SetDepthWrite(false); | |
mat->SetTechnique(i, tec); | |
} | |
planeObject->SetMaterial(mat); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node* planeNode = scene_->CreateChild("Plane"); | |
planeNode->SetScale(Vector3(100.0f, 1.0f, 100.0f)); | |
StaticModel* planeObject = planeNode->CreateComponent<StaticModel>(); | |
planeObject->SetModel(cache->GetResource<Model>("Models/Plane.mdl")); | |
auto mat = cache->GetResource<Material>("Materials/StoneTiled.xml")->Clone(); | |
mat->SetRenderOrder(200); // Higher render order to render last | |
auto tecs = mat->GetTechniques(); | |
for (size_t i = 0; i < tecs.Size(); ++i) | |
{ | |
auto tec = mat->GetTechnique(i)->Clone(); | |
auto passes = tec->GetPasses(); | |
for (auto pass : passes) | |
pass->SetDepthTestMode(CMP_ALWAYS); // Always pass depth test | |
mat->SetTechnique(i, tec); | |
} | |
planeObject->SetMaterial(mat); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment