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
| 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 | { |
no test coverage detected