i would email teddy - or ask him over irc #dystopia
ausirc.net - i think he would be the person to ask
about texture overrides

--- Olivier Chatry <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> I'm working on an night vision effect and i have a
> little problem with it.
> My NVG effect is rendered using two shader :
> * One is a postprocessing effect wich "greenify" and
> a little noise to the
> sceen. This one work OK.
> * Second, wich i have problem with, is a thermal
> like effect that allow
> entitie to be hilighted. In fact the problem does
> not come from the shader
> itself, wich is working OK. The probleme is that i
> have to get materials
> from a given model to replace the shader it use.
> Currently i'm using the
> fonction 'ForcedMaterialOverride', to replace
> rendered material and try to
> get the model base texture with this code :
>
> [CODE]
> IMaterial*  pMaterial = materials->FindMaterial(
> "hl2ctf/nvg/thermal",
> TEXTURE_GROUP_OTHER );
> if (pMaterial == NULL)
>     return;
> IMaterialVar* pVarBaseTextureDestination =
> HL2CTF_GetShaderParam(pMaterial,
> "$basetexture");
> C_BasePlayer* pLocal =
> C_BasePlayer::GetLocalPlayer();
> Vector   vLook;
>
> if (pVarBaseTextureDestination == NULL)
> {
>     Msg("Cannot find $BASETEXTURE on Thermal
> material !\n");
>     return;
> }
> AngleVectors(pLocal->GetLocalAngles(), &vLook);
> VectorNormalize(vLook);
>
> const model_t* pModel = pEntity->GetModel();
> bool   bBaseTextureFound = false;
>
> studiohdr_t* pStudio =
> modelinfo->GetStudiomodel(pModel);
> if (pStudio)
> {
>     if (pStudio->numtextures > 0)
>    {
>         mstudiotexture_t* pTextureStudio =
> pStudio->pTexture(0);
>         const char*  pTexturePath =
> pStudio->pCdtexture(0);
>         char    pSearchPath[255] = {0};
>         Q_strcpy(pSearchPath, pTexturePath);
>         Q_strcat(pSearchPath,
> pTextureStudio->pszName());
>         ITexture* pTexture =
> materials->FindTexture(pSearchPath,
> TEXTURE_GROUP_MODEL);
>         if (pTexture && pTexture->IsError() ==
> false)
>         {
>
>
pVarBaseTextureDestination->SetTextureValue(pTexture);
>             bBaseTextureFound = true;
>         }
>    }
> }
> if (!bBaseTextureFound)
> {
>     ITexture* pWhiteTexture =
> materials->FindTexture("hl2ctf/nvg/white",
> TEXTURE_GROUP_OTHER);
>
>
pVarBaseTextureDestination->SetTextureValue(pWhiteTexture);
> }
> IMaterialVar* pVar =
> HL2CTF_GetShaderParam(pMaterial,
> "$light_direction");
> if (pVar)
>     pVar->SetVecValue(vLook.x, vLook.y, vLook.z);
> modelrender->ForcedMaterialOverride( pMaterial );
> [/CODE]
>
> But if the model have more than one material applyed
> to it, this code just
> does not work (all part of the model are rendered
> with the same material /
> texture).
> You can download a video of the problem at
> http://www.urba3d.com/hl2ctf/nvg.avi (look at the
> flag and the weapon with /
> without nvg).
>
> Is anyone have an idea / trick to get all the
> materials from a model ? I've
> tried "modelinfo->GetModelMaterialCount" and
> "modelinfo->GetModelMaterials"
> but these functions doesn't seems to work.
>
> Sorry for my bad english :).
>
> By Olivier.
>
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view
> the list archives, please visit:
>
http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>


--------

My Website http://www.ammahls.com
   Lead Programer NightFall http://www.nightfallmod.net/
      Developer of CST and ZHLT 3.0 http://www.zhlt.tk

This email has been sent from Adam McKern, and is not one of the many spam bots 
that use my email address.

If you receive an email that has not got this signature line, please delate the 
email, and not respond in any way to it.



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to