From 25130e3c824d5eddf2bcf922cdabc08e589b0250 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Tue, 25 Sep 2012 22:51:37 +0100 Subject: [PATCH] Add alpha-to-coverage GL parameter to effects code. --- simgear/scene/material/Effect.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index c9348157..e607c2e5 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -602,6 +602,24 @@ struct StencilBuilder : public PassAttributeBuilder InstallAttributeBuilder installStencil("stencil"); +struct AlphaToCoverageBuilder : public PassAttributeBuilder +{ + void buildAttribute(Effect* effect, Pass* pass, const SGPropertyNode* prop, + const SGReaderWriterOptions* options); +}; + +void AlphaToCoverageBuilder::buildAttribute(Effect* effect, Pass* pass, + const SGPropertyNode* prop, + const SGReaderWriterOptions* options) +{ + const SGPropertyNode* realProp = getEffectPropertyNode(effect, prop); + if (!realProp) + return; + pass->setMode(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, (realProp->getValue() ? + StateAttribute::ON : StateAttribute::OFF)); +} + +InstallAttributeBuilder installAlphaToCoverage("alpha-to-coverage"); EffectNameValue alphaComparisonInit[] = { @@ -648,6 +666,7 @@ struct AlphaTestBuilder : public PassAttributeBuilder "comparison"); const SGPropertyNode* pRef = getEffectPropertyChild(effect, prop, "reference"); + AlphaFunc::ComparisonFunction func = AlphaFunc::ALWAYS; float refValue = 1.0f; if (pComp)