Sorry for the e-mails... but I had misunderstanding about the code which
lead me to errors in testing and in my previous findings. I'll try to give
myself more time(sleep) before e-mailing about a problem again.
So disregard everything I said, except for the code. The code actually works
if you need to set a rendermode for a material that's not suppose to be
opaque. Like the visual bug with the physics canon when you first start a
sdk hl2dm game.


EJ


From: "Eric Van Huss" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: RE: [hlcoders] Question about materials
Date: Mon, 13 Nov 2006 07:01:05 -0700

I stuck with a sprite instead of an unlitgeneric.  But I guess
$spriteRenderMode inside a vmt file doesn't work.  Checking the Int value
of
the IMaterialVar associated with $spriteRenderMode returns 0, when in the
vmt it's set to 3.  It can be done in code though, which I took from
Valve's
CEngineSprite::SetRenderMode. The problem was with creating a mesh(rpg
laser
dot,redglow1) with a material who's rendermode hadn't been set. I guess you
should always set the rendermode for the material a mesh uses before it
draws? Anyway here's the code that makes it work, I got it from
CEngineSprite::SetRenderMode. (what seems weird that when a mesh is used,
it
could potentially use the material's render mode set by another entity if
you don't do this)

I included:  "materialsystem/imaterial.h" and
"materialsystem/imaterialvar.h"

//use CMaterialReference's operator method to store it's IMaterial pointer
inside testMaterial
IMaterial* testMaterial(m_hSomeCMaterialReference);
static unsigned int spriteRenderModeCache;
IMaterialVar* pTMaterialVar = testMaterial->FindVarFast(
"$spriteRenderMode", &spriteRenderModeCache );
    if (pTMaterialVar)
    {
         if(pTMaterialVar->GetIntValue() != kRenderGlow)
         {
              pTMaterialVar->SetIntValue( kRenderGlow );
              testMaterial->RecomputeStateSnapshots();
         }
    }

This is also the reason when you first start up a fresh sdk MP game, your
physics cannon has opaque sprites in a couple of it's textures. I did a
quick fix with some code and the physics cannon was fixed. In my quick fix
I
used the same rendermode for all the textures so some of em looked a little
wonky but it still worked. I just need to tweak it or maybe look again at
the texture's vmt file...
So are material's suppose to have a default rendermode based on what they
are (e.g. Sprite,unlitgeneric,etc.). Or is it always 0 unless set? Are
unlitgenerics suppose to use $spriteRenderMode?
Another strange thing happened when I called aMaterial->Refresh() during
testing. After that I called FindVarFast so I could look at the int value
of
$spriteRenderMode, it was set to a large int(792588). Whats weird is that I
called FindVar right after and the int value was different. It was
(3,170,352) which is the first int, but just bit shifted to the left 2
times. 3,170,352 when looking at MaterialVarFlags_t seems to line up with a
good default render setting bitmask. So is this how aMaterial->Refresh() is
suppose to act? Using the code from above with out using Refresh() makes
them both return 3.

EJ


From: "Eric Van Huss" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: RE: [hlcoders] Question about materials
Date: Sun, 12 Nov 2006 14:32:52 -0700

[ Converted text/html to text/plain ]

Sorry should've mentioned that I had tried both sprite and unlitgeneric
and
have also tried $spriterendermode with the sprite. (tried 0 through 6 but
it
should be 3 I think)

I'll see if I can use IMaterialVar to get/set but any other suggestions
would
be appreciated.

Thanks,

EJ


------------------------------------------------------------------------------
From:  "Jay Stelly" <[EMAIL PROTECTED]>
Reply-To:  [email protected]
To:  <[email protected]>
Subject:  RE: [hlcoders] Question about materials
Date:  Sun, 12 Nov 2006 10:13:45 -0800
It can depend on the material.  In this case I'd guess you have a sprite
material and it's the rendermode key that's set to normal (which is not
transparent) and you change it to kRenderGlow (which is).

Jay


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Eric Van Huss
> Sent: Sunday, November 12, 2006 8:18 AM
> To: [email protected]
> Subject: [hlcoders] Question about materials
>
> [ Converted text/html to text/plain ]
>
> Trying to fix a visual bug.
>
> What can you set in a .vmt file where
> aMaterial->IsTranslucent() would return True? I tried the
> obvious "$translucent" "1" but that didn't work(I've tried
> lots of other stuff). Here's some more info.
>
> If a temp sprite ,using the same material, calls
> SetTransparency( kRenderGlow, 255, 255, 255, 200,
> kRenderFxNoDissipation ) then the material gets changed and
> aMaterial->IsTranslucent() returns True. If I call
> aMaterial->Refresh(),
> IsTranslucent() returns False and the visual bug returns. Which means
> Refresh() is working(I think). So I just need to know what
> settings in a .vmt file makes aMaterial->IsTranslucent() return True.
>
> EJ
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list
> archives, please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>

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



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




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




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

Reply via email to