Load particle cloud materials

This commit is contained in:
Jan 2022-08-07 15:45:40 +02:00
parent c55f759793
commit a8bb1a5ead
2 changed files with 75 additions and 4 deletions

View File

@ -172,14 +172,82 @@ namespace IW4
void mtl_distortion_template()
{
// TODO
throw SkipMaterialException();
commonsetup_template();
const auto uvAnim = ReadBoolProperty("uvAnim");
if (uvAnim)
SetTechniqueSet("distortion_scale_ua_zfeather");
else
SetTechniqueSet("distortion_scale_zfeather");
const auto colorMapName = ReadStringProperty("colorMap");
const auto tileColor = ReadEnumProperty<TileMode_e>("tileColor", GdtTileModeNames, std::extent_v<decltype(GdtTileModeNames)>);
const auto filterColor = ReadEnumProperty<GdtFilter_e>("filterColor", GdtSamplerFilterNames, std::extent_v<decltype(GdtSamplerFilterNames)>);
if (!colorMapName.empty())
AddMapTexture("colorMap", tileColor, filterColor, TS_COLOR_MAP, colorMapName);
else
throw GdtReadingException("ColorMap may not be blank in tools materials");
const auto distortionScaleX = ReadFloatProperty("distortionScaleX");
const auto distortionScaleY = ReadFloatProperty("distortionScaleY");
AddConstant("distortionScale", Vector4f(distortionScaleX, distortionScaleY, 0, 0));
if (uvAnim)
{
const auto uvScrollX = ReadFloatProperty("uvScrollX");
const auto uvScrollY = ReadFloatProperty("uvScrollY");
const auto uvScrollRotate = ReadFloatProperty("uvScrollRotate");
AddConstant("uvAnimParms", Vector4f(uvScrollX, uvScrollY, uvScrollRotate, 0));
}
}
void mtl_particlecloud_template()
{
// TODO
throw SkipMaterialException();
refblend_template();
sort_template();
clamp_template();
SetTextureAtlas(1, 1);
// tessSize(0)
// hasEditorMaterial
// allocLightmap
statebits_template();
std::string outdoorSuffix;
const auto outdoorOnly = ReadBoolProperty("outdoorOnly");
if (outdoorOnly)
outdoorSuffix = "_outdoor";
std::string addSuffix;
const auto blendFunc = ReadStringProperty("blendFunc");
if (blendFunc == GDT_BLEND_FUNC_ADD || blendFunc == GDT_BLEND_FUNC_SCREEN_ADD)
addSuffix = "_add";
std::string spotSuffix;
const auto useSpotLight = ReadBoolProperty("useSpotLight");
if (useSpotLight)
spotSuffix = "_spot";
if(outdoorOnly && useSpotLight)
throw GdtReadingException("Outdoor and spot aren't supported on particle cloud materials");
std::ostringstream ss;
ss << "particle_cloud" << outdoorSuffix << addSuffix << spotSuffix;
SetTechniqueSet(ss.str());
const auto colorMapName = ReadStringProperty("colorMap");
const auto tileColor = ReadEnumProperty<TileMode_e>("tileColor", GdtTileModeNames, std::extent_v<decltype(GdtTileModeNames)>);
const auto filterColor = ReadEnumProperty<GdtFilter_e>("filterColor", GdtSamplerFilterNames, std::extent_v<decltype(GdtSamplerFilterNames)>);
if (!colorMapName.empty())
AddMapTexture("colorMap", tileColor, filterColor, TS_COLOR_MAP, colorMapName);
else
throw GdtReadingException("ColorMap may not be blank in particle cloud materials");
std::cout << "Using particlecloud for \"" << m_material->info.name << "\"\n";
}
void mtl_tools_template()

View File

@ -1343,6 +1343,9 @@ namespace IW4
SetValue("waterColor", m_constants_info.m_water_color);
SetValue("flagSpeed", m_constants_info.m_flag_speed);
SetValue("flagPhase", m_constants_info.m_flag_phase);
SetValue("uvScrollX", m_constants_info.m_uv_scroll_x);
SetValue("uvScrollY", m_constants_info.m_uv_scroll_y);
SetValue("uvScrollRotate", m_constants_info.m_uv_rotate);
}
void SetTextureTableValues()