MCPcopy Create free account
hub / github.com/defold/defold / SetMaterialSampler

Function SetMaterialSampler

engine/gamesys/src/gamesys/scripts/script_material.cpp:732–757  ·  view source on GitHub ↗

sets texture samplers in a material * Sets texture samplers in a material, if the samplers exist. Use this function to change the settings of texture samplers. * To set actual textures that should be bound to the samplers, use the `material.set_textures` function instead. * * @name material.set_samplers * * @param path [type:hash|string] The path to the resource

Source from the content-addressed store, hash-verified

730 * ```
731 */
732 static int SetMaterialSampler(lua_State* L, MaterialResource* material_res, dmhash_t name_hash, int args_index)
733 {
734 args_index = args_index < 0 ? lua_gettop(L) + args_index + 1 : args_index;
735
736 uint32_t unit = dmRender::GetMaterialSamplerUnit(material_res->m_Material, name_hash);
737 if (unit == dmRender::INVALID_SAMPLER_UNIT)
738 {
739 return luaL_error(L, "Material sampler '%s' not found", dmHashReverseSafe64(name_hash));
740 }
741
742 dmRender::HSampler sampler = dmRender::GetMaterialSampler(material_res->m_Material, unit);
743
744 dmRender::SamplerInfo sampler_info = {};
745 dmRender::GetSamplerInfo(sampler, &sampler_info);
746
747 luaL_checktype(L, args_index, LUA_TTABLE);
748 lua_pushvalue(L, args_index);
749
750 GetSamplerParametersFromLua(L, &sampler_info.m_UWrap, &sampler_info.m_VWrap, &sampler_info.m_MinFilter, &sampler_info.m_MagFilter, &sampler_info.m_MaxAnisotropy);
751
752 lua_pop(L, 1);
753
754 dmRender::SetMaterialSampler(material_res->m_Material, name_hash, unit, sampler_info.m_UWrap, sampler_info.m_VWrap, sampler_info.m_MinFilter, sampler_info.m_MagFilter, sampler_info.m_MaxAnisotropy);
755
756 return 0;
757 }
758
759 static int Material_SetSamplers(lua_State* L)
760 {

Callers 4

Material_SetSamplersFunction · 0.70
SetupSkinnedMatrixCacheFunction · 0.50
ApplyMorphToRenderObjectFunction · 0.50
SetMaterialFunction · 0.50

Calls 9

lua_gettopFunction · 0.85
GetMaterialSamplerUnitFunction · 0.85
luaL_errorFunction · 0.85
dmHashReverseSafe64Function · 0.85
GetMaterialSamplerFunction · 0.85
GetSamplerInfoFunction · 0.85
luaL_checktypeFunction · 0.85
lua_pushvalueFunction · 0.85

Tested by

no test coverage detected