Solved CSGO IMaterial / IMaterialSystem for Wireframe hands

  • CSGO recently moved logic from 'client_panorama.dll' to 'client.dll', you must update all code that uses 'client_panorama.dll' and replace it with 'client.dll' or the code will not work.
Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Nerd0

Newbie
Dank Tier Donator
May 1, 2015
28
118
1
Hey,

I attempted to do NoHands / Wireframe hands today, but I ran into an issue, IMaterial->SetMaterialFlag doesn't seem to work.
SDK Related:
C++:
class IMaterial
{
public:
	void SetMaterialVarFlag(MaterialVarFlags_t flag, bool on) // doesnt work
	{
		typedef void(__thiscall* OriginalFn)(PVOID, MaterialVarFlags_t, bool);
		return getvfunc<OriginalFn>(this, 30)(this, flag, on);
	}
};

class IMaterialSystem // works
{
public:

	IMaterial* FindMaterial(char const* pMaterialName, const char *pTextureGroupName, bool complain = true, const char *pComplainPrefix = NULL)
	{
		typedef IMaterial*(__thiscall* OriginalFn)( PVOID, char const*, const char*, bool, const char*);
		return getvfunc<OriginalFn>(this, 75)(this, pMaterialName, pTextureGroupName, complain, pComplainPrefix);
	}
};
I used Dude719's SDK and counted down to 30 and found SetMaterialVarFlag. The IMaterialSystem class works because I did:
C++:
IMaterial *test= g_pMaterialSystem->FindMaterial("models\\weapons\\v_models\\hands\\testestest", NULL);
And it spammed my console with "can't find material X."

My MaterialVarFlags (Creds: dude719):
C++:
enum MaterialVarFlags_t
{
	MATERIAL_VAR_DEBUG = (1 << 0),
	MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
	MATERIAL_VAR_NO_DRAW = (1 << 2),
	MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),

	MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
	MATERIAL_VAR_VERTEXALPHA = (1 << 5),
	MATERIAL_VAR_SELFILLUM = (1 << 6),
	MATERIAL_VAR_ADDITIVE = (1 << 7),
	MATERIAL_VAR_ALPHATEST = (1 << 8),
	//	MATERIAL_VAR_UNUSED					  = (1 << 9),
	MATERIAL_VAR_ZNEARER = (1 << 10),
	MATERIAL_VAR_MODEL = (1 << 11),
	MATERIAL_VAR_FLAT = (1 << 12),
	MATERIAL_VAR_NOCULL = (1 << 13),
	MATERIAL_VAR_NOFOG = (1 << 14),
	MATERIAL_VAR_IGNOREZ = (1 << 15),
	MATERIAL_VAR_DECAL = (1 << 16),
	MATERIAL_VAR_ENVMAPSPHERE = (1 << 17), // OBSOLETE
	//	MATERIAL_VAR_UNUSED					  = (1 << 18),
	MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19), // OBSOLETE
	MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
	MATERIAL_VAR_TRANSLUCENT = (1 << 21),
	MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
	MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23), // OBSOLETE
	MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
	MATERIAL_VAR_ENVMAPMODE = (1 << 25), // OBSOLETE
	MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
	MATERIAL_VAR_HALFLAMBERT = (1 << 27),
	MATERIAL_VAR_WIREFRAME = (1 << 28),
	MATERIAL_VAR_ALLOWALPHATOCOVERAGE = (1 << 29),
	MATERIAL_VAR_ALPHA_MODIFIED_BY_PROXY = (1 << 30),
	MATERIAL_VAR_VERTEXFOG = (1 << 31),

	// NOTE: Only add flags here that either should be read from
	// .vmts or can be set directly from client code. Other, internal
	// flags should to into the flag enum in IMaterialInternal.h
};


//-----------------------------------------------------------------------------
// Internal flags not accessible from outside the material system. Stored in Flags2
//-----------------------------------------------------------------------------
enum MaterialVarFlags2_t
{
	// NOTE: These are for $flags2!!!!!
	//	UNUSED											= (1 << 0),

	MATERIAL_VAR2_LIGHTING_UNLIT = 0,
	MATERIAL_VAR2_LIGHTING_VERTEX_LIT = (1 << 1),
	MATERIAL_VAR2_LIGHTING_LIGHTMAP = (1 << 2),
	MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP = (1 << 3),
	MATERIAL_VAR2_LIGHTING_MASK =
	(MATERIAL_VAR2_LIGHTING_VERTEX_LIT |
	MATERIAL_VAR2_LIGHTING_LIGHTMAP |
	MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP),

	// FIXME: Should this be a part of the above lighting enums?
	MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL = (1 << 4),
	MATERIAL_VAR2_USES_ENV_CUBEMAP = (1 << 5),
	MATERIAL_VAR2_NEEDS_TANGENT_SPACES = (1 << 6),
	MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING = (1 << 7),
	// GR - HDR path puts lightmap alpha in separate texture...
	MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA = (1 << 8),
	MATERIAL_VAR2_NEEDS_BAKED_LIGHTING_SNAPSHOTS = (1 << 9),
	MATERIAL_VAR2_USE_FLASHLIGHT = (1 << 10),
	MATERIAL_VAR2_USE_FIXED_FUNCTION_BAKED_LIGHTING = (1 << 11),
	MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT = (1 << 12),
	MATERIAL_VAR2_USE_EDITOR = (1 << 13),
	MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE = (1 << 14),
	MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE = (1 << 15),
	MATERIAL_VAR2_IS_SPRITECARD = (1 << 16),
	MATERIAL_VAR2_USES_VERTEXID = (1 << 17),
	MATERIAL_VAR2_SUPPORTS_HW_SKINNING = (1 << 18),
	MATERIAL_VAR2_SUPPORTS_FLASHLIGHT = (1 << 19),
	MATERIAL_VAR2_USE_GBUFFER0 = (1 << 20),
	MATERIAL_VAR2_USE_GBUFFER1 = (1 << 21),
	MATERIAL_VAR2_SELFILLUMMASK = (1 << 22),
	MATERIAL_VAR2_SUPPORTS_TESSELLATION = (1 << 23)
};
Wireframe code:
C++:
                        if (gCvars.misc_wireframe)
			{
				IMaterial *Hands = g_pMaterialSystem->FindMaterial("models\\weapons\\v_models\\hands\\v_hands", "Model textures");
				Hands->SetMaterialVarFlag(MATERIAL_VAR_WIREFRAME, true);
				Hands->SetMaterialVarFlag(MATERIAL_VAR_NO_DRAW, false);
				Hands->SetMaterialVarFlag(MATERIAL_VAR_IGNOREZ, true);
			}
g_pMaterialSystem(Even though I'm 100% sure it works)
C++:
g_pMatSysFactory = (CreateInterfaceFn)GetProcAddress(GetModuleHandleSafe("materialsystem.dll"), "CreateInterface");
g_pMaterialSystem = (IMaterialSystem*)g_pMatSysFactory("VMaterialSystem080", NULL);
Any help is appreciated greatly!
PS: Sorry for terrible grammar.
 
Last edited:

rN'

Jr.Hacker
Meme Tier VIP
Jan 19, 2014
340
5,268
41
Can you give any hints on how it's done?
C++:
if( strModelName.find( "models/weapons/ct_arms" ) != std::string::npos || strModelName.find( "models/weapons/t_arms" ) != std::string::npos )
{
	studiohdr_t *pHdr = g_pModelInfo->GetStudioModel( pInfo.pModel );
	if( pHdr )
	{
		IMaterial *pMaterials[ 32 ];
		g_pModelInfo->GetModelMaterials( pInfo.pModel, pHdr->numtextures, pMaterials );
		
		for( int i = 0; i < pHdr->numtextures; i++ )
		{
			IMaterial *pMaterial = pMaterials[ i ];
			if( !pMaterial )
				continue;

			if( gCvars.misc_wireframe )
				pMaterial->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME, true );
			else pMaterial->SetMaterialVarFlag( MATERIAL_VAR_WIREFRAME, false );

			g_pModelRender->ForceMaterialOverrde( pMaterial );
		}
	}
}
 

rN'

Jr.Hacker
Meme Tier VIP
Jan 19, 2014
340
5,268
41
FindMaterial is index 84 and SetMaterialVarFlag is index 29 lel

Edit: your wireframe code is wrong
 
Last edited:

Souper

Newbie
Full Member
Jun 1, 2014
18
308
0
Wow. Never even noticed that. I just thought that because of your signature.
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods