SetMaterialOverride() ?

Just wondering if anyone knoes how to use this to override the textures for everything i tried putting it in GM:RenderScene() with no avial?

Typically you’d call SetMaterialOverride in between cam.Start3D() and cam.End3D() and draw whatever entities who’s texture you want to override manually with Entity.Draw. Or (this might be risky), you could call cam.Start3D() and SetMaterialOverride() in the PreDrawOpaqueRenderables hook and then call cam.End3D() in PostDrawOpaqueRenderables. This should make every opaque entity in the game be drawn with the material you specify (if it works).

That’s how i’m overriding props and npc’s, but it doesn’t overide the map, it appears to be drawn before hand as failing to “turn off” SetMaterialOverride() doesn’t do it.

[editline]09:46PM[/editline]

and SetMaterialOverride() works fine without the cam.Start3D() & cam.End3D() functions

[editline]09:48PM[/editline]

I’m thinking of just drawing a full screen quad then props and etc over the top, i’m trying to achieve something to the ivision post procceses but less taxing on the cpu by avoiding the stencil buffer.

The materials on the map have very different naming than the materials that are used. Try using the command “mat_crosshair” while looking at a material in the map. That will give you the exact map name to use to override.

Well i was more relying on the fact that if you leave SetMaterialOverride() open earlier enough in the rendering stage, ALL materials are overridden with the material you specify, how ever i can not find a hook that is called early enough.

Maybe RenderScene? That may be too late, though.

You could try the new Pre and Post skybox rendering hooks, I presume Source renders the skybox before anything else?

SetMaterialOverride must be called prior to drawing something. Typically in an ent’s draw hook you’d do
[lua]
local material=Material(“some/thing”);

function ENT:Draw()
SetMaterialOverride(material)
self.Entity:DrawModel();
SetMaterialOverride(nil)
end
[/lua]

If you were looking to change the material of everything… that’s a different story. I’m not sure how you’d go about do thing that.
I’d imagine it would work for a few things and then the material override would get set to nil by something else, or that the material override would get set to nil right off the bat if you tried to render the whole scene.