Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. IMaterial* create_material_metallic(bool ignorez, bool lit, bool wireframe)
  2. {
  3. static auto created = 0;
  4.  
  5. std::string type = lit ? "VertexLitGeneric" : "UnlitGeneric";
  6. auto matdata =
  7. "\"" + type + "\"\
  8. \n{\
  9. \n\t\"$basetexture\" \"vgui/white_additive\"\
  10. \n\t\"$envmap\" \"env_cubemap\"\
  11. \n\t\"$model\" \"1\"\
  12. \n\t\"$normalmapalphaenvmapmask\" \"1\"\
  13. \n\t\"$envmapcontrast\" \"1\"\
  14. \n\t\"$flat\" \"1\"\
  15. \n\t\"$nocull\" \"0\"\
  16. \n\t\"$selfillum\" \"1\"\
  17. \n\t\"$halflambert\" \"1\"\
  18. \n\t\"$nofog\" \"0\"\
  19. \n\t\"$ignorez\" \"" + std::to_string(ignorez) + "\"\
  20. \n\t\"$znearer\" \"0\"\
  21. \n\t\"$wireframe\" \"" + std::to_string(wireframe) + "\"\
  22. \n}\n";
  23.  
  24. auto matname = "custom_" + std::to_string(created);
  25. ++created;
  26.  
  27. auto init_key_values = [](KeyValuesv2* keyvalues, const char* key_name) -> void {
  28. using InitKeyValues_t = void(__thiscall*)(void*, const char*);
  29. static InitKeyValues_t InitKeyValuesEx = nullptr;
  30. static auto pThis = *reinterpret_cast<DWORD * *>(Utils::FindSignature("client_panorama.dll", "B9 ? ? ? ? E8 ? ? ? ? 8B 5D 08") + 1);
  31. if (!InitKeyValuesEx)
  32. InitKeyValuesEx = *reinterpret_cast<InitKeyValues_t>(Utils::FindSignature("client_panorama.dll", "55 8B EC 51 33 C0 C7 45"));
  33.  
  34. InitKeyValuesEx(keyvalues, key_name);
  35. };
  36.  
  37. auto load_from_buffer = [](KeyValuesv2* key_values, const char* resource_name, const char* buf, void* file_sys = nullptr, const char* path_id = nullptr, void* eval_sym_proc = nullptr, void* unk = nullptr) -> void {
  38. using LoadFromBuffer_t = void(__thiscall*)(void*, const char*, const char*, void*, const char*, void*, void*);
  39. static LoadFromBuffer_t LoadFromBufferEx = nullptr;
  40.  
  41. if (!LoadFromBufferEx)
  42. LoadFromBufferEx = *reinterpret_cast<LoadFromBuffer_t>(Utils::FindSignature("client_panorama.dll", "55 8B EC 83 E4 F8 83 EC 34 53 8B 5D 0C 89"));
  43.  
  44. LoadFromBufferEx(key_values, resource_name, buf, file_sys, path_id, eval_sym_proc, unk);
  45. };
  46.  
  47. auto* key_values = new KeyValuesv2();
  48. init_key_values(key_values, type.c_str());
  49. load_from_buffer(key_values, matname.c_str(), matdata.c_str());
  50.  
  51. return g_pMaterialSys->CreateMaterial(matname.c_str(), key_values);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement