Single color write mask in material pass

What it says on the tin: a place to discuss proposed new features.
def87
Halfling
Posts: 90
Joined: Wed Sep 19, 2012 1:41 pm
x 1

Single color write mask in material pass

Post by def87 »

ColorWriteEnable "on"/"off" is not enough for me. I need to render alpha only, or single colors.

I haven't implemented this yet, as far a I can see setRGBAWriteMask() would have to be added to Ogre::Technique and Ogre::Pass and to all available Rendersystem plugins.

Ogre::MaterialSerializer (with backward material compatibility)

Code: Select all

    bool parseColourWrite(String& params, MaterialScriptContext& context)
    {
        StringVector vecparams = StringUtil::split(params, " \t");
        // Must be 1 or 4 parameters
        if (vecparams.size() == 1) {
	        if (vecparams[0] == "on")
	            context.pass->setColourWriteEnabled(true);
	        else if (vecparams[0] == "off")
	            context.pass->setColourWriteEnabled(false);
	        else
	            logParseError(
	                "Bad colour_write attribute, valid single parameters are 'on' or 'off'.",
	                context);
	    }
        else if (vecparams.size() == 4)
        {
        	bool red = false;
        	bool green = false;
        	bool blue = false;
        	bool alpha = false;
	        if (vecparams[0] == "on")
	            red = true;
	        if (vecparams[1] == "on")
	            green = true;
	        if (vecparams[2] == "on")
	            blue = true;
	        if (vecparams[3] == "on")
	            alpha = true;
	        
	        context.pass->setRGBAWriteMask(red, green, blue, alpha);
        }
        else
        {
            logParseError(
                "Bad colour_write attribute, wrong number of parameters (expected 1 or 4)",
                context);
        }        return false;
    }