How to get the impostor material(s)?

scrawl

28-10-2011 15:45:22

Hi.

As title suggests, I need to get all impostor material(s) that paged geometry uses. Why? To make the impostors not look too dark with HDR, they need a 2.0 pixel shader. So I want to add this shader to all impostor materials.

Is it possible?

tod

31-10-2011 10:25:02

Not sure about the imposters but the batches material is generated in code. If the same is true for imposters you could apply your changes there.

scrawl

01-11-2011 13:19:38

Thanks! I've found it:

This is the relevant source (ImpostorPage.cpp, constructor ImpostorTexture):

//Set up materials
for (int o = 0; o < IMPOSTOR_YAW_ANGLES; ++o){
for (int i = 0; i < IMPOSTOR_PITCH_ANGLES; ++i){
material[i][o] = MaterialManager::getSingleton().create(getUniqueID("ImpostorMaterial"), "Impostors");

Material *m = material[i][o].getPointer();
Pass *p = m->getTechnique(0)->getPass(0);

TextureUnitState *t = p->createTextureUnitState(texture->getName());

t->setTextureUScroll((float)o / IMPOSTOR_YAW_ANGLES);
t->setTextureVScroll((float)i / IMPOSTOR_PITCH_ANGLES);

p->setLightingEnabled(false);
m->setReceiveShadows(false);

if (group->getBlendMode() == ALPHA_REJECT_IMPOSTOR){
p->setAlphaRejectSettings(CMPF_GREATER_EQUAL, 128);
//p->setAlphaRejectSettings(CMPF_GREATER_EQUAL, 64);
} else if (group->getBlendMode() == ALPHA_BLEND_IMPOSTOR){
p->setSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
p->setDepthWriteEnabled(false);
}
}
}