big material texture slot refactor
This commit is contained in:
+140
-808
File diff suppressed because it is too large
Load Diff
+14
-37
@@ -42,44 +42,21 @@ public:
|
||||
wiSlider clearcoatSlider;
|
||||
wiSlider clearcoatRoughnessSlider;
|
||||
|
||||
wiLabel texture_baseColor_Label;
|
||||
wiLabel texture_normal_Label;
|
||||
wiLabel texture_surface_Label;
|
||||
wiLabel texture_displacement_Label;
|
||||
wiLabel texture_emissive_Label;
|
||||
wiLabel texture_occlusion_Label;
|
||||
wiLabel texture_transmission_Label;
|
||||
wiLabel texture_sheenColor_Label;
|
||||
wiLabel texture_sheenRoughness_Label;
|
||||
wiLabel texture_clearcoat_Label;
|
||||
wiLabel texture_clearcoatRoughness_Label;
|
||||
wiLabel texture_clearcoatNormal_Label;
|
||||
struct TextureSlotControls
|
||||
{
|
||||
std::string name;
|
||||
wiLabel label;
|
||||
wiButton button;
|
||||
wiTextInputField uvsetField;
|
||||
|
||||
wiButton texture_baseColor_Button;
|
||||
wiButton texture_normal_Button;
|
||||
wiButton texture_surface_Button;
|
||||
wiButton texture_displacement_Button;
|
||||
wiButton texture_emissive_Button;
|
||||
wiButton texture_occlusion_Button;
|
||||
wiButton texture_transmission_Button;
|
||||
wiButton texture_sheenColor_Button;
|
||||
wiButton texture_sheenRoughness_Button;
|
||||
wiButton texture_clearcoat_Button;
|
||||
wiButton texture_clearcoatRoughness_Button;
|
||||
wiButton texture_clearcoatNormal_Button;
|
||||
|
||||
wiTextInputField texture_baseColor_uvset_Field;
|
||||
wiTextInputField texture_normal_uvset_Field;
|
||||
wiTextInputField texture_surface_uvset_Field;
|
||||
wiTextInputField texture_displacement_uvset_Field;
|
||||
wiTextInputField texture_emissive_uvset_Field;
|
||||
wiTextInputField texture_occlusion_uvset_Field;
|
||||
wiTextInputField texture_transmission_uvset_Field;
|
||||
wiTextInputField texture_sheenColor_uvset_Field;
|
||||
wiTextInputField texture_sheenRoughness_uvset_Field;
|
||||
wiTextInputField texture_clearcoat_uvset_Field;
|
||||
wiTextInputField texture_clearcoatRoughness_uvset_Field;
|
||||
wiTextInputField texture_clearcoatNormal_uvset_Field;
|
||||
void SetEnabled(bool value)
|
||||
{
|
||||
label.SetEnabled(value);
|
||||
button.SetEnabled(value);
|
||||
uvsetField.SetEnabled(value);
|
||||
}
|
||||
};
|
||||
TextureSlotControls slots[wiScene::MaterialComponent::TEXTURESLOT_COUNT];
|
||||
|
||||
wiComboBox colorComboBox;
|
||||
wiColorPicker colorPicker;
|
||||
|
||||
@@ -438,41 +438,41 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
{
|
||||
auto& tex = state.gltfModel.textures[baseColorTexture->second.TextureIndex()];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.baseColorMap = RegisterTexture(&img, "basecolor");
|
||||
material.baseColorMapName = img.uri;
|
||||
material.uvset_baseColorMap = baseColorTexture->second.TextureTexCoord();
|
||||
material.textures[MaterialComponent::BASECOLORMAP].resource = RegisterTexture(&img, "basecolor");
|
||||
material.textures[MaterialComponent::BASECOLORMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::BASECOLORMAP].uvset = baseColorTexture->second.TextureTexCoord();
|
||||
}
|
||||
if (normalTexture != x.additionalValues.end())
|
||||
{
|
||||
auto& tex = state.gltfModel.textures[normalTexture->second.TextureIndex()];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.normalMap = RegisterTexture(&img, "normal");
|
||||
material.normalMapName = img.uri;
|
||||
material.uvset_normalMap = normalTexture->second.TextureTexCoord();
|
||||
material.textures[MaterialComponent::NORMALMAP].resource = RegisterTexture(&img, "normal");
|
||||
material.textures[MaterialComponent::NORMALMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::NORMALMAP].uvset = normalTexture->second.TextureTexCoord();
|
||||
}
|
||||
if (metallicRoughnessTexture != x.values.end())
|
||||
{
|
||||
auto& tex = state.gltfModel.textures[metallicRoughnessTexture->second.TextureIndex()];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.surfaceMap = RegisterTexture(&img, "roughness_metallic");
|
||||
material.surfaceMapName = img.uri;
|
||||
material.uvset_surfaceMap = metallicRoughnessTexture->second.TextureTexCoord();
|
||||
material.textures[MaterialComponent::SURFACEMAP].resource = RegisterTexture(&img, "roughness_metallic");
|
||||
material.textures[MaterialComponent::SURFACEMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::SURFACEMAP].uvset = metallicRoughnessTexture->second.TextureTexCoord();
|
||||
}
|
||||
if (emissiveTexture != x.additionalValues.end())
|
||||
{
|
||||
auto& tex = state.gltfModel.textures[emissiveTexture->second.TextureIndex()];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.emissiveMap = RegisterTexture(&img, "emissive");
|
||||
material.emissiveMapName = img.uri;
|
||||
material.uvset_emissiveMap = emissiveTexture->second.TextureTexCoord();
|
||||
material.textures[MaterialComponent::EMISSIVEMAP].resource = RegisterTexture(&img, "emissive");
|
||||
material.textures[MaterialComponent::EMISSIVEMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::EMISSIVEMAP].uvset = emissiveTexture->second.TextureTexCoord();
|
||||
}
|
||||
if (occlusionTexture != x.additionalValues.end())
|
||||
{
|
||||
auto& tex = state.gltfModel.textures[occlusionTexture->second.TextureIndex()];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.occlusionMap = RegisterTexture(&img, "occlusion");
|
||||
material.occlusionMapName = img.uri;
|
||||
material.uvset_occlusionMap = occlusionTexture->second.TextureTexCoord();
|
||||
material.textures[MaterialComponent::OCCLUSIONMAP].resource = RegisterTexture(&img, "occlusion");
|
||||
material.textures[MaterialComponent::OCCLUSIONMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::OCCLUSIONMAP].uvset = occlusionTexture->second.TextureTexCoord();
|
||||
material.SetOcclusionEnabled_Secondary(true);
|
||||
}
|
||||
|
||||
@@ -529,9 +529,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = ext_transmission->second.Get("transmissionTexture").Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.transmissionMap = RegisterTexture(&img, "transmission");
|
||||
material.transmissionMapName = img.uri;
|
||||
material.uvset_transmissionMap = (uint32_t)ext_transmission->second.Get("transmissionTexture").Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::TRANSMISSIONMAP].resource = RegisterTexture(&img, "transmission");
|
||||
material.textures[MaterialComponent::TRANSMISSIONMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::TRANSMISSIONMAP].uvset = (uint32_t)ext_transmission->second.Get("transmissionTexture").Get("texCoord").Get<int>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,18 +546,18 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = specularGlossinessWorkflow->second.Get("diffuseTexture").Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.baseColorMap = RegisterTexture(&img, "diffuse");
|
||||
material.baseColorMapName = img.uri;
|
||||
material.uvset_baseColorMap = (uint32_t)specularGlossinessWorkflow->second.Get("diffuseTexture").Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::BASECOLORMAP].resource = RegisterTexture(&img, "diffuse");
|
||||
material.textures[MaterialComponent::BASECOLORMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::BASECOLORMAP].uvset = (uint32_t)specularGlossinessWorkflow->second.Get("diffuseTexture").Get("texCoord").Get<int>();
|
||||
}
|
||||
if (specularGlossinessWorkflow->second.Has("specularGlossinessTexture"))
|
||||
{
|
||||
int index = specularGlossinessWorkflow->second.Get("specularGlossinessTexture").Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.surfaceMap = RegisterTexture(&img, "specular_glossiness");
|
||||
material.surfaceMapName = img.uri;
|
||||
material.uvset_surfaceMap = (uint32_t)specularGlossinessWorkflow->second.Get("specularGlossinessTexture").Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::SURFACEMAP].resource = RegisterTexture(&img, "specular_glossiness");
|
||||
material.textures[MaterialComponent::SURFACEMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::SURFACEMAP].uvset = (uint32_t)specularGlossinessWorkflow->second.Get("specularGlossinessTexture").Get("texCoord").Get<int>();
|
||||
}
|
||||
|
||||
if (specularGlossinessWorkflow->second.Has("diffuseFactor"))
|
||||
@@ -602,9 +602,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = param.Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.sheenColorMap = RegisterTexture(&img, "sheenColor");
|
||||
material.sheenColorMapName = img.uri;
|
||||
material.uvset_sheenColorMap = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::SHEENCOLORMAP].resource = RegisterTexture(&img, "sheenColor");
|
||||
material.textures[MaterialComponent::SHEENCOLORMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::SHEENCOLORMAP].uvset = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
}
|
||||
if (ext_sheen->second.Has("sheenRoughnessFactor"))
|
||||
{
|
||||
@@ -617,9 +617,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = param.Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.sheenRoughnessMap = RegisterTexture(&img, "sheenRoughness");
|
||||
material.sheenRoughnessMapName = img.uri;
|
||||
material.uvset_sheenRoughnessMap = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::SHEENROUGHNESSMAP].resource = RegisterTexture(&img, "sheenRoughness");
|
||||
material.textures[MaterialComponent::SHEENROUGHNESSMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::SHEENROUGHNESSMAP].uvset = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,9 +646,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = param.Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.clearcoatMap = RegisterTexture(&img, "clearcoat");
|
||||
material.clearcoatMapName = img.uri;
|
||||
material.uvset_clearcoatMap = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::CLEARCOATMAP].resource = RegisterTexture(&img, "clearcoat");
|
||||
material.textures[MaterialComponent::CLEARCOATMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::CLEARCOATMAP].uvset = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
}
|
||||
if (ext_clearcoat->second.Has("clearcoatRoughnessFactor"))
|
||||
{
|
||||
@@ -661,9 +661,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = param.Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.clearcoatRoughnessMap = RegisterTexture(&img, "clearcoatRoughness");
|
||||
material.clearcoatRoughnessMapName = img.uri;
|
||||
material.uvset_clearcoatRoughnessMap = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::CLEARCOATROUGHNESSMAP].resource = RegisterTexture(&img, "clearcoatRoughness");
|
||||
material.textures[MaterialComponent::CLEARCOATROUGHNESSMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::CLEARCOATROUGHNESSMAP].uvset = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
}
|
||||
if (ext_clearcoat->second.Has("clearcoatNormalTexture"))
|
||||
{
|
||||
@@ -671,9 +671,9 @@ void ImportModel_GLTF(const std::string& fileName, Scene& scene)
|
||||
int index = param.Get("index").Get<int>();
|
||||
auto& tex = state.gltfModel.textures[index];
|
||||
auto& img = state.gltfModel.images[tex.source];
|
||||
material.clearcoatNormalMap = RegisterTexture(&img, "clearcoatNormal");
|
||||
material.clearcoatNormalMapName = img.uri;
|
||||
material.uvset_clearcoatNormalMap = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
material.textures[MaterialComponent::CLEARCOATNORMALMAP].resource = RegisterTexture(&img, "clearcoatNormal");
|
||||
material.textures[MaterialComponent::CLEARCOATNORMALMAP].name = img.uri;
|
||||
material.textures[MaterialComponent::CLEARCOATNORMALMAP].uvset = (uint32_t)param.Get("texCoord").Get<int>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,43 +112,28 @@ void ImportModel_OBJ(const std::string& fileName, Scene& scene)
|
||||
MaterialComponent& material = *scene.materials.GetComponent(materialEntity);
|
||||
|
||||
material.baseColor = XMFLOAT4(obj_material.diffuse[0], obj_material.diffuse[1], obj_material.diffuse[2], 1);
|
||||
material.baseColorMapName = obj_material.diffuse_texname;
|
||||
material.displacementMapName = obj_material.displacement_texname;
|
||||
material.textures[MaterialComponent::BASECOLORMAP].name = obj_material.diffuse_texname;
|
||||
material.textures[MaterialComponent::DISPLACEMENTMAP].name = obj_material.displacement_texname;
|
||||
material.emissiveColor.x = obj_material.emission[0];
|
||||
material.emissiveColor.y = obj_material.emission[1];
|
||||
material.emissiveColor.z = obj_material.emission[2];
|
||||
material.emissiveColor.w = max(obj_material.emission[0], max(obj_material.emission[1], obj_material.emission[2]));
|
||||
//material.refractionIndex = obj_material.ior;
|
||||
material.metalness = obj_material.metallic;
|
||||
material.normalMapName = obj_material.normal_texname;
|
||||
material.surfaceMapName = obj_material.specular_texname;
|
||||
material.textures[MaterialComponent::NORMALMAP].name = obj_material.normal_texname;
|
||||
material.textures[MaterialComponent::SURFACEMAP].name = obj_material.specular_texname;
|
||||
material.roughness = obj_material.roughness;
|
||||
|
||||
if (material.normalMapName.empty())
|
||||
if (material.textures[MaterialComponent::NORMALMAP].name.empty())
|
||||
{
|
||||
material.normalMapName = obj_material.bump_texname;
|
||||
material.textures[MaterialComponent::NORMALMAP].name = obj_material.bump_texname;
|
||||
}
|
||||
if (material.surfaceMapName.empty())
|
||||
if (material.textures[MaterialComponent::SURFACEMAP].name.empty())
|
||||
{
|
||||
material.surfaceMapName = obj_material.specular_highlight_texname;
|
||||
material.textures[MaterialComponent::SURFACEMAP].name = obj_material.specular_highlight_texname;
|
||||
}
|
||||
|
||||
if (!material.surfaceMapName.empty())
|
||||
{
|
||||
material.surfaceMap = wiResourceManager::Load(directory + material.surfaceMapName);
|
||||
}
|
||||
if (!material.baseColorMapName.empty())
|
||||
{
|
||||
material.baseColorMap = wiResourceManager::Load(directory + material.baseColorMapName);
|
||||
}
|
||||
if (!material.normalMapName.empty())
|
||||
{
|
||||
material.normalMap = wiResourceManager::Load(directory + material.normalMapName);
|
||||
}
|
||||
if (!material.displacementMapName.empty())
|
||||
{
|
||||
material.displacementMap = wiResourceManager::Load(directory + material.displacementMapName);
|
||||
}
|
||||
material.CreateRenderData(directory);
|
||||
|
||||
materialLibrary.push_back(materialEntity); // for subset-indexing...
|
||||
}
|
||||
|
||||
+20
-75
@@ -132,12 +132,18 @@ void PaintToolWindow::Create(EditorComponent* editor)
|
||||
textureSlotComboBox.SetTooltip("Choose texture slot of the selected material to paint (texture paint mode only)");
|
||||
textureSlotComboBox.SetPos(XMFLOAT2(x, y += step));
|
||||
textureSlotComboBox.SetSize(XMFLOAT2(200, hei));
|
||||
textureSlotComboBox.AddItem("BaseColor (RGBA)");
|
||||
textureSlotComboBox.AddItem("Normal (RGB)");
|
||||
textureSlotComboBox.AddItem("SurfaceMap (RGBA)");
|
||||
textureSlotComboBox.AddItem("DisplacementMap (R)");
|
||||
textureSlotComboBox.AddItem("EmissiveMap (RGBA)");
|
||||
textureSlotComboBox.AddItem("OcclusionMap (R)");
|
||||
textureSlotComboBox.AddItem("BaseColor (RGBA)", MaterialComponent::BASECOLORMAP);
|
||||
textureSlotComboBox.AddItem("Normal (RGB)", MaterialComponent::NORMALMAP);
|
||||
textureSlotComboBox.AddItem("SurfaceMap (RGBA)", MaterialComponent::SURFACEMAP);
|
||||
textureSlotComboBox.AddItem("DisplacementMap (R)", MaterialComponent::DISPLACEMENTMAP);
|
||||
textureSlotComboBox.AddItem("EmissiveMap (RGBA)", MaterialComponent::EMISSIVEMAP);
|
||||
textureSlotComboBox.AddItem("OcclusionMap (R)", MaterialComponent::OCCLUSIONMAP);
|
||||
textureSlotComboBox.AddItem("TransmissionMap (R)", MaterialComponent::TRANSMISSIONMAP);
|
||||
textureSlotComboBox.AddItem("SheenColorMap (R)", MaterialComponent::SHEENCOLORMAP);
|
||||
textureSlotComboBox.AddItem("SheenRoughMap (R)", MaterialComponent::SHEENROUGHNESSMAP);
|
||||
textureSlotComboBox.AddItem("ClearcoatMap (R)", MaterialComponent::CLEARCOATMAP);
|
||||
textureSlotComboBox.AddItem("ClearcoatRoughMap (R)", MaterialComponent::CLEARCOATROUGHNESSMAP);
|
||||
textureSlotComboBox.AddItem("ClearcoatNormMap (R)", MaterialComponent::CLEARCOATNORMALMAP);
|
||||
textureSlotComboBox.SetSelected(0);
|
||||
textureSlotComboBox.SetEnabled(false);
|
||||
AddWidget(&textureSlotComboBox);
|
||||
@@ -166,29 +172,8 @@ void PaintToolWindow::Create(EditorComponent* editor)
|
||||
|
||||
std::string* slotname = nullptr;
|
||||
|
||||
int sel = textureSlotComboBox.GetSelected();
|
||||
switch (sel)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
slotname = &material->baseColorMapName;
|
||||
break;
|
||||
case 1:
|
||||
slotname = &material->normalMapName;
|
||||
break;
|
||||
case 2:
|
||||
slotname = &material->surfaceMapName;
|
||||
break;
|
||||
case 3:
|
||||
slotname = &material->displacementMapName;
|
||||
break;
|
||||
case 4:
|
||||
slotname = &material->emissiveMapName;
|
||||
break;
|
||||
case 5:
|
||||
slotname = &material->occlusionMapName;
|
||||
break;
|
||||
}
|
||||
uint64_t sel = textureSlotComboBox.GetItemUserData(textureSlotComboBox.GetSelected());
|
||||
slotname = &material->textures[sel].name;
|
||||
|
||||
wiHelper::RemoveExtensionFromFileName(*slotname);
|
||||
*slotname = *slotname + "_0.png";
|
||||
@@ -1259,53 +1244,13 @@ void PaintToolWindow::ConsumeHistoryOperation(wiArchive& archive, bool undo)
|
||||
}
|
||||
std::shared_ptr<wiResource> PaintToolWindow::GetEditTextureSlot(const MaterialComponent& material, int* uvset)
|
||||
{
|
||||
int sel = textureSlotComboBox.GetSelected();
|
||||
switch (sel)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
if (uvset) *uvset = material.uvset_baseColorMap;
|
||||
return material.baseColorMap;
|
||||
case 1:
|
||||
if (uvset) *uvset = material.uvset_normalMap;
|
||||
return material.normalMap;
|
||||
case 2:
|
||||
if (uvset) *uvset = material.uvset_surfaceMap;
|
||||
return material.surfaceMap;
|
||||
case 3:
|
||||
if (uvset) *uvset = material.uvset_displacementMap;
|
||||
return material.displacementMap;
|
||||
case 4:
|
||||
if (uvset) *uvset = material.uvset_emissiveMap;
|
||||
return material.emissiveMap;
|
||||
case 5:
|
||||
if (uvset) *uvset = material.uvset_occlusionMap;
|
||||
return material.occlusionMap;
|
||||
}
|
||||
uint64_t sel = textureSlotComboBox.GetItemUserData(textureSlotComboBox.GetSelected());
|
||||
if (uvset)
|
||||
*uvset = material.textures[sel].uvset;
|
||||
return material.textures[sel].resource;
|
||||
}
|
||||
void PaintToolWindow::ReplaceEditTextureSlot(wiScene::MaterialComponent& material, std::shared_ptr<wiResource> resource)
|
||||
{
|
||||
int sel = textureSlotComboBox.GetSelected();
|
||||
switch (sel)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
material.baseColorMap = resource;
|
||||
break;
|
||||
case 1:
|
||||
material.normalMap = resource;
|
||||
break;
|
||||
case 2:
|
||||
material.surfaceMap = resource;
|
||||
break;
|
||||
case 3:
|
||||
material.displacementMap = resource;
|
||||
break;
|
||||
case 4:
|
||||
material.emissiveMap = resource;
|
||||
break;
|
||||
case 5:
|
||||
material.occlusionMap = resource;
|
||||
break;
|
||||
}
|
||||
uint64_t sel = textureSlotComboBox.GetItemUserData(textureSlotComboBox.GetSelected());
|
||||
material.textures[sel].resource = resource;
|
||||
}
|
||||
|
||||
@@ -243,9 +243,9 @@ struct VertexSurface
|
||||
|
||||
uint normal_wind = asuint(input.pos.w);
|
||||
|
||||
normal.x = (float)((normal_wind >> 0) & 0xFF) / 255.0f * 2.0f - 1.0f;
|
||||
normal.y = (float)((normal_wind >> 8) & 0xFF) / 255.0f * 2.0f - 1.0f;
|
||||
normal.z = (float)((normal_wind >> 16) & 0xFF) / 255.0f * 2.0f - 1.0f;
|
||||
normal.x = (float)((normal_wind >> 0) & 0xFF) / 255.0 * 2 - 1;
|
||||
normal.y = (float)((normal_wind >> 8) & 0xFF) / 255.0 * 2 - 1;
|
||||
normal.z = (float)((normal_wind >> 16) & 0xFF) / 255.0 * 2 - 1;
|
||||
normal = normalize(mul((float3x3)WORLD, normal));
|
||||
|
||||
#ifdef OBJECTSHADER_INPUT_TAN
|
||||
@@ -256,7 +256,7 @@ struct VertexSurface
|
||||
#ifdef OBJECTSHADER_USE_WIND
|
||||
if (material.IsUsingWind())
|
||||
{
|
||||
const float windweight = ((normal_wind >> 24) & 0xFF) / 255.0f;
|
||||
const float windweight = ((normal_wind >> 24) & 0xFF) / 255.0;
|
||||
const float waveoffset = dot(position.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (position.x + position.y + position.z) * g_xFrame_WindRandomness;
|
||||
const float waveoffsetPrev = dot(positionPrev.xyz, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + (positionPrev.x + positionPrev.y + positionPrev.z) * g_xFrame_WindRandomness;
|
||||
const float3 wavedir = g_xFrame_WindDirection * windweight;
|
||||
@@ -287,7 +287,7 @@ struct VertexSurface
|
||||
|
||||
struct PixelInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
precise float4 pos : SV_POSITION;
|
||||
|
||||
#ifdef OBJECTSHADER_USE_CLIPPLANE
|
||||
float clip : SV_ClipDistance0;
|
||||
|
||||
@@ -541,7 +541,14 @@ void wiEmittedParticle::Draw(const CameraComponent& camera, const MaterialCompon
|
||||
{
|
||||
const BLENDMODE blendMode = material.GetBlendMode();
|
||||
device->BindPipelineState(&PSO[blendMode][shaderType], cmd);
|
||||
device->BindResource(PS, material.GetBaseColorMap(), TEXSLOT_ONDEMAND0, cmd);
|
||||
if (material.textures[MaterialComponent::BASECOLORMAP].resource == nullptr)
|
||||
{
|
||||
device->BindResource(PS, wiTextureHelper::getWhite(), TEXSLOT_ONDEMAND0, cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
device->BindResource(PS, material.textures[MaterialComponent::BASECOLORMAP].GetGPUResource(), TEXSLOT_ONDEMAND0, cmd);
|
||||
}
|
||||
device->BindShadingRate(material.shadingRate, cmd);
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -48,21 +48,21 @@ void wiGPUBVH::UpdateGlobalMaterialResources(const Scene& scene, CommandList cmd
|
||||
{
|
||||
const MaterialComponent& material = *scene.materials.GetComponent(subset.materialID);
|
||||
|
||||
if (material.baseColorMap != nullptr)
|
||||
if (material.textures[MaterialComponent::BASECOLORMAP].resource != nullptr)
|
||||
{
|
||||
sceneTextures.insert(material.baseColorMap);
|
||||
sceneTextures.insert(material.textures[MaterialComponent::BASECOLORMAP].resource);
|
||||
}
|
||||
if (material.surfaceMap != nullptr)
|
||||
if (material.textures[MaterialComponent::SURFACEMAP].resource != nullptr)
|
||||
{
|
||||
sceneTextures.insert(material.surfaceMap);
|
||||
sceneTextures.insert(material.textures[MaterialComponent::SURFACEMAP].resource);
|
||||
}
|
||||
if (material.emissiveMap != nullptr)
|
||||
if (material.textures[MaterialComponent::EMISSIVEMAP].resource != nullptr)
|
||||
{
|
||||
sceneTextures.insert(material.emissiveMap);
|
||||
sceneTextures.insert(material.textures[MaterialComponent::EMISSIVEMAP].resource);
|
||||
}
|
||||
if (material.normalMap != nullptr)
|
||||
if (material.textures[MaterialComponent::NORMALMAP].resource != nullptr)
|
||||
{
|
||||
sceneTextures.insert(material.normalMap);
|
||||
sceneTextures.insert(material.textures[MaterialComponent::NORMALMAP].resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,9 +150,9 @@ void wiGPUBVH::UpdateGlobalMaterialResources(const Scene& scene, CommandList cmd
|
||||
// Add extended properties:
|
||||
const TextureDesc& desc = globalMaterialAtlas.GetDesc();
|
||||
|
||||
if (material.baseColorMap != nullptr)
|
||||
if (material.textures[MaterialComponent::BASECOLORMAP].resource != nullptr)
|
||||
{
|
||||
rect_xywh rect = storedTextures[material.baseColorMap];
|
||||
rect_xywh rect = storedTextures[material.textures[MaterialComponent::BASECOLORMAP].resource];
|
||||
// eliminate border expansion:
|
||||
rect.x += atlasWrapBorder;
|
||||
rect.y += atlasWrapBorder;
|
||||
@@ -162,9 +162,9 @@ void wiGPUBVH::UpdateGlobalMaterialResources(const Scene& scene, CommandList cmd
|
||||
(float)rect.x / (float)desc.Width, (float)rect.y / (float)desc.Height);
|
||||
}
|
||||
|
||||
if (material.surfaceMap != nullptr)
|
||||
if (material.textures[MaterialComponent::SURFACEMAP].resource != nullptr)
|
||||
{
|
||||
rect_xywh rect = storedTextures[material.surfaceMap];
|
||||
rect_xywh rect = storedTextures[material.textures[MaterialComponent::SURFACEMAP].resource];
|
||||
// eliminate border expansion:
|
||||
rect.x += atlasWrapBorder;
|
||||
rect.y += atlasWrapBorder;
|
||||
@@ -174,9 +174,9 @@ void wiGPUBVH::UpdateGlobalMaterialResources(const Scene& scene, CommandList cmd
|
||||
(float)rect.x / (float)desc.Width, (float)rect.y / (float)desc.Height);
|
||||
}
|
||||
|
||||
if (material.emissiveMap != nullptr)
|
||||
if (material.textures[MaterialComponent::EMISSIVEMAP].resource != nullptr)
|
||||
{
|
||||
rect_xywh rect = storedTextures[material.emissiveMap];
|
||||
rect_xywh rect = storedTextures[material.textures[MaterialComponent::EMISSIVEMAP].resource];
|
||||
// eliminate border expansion:
|
||||
rect.x += atlasWrapBorder;
|
||||
rect.y += atlasWrapBorder;
|
||||
@@ -186,9 +186,9 @@ void wiGPUBVH::UpdateGlobalMaterialResources(const Scene& scene, CommandList cmd
|
||||
(float)rect.x / (float)desc.Width, (float)rect.y / (float)desc.Height);
|
||||
}
|
||||
|
||||
if (material.normalMap != nullptr)
|
||||
if (material.textures[MaterialComponent::NORMALMAP].resource != nullptr)
|
||||
{
|
||||
rect_xywh rect = storedTextures[material.normalMap];
|
||||
rect_xywh rect = storedTextures[material.textures[MaterialComponent::NORMALMAP].resource];
|
||||
// eliminate border expansion:
|
||||
rect.x += atlasWrapBorder;
|
||||
rect.y += atlasWrapBorder;
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#define WI_GRAPHICSDEVICE_SHAREDINTERNALS_H
|
||||
|
||||
// Descriptor layout counts per shader stage:
|
||||
// Rebuilding shaders and graphics devices are necessary after changing these values
|
||||
#define GPU_RESOURCE_HEAP_CBV_COUNT 12
|
||||
#define GPU_RESOURCE_HEAP_SRV_COUNT 48
|
||||
#define GPU_RESOURCE_HEAP_CBV_COUNT 15
|
||||
#define GPU_RESOURCE_HEAP_SRV_COUNT 64
|
||||
#define GPU_RESOURCE_HEAP_UAV_COUNT 8
|
||||
#define GPU_SAMPLER_HEAP_COUNT 16
|
||||
|
||||
|
||||
@@ -162,7 +162,11 @@ void wiHairParticle::UpdateGPU(const MeshComponent& mesh, const MaterialComponen
|
||||
GraphicsDevice* device = wiRenderer::GetDevice();
|
||||
device->EventBegin("HairParticle - UpdateRenderData", cmd);
|
||||
|
||||
const TextureDesc& desc = material.GetBaseColorMap()->GetDesc();
|
||||
TextureDesc desc;
|
||||
if (material.textures[MaterialComponent::BASECOLORMAP].resource != nullptr)
|
||||
{
|
||||
desc = material.textures[MaterialComponent::BASECOLORMAP].resource->texture->GetDesc();
|
||||
}
|
||||
|
||||
HairParticleCB hcb;
|
||||
hcb.xWorld = world;
|
||||
@@ -184,7 +188,7 @@ void wiHairParticle::UpdateGPU(const MeshComponent& mesh, const MaterialComponen
|
||||
hcb.xHairFrameCount = std::max(1u, frameCount);
|
||||
hcb.xHairFrameStart = frameStart;
|
||||
hcb.xHairTexMul = float2(1.0f / (float)hcb.xHairFramesXY.x, 1.0f / (float)hcb.xHairFramesXY.y);
|
||||
hcb.xHairAspect = (float)desc.Width / (float)desc.Height;
|
||||
hcb.xHairAspect = (float)std::max(1u, desc.Width) / (float)std::max(1u, desc.Height);
|
||||
device->UpdateBuffer(&cb, &hcb, cmd);
|
||||
|
||||
// Simulate:
|
||||
@@ -265,11 +269,16 @@ void wiHairParticle::Draw(const CameraComponent& camera, const MaterialComponent
|
||||
{
|
||||
device->BindPipelineState(&PSO[renderPass], cmd);
|
||||
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap()
|
||||
};
|
||||
device->BindResources(PS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);
|
||||
device->BindResources(VS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);
|
||||
if (material.textures[MaterialComponent::BASECOLORMAP].resource == nullptr)
|
||||
{
|
||||
device->BindResource(PS, wiTextureHelper::getWhite(), TEXSLOT_ONDEMAND0, cmd);
|
||||
device->BindResource(VS, wiTextureHelper::getWhite(), TEXSLOT_ONDEMAND0, cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
device->BindResource(PS, material.textures[MaterialComponent::BASECOLORMAP].GetGPUResource(), TEXSLOT_ONDEMAND0, cmd);
|
||||
device->BindResource(VS, material.textures[MaterialComponent::BASECOLORMAP].GetGPUResource(), TEXSLOT_ONDEMAND0, cmd);
|
||||
}
|
||||
|
||||
if (renderPass != RENDERPASS_PREPASS) // depth only alpha test will be full res
|
||||
{
|
||||
|
||||
+27
-65
@@ -2903,30 +2903,13 @@ void RenderMeshes(
|
||||
device->BindConstantBuffer(PS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB), cmd);
|
||||
|
||||
// Bind all material textures:
|
||||
{
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap(),
|
||||
material.GetNormalMap(),
|
||||
material.GetSurfaceMap(),
|
||||
material.GetEmissiveMap(),
|
||||
material.GetDisplacementMap(),
|
||||
material.GetOcclusionMap(),
|
||||
material.GetTransmissionMap(),
|
||||
material.GetSheenColorMap(),
|
||||
material.GetSheenRoughnessMap(),
|
||||
material.GetClearcoatMap(),
|
||||
material.GetClearcoatRoughnessMap(),
|
||||
material.GetClearcoatNormalMap(),
|
||||
};
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BASECOLORMAP, arraysize(res), cmd);
|
||||
}
|
||||
const GPUResource* materialtextures[MaterialComponent::TEXTURESLOT_COUNT];
|
||||
material.WriteTextures(materialtextures, arraysize(materialtextures));
|
||||
device->BindResources(PS, materialtextures, TEXSLOT_RENDERER_BASECOLORMAP, arraysize(materialtextures), cmd);
|
||||
|
||||
if (tessellatorRequested)
|
||||
{
|
||||
const GPUResource* res[] = {
|
||||
material.GetDisplacementMap(),
|
||||
};
|
||||
device->BindResources(DS, res, TEXSLOT_RENDERER_DISPLACEMENTMAP, arraysize(res), cmd);
|
||||
device->BindResources(DS, materialtextures, TEXSLOT_RENDERER_BASECOLORMAP, arraysize(materialtextures), cmd);
|
||||
device->BindConstantBuffer(DS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB), cmd);
|
||||
}
|
||||
|
||||
@@ -2934,72 +2917,42 @@ void RenderMeshes(
|
||||
{
|
||||
if (mesh.terrain_material1 == INVALID_ENTITY || !vis.scene->materials.Contains(mesh.terrain_material1))
|
||||
{
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap(),
|
||||
material.GetNormalMap(),
|
||||
material.GetSurfaceMap(),
|
||||
material.GetEmissiveMap(),
|
||||
};
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND1_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindResources(PS, materialtextures, TEXSLOT_RENDERER_BLEND1_BASECOLORMAP, 4, cmd);
|
||||
device->BindConstantBuffer(PS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend1), cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const MaterialComponent& blendmat = *vis.scene->materials.GetComponent(mesh.terrain_material1);
|
||||
const GPUResource* res[] = {
|
||||
blendmat.GetBaseColorMap(),
|
||||
blendmat.GetNormalMap(),
|
||||
blendmat.GetSurfaceMap(),
|
||||
blendmat.GetEmissiveMap(),
|
||||
};
|
||||
const GPUResource* res[4];
|
||||
blendmat.WriteTextures(res, arraysize(res));
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND1_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindConstantBuffer(PS, &blendmat.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend1), cmd);
|
||||
}
|
||||
|
||||
if (mesh.terrain_material2 == INVALID_ENTITY || !vis.scene->materials.Contains(mesh.terrain_material2))
|
||||
{
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap(),
|
||||
material.GetNormalMap(),
|
||||
material.GetSurfaceMap(),
|
||||
material.GetEmissiveMap(),
|
||||
};
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND2_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindResources(PS, materialtextures, TEXSLOT_RENDERER_BLEND2_BASECOLORMAP, 4, cmd);
|
||||
device->BindConstantBuffer(PS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend2), cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const MaterialComponent& blendmat = *vis.scene->materials.GetComponent(mesh.terrain_material2);
|
||||
const GPUResource* res[] = {
|
||||
blendmat.GetBaseColorMap(),
|
||||
blendmat.GetNormalMap(),
|
||||
blendmat.GetSurfaceMap(),
|
||||
blendmat.GetEmissiveMap(),
|
||||
};
|
||||
const GPUResource* res[4];
|
||||
blendmat.WriteTextures(res, arraysize(res));
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND2_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindConstantBuffer(PS, &blendmat.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend2), cmd);
|
||||
}
|
||||
|
||||
if (mesh.terrain_material3 == INVALID_ENTITY || !vis.scene->materials.Contains(mesh.terrain_material3))
|
||||
{
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap(),
|
||||
material.GetNormalMap(),
|
||||
material.GetSurfaceMap(),
|
||||
material.GetEmissiveMap(),
|
||||
};
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND3_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindResources(PS, materialtextures, TEXSLOT_RENDERER_BLEND3_BASECOLORMAP, 4, cmd);
|
||||
device->BindConstantBuffer(PS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend3), cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const MaterialComponent& blendmat = *vis.scene->materials.GetComponent(mesh.terrain_material3);
|
||||
const GPUResource* res[] = {
|
||||
blendmat.GetBaseColorMap(),
|
||||
blendmat.GetNormalMap(),
|
||||
blendmat.GetSurfaceMap(),
|
||||
blendmat.GetEmissiveMap(),
|
||||
};
|
||||
const GPUResource* res[4];
|
||||
blendmat.WriteTextures(res, arraysize(res));
|
||||
device->BindResources(PS, res, TEXSLOT_RENDERER_BLEND3_BASECOLORMAP, arraysize(res), cmd);
|
||||
device->BindConstantBuffer(PS, &blendmat.constantBuffer, CB_GETBINDSLOT(MaterialCB_Blend3), cmd);
|
||||
}
|
||||
@@ -6192,17 +6145,29 @@ void DrawDebugWorld(
|
||||
|
||||
const GPUBuffer* vbs[] = {
|
||||
mesh.streamoutBuffer_POS.IsValid() ? &mesh.streamoutBuffer_POS : &mesh.vertexBuffer_POS,
|
||||
nullptr,
|
||||
&mesh.vertexBuffer_UV0,
|
||||
&mesh.vertexBuffer_UV1,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
mem.buffer
|
||||
};
|
||||
uint32_t strides[] = {
|
||||
sizeof(MeshComponent::Vertex_POS),
|
||||
sizeof(MeshComponent::Vertex_POS),
|
||||
sizeof(MeshComponent::Vertex_TEX),
|
||||
sizeof(MeshComponent::Vertex_TEX),
|
||||
sizeof(MeshComponent::Vertex_TEX),
|
||||
sizeof(MeshComponent::Vertex_COL),
|
||||
sizeof(MeshComponent::Vertex_TAN),
|
||||
sizeof(Instance)
|
||||
};
|
||||
uint32_t offsets[] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
@@ -6993,11 +6958,8 @@ void RefreshImpostors(const Scene& scene, CommandList cmd)
|
||||
device->BindConstantBuffer(VS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB), cmd);
|
||||
device->BindConstantBuffer(PS, &material.constantBuffer, CB_GETBINDSLOT(MaterialCB), cmd);
|
||||
|
||||
const GPUResource* res[] = {
|
||||
material.GetBaseColorMap(),
|
||||
material.GetNormalMap(),
|
||||
material.GetSurfaceMap(),
|
||||
};
|
||||
const GPUResource* res[4];
|
||||
material.WriteTextures(res, arraysize(res));
|
||||
device->BindResources(PS, res, TEXSLOT_ONDEMAND0, arraysize(res), cmd);
|
||||
|
||||
device->DrawIndexedInstanced(subset.indexCount, 1, subset.indexOffset, 0, 0, cmd);
|
||||
|
||||
+36
-174
@@ -224,102 +224,6 @@ namespace wiScene
|
||||
XMStoreFloat3(&scale_local, S);
|
||||
}
|
||||
|
||||
const Texture* MaterialComponent::GetBaseColorMap() const
|
||||
{
|
||||
if (baseColorMap != nullptr)
|
||||
{
|
||||
return baseColorMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetNormalMap() const
|
||||
{
|
||||
if (normalMap != nullptr)
|
||||
{
|
||||
return normalMap->texture;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
const Texture* MaterialComponent::GetSurfaceMap() const
|
||||
{
|
||||
if (surfaceMap != nullptr)
|
||||
{
|
||||
return surfaceMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetDisplacementMap() const
|
||||
{
|
||||
if (displacementMap != nullptr)
|
||||
{
|
||||
return displacementMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetEmissiveMap() const
|
||||
{
|
||||
if (emissiveMap != nullptr)
|
||||
{
|
||||
return emissiveMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetOcclusionMap() const
|
||||
{
|
||||
if (occlusionMap != nullptr)
|
||||
{
|
||||
return occlusionMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetTransmissionMap() const
|
||||
{
|
||||
if (transmissionMap != nullptr)
|
||||
{
|
||||
return transmissionMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetSheenColorMap() const
|
||||
{
|
||||
if (sheenColorMap != nullptr)
|
||||
{
|
||||
return sheenColorMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetSheenRoughnessMap() const
|
||||
{
|
||||
if (sheenRoughnessMap != nullptr)
|
||||
{
|
||||
return sheenRoughnessMap->texture;
|
||||
}
|
||||
return wiTextureHelper::getWhite();
|
||||
}
|
||||
const Texture* MaterialComponent::GetClearcoatMap() const
|
||||
{
|
||||
if (clearcoatMap != nullptr)
|
||||
{
|
||||
return clearcoatMap->texture;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
const Texture* MaterialComponent::GetClearcoatRoughnessMap() const
|
||||
{
|
||||
if (clearcoatRoughnessMap != nullptr)
|
||||
{
|
||||
return clearcoatRoughnessMap->texture;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
const Texture* MaterialComponent::GetClearcoatNormalMap() const
|
||||
{
|
||||
if (clearcoatNormalMap != nullptr)
|
||||
{
|
||||
return clearcoatNormalMap->texture;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void MaterialComponent::WriteShaderMaterial(ShaderMaterial* dest) const
|
||||
{
|
||||
dest->baseColor = baseColor;
|
||||
@@ -330,7 +234,7 @@ namespace wiScene
|
||||
dest->reflectance = reflectance;
|
||||
dest->metalness = metalness;
|
||||
dest->refraction = refraction;
|
||||
dest->normalMapStrength = (normalMap == nullptr ? 0 : normalMapStrength);
|
||||
dest->normalMapStrength = (textures[NORMALMAP].resource == nullptr ? 0 : normalMapStrength);
|
||||
dest->parallaxOcclusionMapping = parallaxOcclusionMapping;
|
||||
dest->displacementMapping = displacementMapping;
|
||||
dest->subsurfaceScattering = subsurfaceScattering;
|
||||
@@ -341,18 +245,18 @@ namespace wiScene
|
||||
dest->subsurfaceScattering_inv.y = 1.0f / ((1 + dest->subsurfaceScattering.y) * (1 + dest->subsurfaceScattering.y));
|
||||
dest->subsurfaceScattering_inv.z = 1.0f / ((1 + dest->subsurfaceScattering.z) * (1 + dest->subsurfaceScattering.z));
|
||||
dest->subsurfaceScattering_inv.w = 1.0f / ((1 + dest->subsurfaceScattering.w) * (1 + dest->subsurfaceScattering.w));
|
||||
dest->uvset_baseColorMap = baseColorMap == nullptr ? -1 : (int)uvset_baseColorMap;
|
||||
dest->uvset_surfaceMap = surfaceMap == nullptr ? -1 : (int)uvset_surfaceMap;
|
||||
dest->uvset_normalMap = normalMap == nullptr ? -1 : (int)uvset_normalMap;
|
||||
dest->uvset_displacementMap = displacementMap == nullptr ? -1 : (int)uvset_displacementMap;
|
||||
dest->uvset_emissiveMap = emissiveMap == nullptr ? -1 : (int)uvset_emissiveMap;
|
||||
dest->uvset_occlusionMap = occlusionMap == nullptr ? -1 : (int)uvset_occlusionMap;
|
||||
dest->uvset_transmissionMap = transmissionMap == nullptr ? -1 : (int)uvset_transmissionMap;
|
||||
dest->uvset_sheenColorMap = sheenColorMap == nullptr ? -1 : (int)uvset_sheenColorMap;
|
||||
dest->uvset_sheenRoughnessMap = sheenRoughnessMap == nullptr ? -1 : (int)uvset_sheenRoughnessMap;
|
||||
dest->uvset_clearcoatMap = clearcoatMap == nullptr ? -1 : (int)uvset_clearcoatMap;
|
||||
dest->uvset_clearcoatRoughnessMap = clearcoatRoughnessMap == nullptr ? -1 : (int)uvset_clearcoatRoughnessMap;
|
||||
dest->uvset_clearcoatNormalMap = clearcoatNormalMap == nullptr ? -1 : (int)uvset_clearcoatNormalMap;
|
||||
dest->uvset_baseColorMap = textures[BASECOLORMAP].GetUVSet();
|
||||
dest->uvset_surfaceMap = textures[SURFACEMAP].GetUVSet();
|
||||
dest->uvset_normalMap = textures[NORMALMAP].GetUVSet();
|
||||
dest->uvset_displacementMap = textures[DISPLACEMENTMAP].GetUVSet();
|
||||
dest->uvset_emissiveMap = textures[EMISSIVEMAP].GetUVSet();
|
||||
dest->uvset_occlusionMap = textures[OCCLUSIONMAP].GetUVSet();
|
||||
dest->uvset_transmissionMap = textures[TRANSMISSIONMAP].GetUVSet();
|
||||
dest->uvset_sheenColorMap = textures[SHEENCOLORMAP].GetUVSet();
|
||||
dest->uvset_sheenRoughnessMap = textures[SHEENROUGHNESSMAP].GetUVSet();
|
||||
dest->uvset_clearcoatMap = textures[CLEARCOATMAP].GetUVSet();
|
||||
dest->uvset_clearcoatRoughnessMap = textures[CLEARCOATROUGHNESSMAP].GetUVSet();
|
||||
dest->uvset_clearcoatNormalMap = textures[CLEARCOATNORMALMAP].GetUVSet();
|
||||
dest->sheenColor = sheenColor;
|
||||
dest->sheenRoughness = sheenRoughness;
|
||||
dest->clearcoat = clearcoat;
|
||||
@@ -387,6 +291,14 @@ namespace wiScene
|
||||
dest->emissiveMapAtlasMulAdd = XMFLOAT4(0, 0, 0, 0);
|
||||
dest->normalMapAtlasMulAdd = XMFLOAT4(0, 0, 0, 0);
|
||||
}
|
||||
void MaterialComponent::WriteTextures(const wiGraphics::GPUResource** dest, int count) const
|
||||
{
|
||||
count = std::min(count, (int)TEXTURESLOT_COUNT);
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
dest[i] = textures[i].GetGPUResource();
|
||||
}
|
||||
}
|
||||
uint32_t MaterialComponent::GetRenderTypes() const
|
||||
{
|
||||
if (IsCustomShader() && customShaderID < (int)wiRenderer::GetCustomShaders().size())
|
||||
@@ -410,55 +322,13 @@ namespace wiScene
|
||||
}
|
||||
void MaterialComponent::CreateRenderData(const std::string& content_dir)
|
||||
{
|
||||
if (!baseColorMapName.empty())
|
||||
for (auto& x : textures)
|
||||
{
|
||||
baseColorMap = wiResourceManager::Load(content_dir + baseColorMapName);
|
||||
if (!x.name.empty())
|
||||
{
|
||||
x.resource = wiResourceManager::Load(content_dir + x.name);
|
||||
}
|
||||
}
|
||||
if (!surfaceMapName.empty())
|
||||
{
|
||||
surfaceMap = wiResourceManager::Load(content_dir + surfaceMapName);
|
||||
}
|
||||
if (!normalMapName.empty())
|
||||
{
|
||||
normalMap = wiResourceManager::Load(content_dir + normalMapName);
|
||||
}
|
||||
if (!displacementMapName.empty())
|
||||
{
|
||||
displacementMap = wiResourceManager::Load(content_dir + displacementMapName);
|
||||
}
|
||||
if (!emissiveMapName.empty())
|
||||
{
|
||||
emissiveMap = wiResourceManager::Load(content_dir + emissiveMapName);
|
||||
}
|
||||
if (!occlusionMapName.empty())
|
||||
{
|
||||
occlusionMap = wiResourceManager::Load(content_dir + occlusionMapName);
|
||||
}
|
||||
if (!transmissionMapName.empty())
|
||||
{
|
||||
transmissionMap = wiResourceManager::Load(content_dir + transmissionMapName);
|
||||
}
|
||||
if (!sheenColorMapName.empty())
|
||||
{
|
||||
sheenColorMap = wiResourceManager::Load(content_dir + sheenColorMapName);
|
||||
}
|
||||
if (!sheenRoughnessMapName.empty())
|
||||
{
|
||||
sheenRoughnessMap = wiResourceManager::Load(content_dir + sheenRoughnessMapName);
|
||||
}
|
||||
if (!clearcoatMapName.empty())
|
||||
{
|
||||
clearcoatMap = wiResourceManager::Load(content_dir + clearcoatMapName);
|
||||
}
|
||||
if (!clearcoatRoughnessMapName.empty())
|
||||
{
|
||||
clearcoatRoughnessMap = wiResourceManager::Load(content_dir + clearcoatRoughnessMapName);
|
||||
}
|
||||
if (!clearcoatNormalMapName.empty())
|
||||
{
|
||||
clearcoatNormalMap = wiResourceManager::Load(content_dir + clearcoatNormalMapName);
|
||||
}
|
||||
|
||||
|
||||
ShaderMaterial shadermat;
|
||||
WriteShaderMaterial(&shadermat);
|
||||
@@ -1820,17 +1690,9 @@ namespace wiScene
|
||||
decals.Create(entity);
|
||||
|
||||
MaterialComponent& material = materials.Create(entity);
|
||||
|
||||
if (!textureName.empty())
|
||||
{
|
||||
material.baseColorMapName = textureName;
|
||||
material.baseColorMap = wiResourceManager::Load(material.baseColorMapName);
|
||||
}
|
||||
if (!normalMapName.empty())
|
||||
{
|
||||
material.normalMapName = normalMapName;
|
||||
material.normalMap = wiResourceManager::Load(material.normalMapName);
|
||||
}
|
||||
material.textures[MaterialComponent::BASECOLORMAP].name = textureName;
|
||||
material.textures[MaterialComponent::NORMALMAP].name = normalMapName;
|
||||
material.CreateRenderData();
|
||||
|
||||
return entity;
|
||||
}
|
||||
@@ -2632,31 +2494,31 @@ namespace wiScene
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_TEXTURES],
|
||||
0,
|
||||
global_geometryIndex * MATERIAL_TEXTURE_SLOT_DESCRIPTOR_COUNT + MATERIAL_TEXTURE_SLOT_DESCRIPTOR_BASECOLOR,
|
||||
material->baseColorMap ? material->baseColorMap->texture : nullptr
|
||||
material->textures[MaterialComponent::BASECOLORMAP].GetGPUResource()
|
||||
);
|
||||
device->WriteDescriptor(
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_TEXTURES],
|
||||
0,
|
||||
global_geometryIndex * MATERIAL_TEXTURE_SLOT_DESCRIPTOR_COUNT + MATERIAL_TEXTURE_SLOT_DESCRIPTOR_NORMAL,
|
||||
material->normalMap ? material->normalMap->texture : nullptr
|
||||
material->textures[MaterialComponent::NORMALMAP].GetGPUResource()
|
||||
);
|
||||
device->WriteDescriptor(
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_TEXTURES],
|
||||
0,
|
||||
global_geometryIndex * MATERIAL_TEXTURE_SLOT_DESCRIPTOR_COUNT + MATERIAL_TEXTURE_SLOT_DESCRIPTOR_SURFACE,
|
||||
material->surfaceMap ? material->surfaceMap->texture : nullptr
|
||||
material->textures[MaterialComponent::SURFACEMAP].GetGPUResource()
|
||||
);
|
||||
device->WriteDescriptor(
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_TEXTURES],
|
||||
0,
|
||||
global_geometryIndex * MATERIAL_TEXTURE_SLOT_DESCRIPTOR_COUNT + MATERIAL_TEXTURE_SLOT_DESCRIPTOR_OCCLUSION,
|
||||
material->occlusionMap ? material->occlusionMap->texture : nullptr
|
||||
material->textures[MaterialComponent::OCCLUSIONMAP].GetGPUResource()
|
||||
);
|
||||
device->WriteDescriptor(
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_TEXTURES],
|
||||
0,
|
||||
global_geometryIndex * MATERIAL_TEXTURE_SLOT_DESCRIPTOR_COUNT + MATERIAL_TEXTURE_SLOT_DESCRIPTOR_EMISSIVE,
|
||||
material->emissiveMap ? material->emissiveMap->texture : nullptr
|
||||
material->textures[MaterialComponent::EMISSIVEMAP].GetGPUResource()
|
||||
);
|
||||
device->WriteDescriptor(
|
||||
&descriptorTables[DESCRIPTORTABLE_SUBSETS_INDEXBUFFER],
|
||||
@@ -2994,8 +2856,8 @@ namespace wiScene
|
||||
const MaterialComponent& material = *materials.GetComponent(entity);
|
||||
decal.color = material.baseColor;
|
||||
decal.emissive = material.GetEmissiveStrength();
|
||||
decal.texture = material.baseColorMap;
|
||||
decal.normal = material.normalMap;
|
||||
decal.texture = material.textures[MaterialComponent::BASECOLORMAP].resource;
|
||||
decal.normal = material.textures[MaterialComponent::NORMALMAP].resource;
|
||||
});
|
||||
}
|
||||
void Scene::RunProbeUpdateSystem(wiJobSystem::context& ctx)
|
||||
|
||||
+38
-61
@@ -177,47 +177,46 @@ namespace wiScene
|
||||
float texAnimFrameRate = 0.0f;
|
||||
float texAnimElapsedTime = 0.0f;
|
||||
|
||||
std::string baseColorMapName;
|
||||
std::string surfaceMapName;
|
||||
std::string normalMapName;
|
||||
std::string displacementMapName;
|
||||
std::string emissiveMapName;
|
||||
std::string occlusionMapName;
|
||||
std::string transmissionMapName;
|
||||
std::string sheenColorMapName;
|
||||
std::string sheenRoughnessMapName;
|
||||
std::string clearcoatMapName;
|
||||
std::string clearcoatRoughnessMapName;
|
||||
std::string clearcoatNormalMapName;
|
||||
enum TEXTURESLOT
|
||||
{
|
||||
BASECOLORMAP,
|
||||
NORMALMAP,
|
||||
SURFACEMAP,
|
||||
EMISSIVEMAP,
|
||||
DISPLACEMENTMAP,
|
||||
OCCLUSIONMAP,
|
||||
TRANSMISSIONMAP,
|
||||
SHEENCOLORMAP,
|
||||
SHEENROUGHNESSMAP,
|
||||
CLEARCOATMAP,
|
||||
CLEARCOATROUGHNESSMAP,
|
||||
CLEARCOATNORMALMAP,
|
||||
|
||||
uint32_t uvset_baseColorMap = 0;
|
||||
uint32_t uvset_surfaceMap = 0;
|
||||
uint32_t uvset_normalMap = 0;
|
||||
uint32_t uvset_displacementMap = 0;
|
||||
uint32_t uvset_emissiveMap = 0;
|
||||
uint32_t uvset_occlusionMap = 0;
|
||||
uint32_t uvset_transmissionMap = 0;
|
||||
uint32_t uvset_sheenColorMap = 0;
|
||||
uint32_t uvset_sheenRoughnessMap = 0;
|
||||
uint32_t uvset_clearcoatMap = 0;
|
||||
uint32_t uvset_clearcoatRoughnessMap = 0;
|
||||
uint32_t uvset_clearcoatNormalMap = 0;
|
||||
TEXTURESLOT_COUNT
|
||||
};
|
||||
struct TextureMap
|
||||
{
|
||||
std::string name;
|
||||
uint32_t uvset = 0;
|
||||
std::shared_ptr<wiResource> resource;
|
||||
const wiGraphics::GPUResource* GetGPUResource() const
|
||||
{
|
||||
if (resource == nullptr)
|
||||
return nullptr;
|
||||
return resource->texture;
|
||||
}
|
||||
int GetUVSet() const
|
||||
{
|
||||
if (resource == nullptr)
|
||||
return -1;
|
||||
return (int)uvset;
|
||||
}
|
||||
};
|
||||
TextureMap textures[TEXTURESLOT_COUNT];
|
||||
|
||||
int customShaderID = -1;
|
||||
|
||||
// Non-serialized attributes:
|
||||
std::shared_ptr<wiResource> baseColorMap;
|
||||
std::shared_ptr<wiResource> surfaceMap;
|
||||
std::shared_ptr<wiResource> normalMap;
|
||||
std::shared_ptr<wiResource> displacementMap;
|
||||
std::shared_ptr<wiResource> emissiveMap;
|
||||
std::shared_ptr<wiResource> occlusionMap;
|
||||
std::shared_ptr<wiResource> transmissionMap;
|
||||
std::shared_ptr<wiResource> sheenColorMap;
|
||||
std::shared_ptr<wiResource> sheenRoughnessMap;
|
||||
std::shared_ptr<wiResource> clearcoatMap;
|
||||
std::shared_ptr<wiResource> clearcoatRoughnessMap;
|
||||
std::shared_ptr<wiResource> clearcoatNormalMap;
|
||||
wiGraphics::GPUBuffer constantBuffer;
|
||||
uint32_t layerMask = ~0u;
|
||||
|
||||
@@ -229,19 +228,6 @@ namespace wiScene
|
||||
}
|
||||
uint32_t GetStencilRef() const;
|
||||
|
||||
const wiGraphics::Texture* GetBaseColorMap() const;
|
||||
const wiGraphics::Texture* GetNormalMap() const;
|
||||
const wiGraphics::Texture* GetSurfaceMap() const;
|
||||
const wiGraphics::Texture* GetDisplacementMap() const;
|
||||
const wiGraphics::Texture* GetEmissiveMap() const;
|
||||
const wiGraphics::Texture* GetOcclusionMap() const;
|
||||
const wiGraphics::Texture* GetTransmissionMap() const;
|
||||
const wiGraphics::Texture* GetSheenColorMap() const;
|
||||
const wiGraphics::Texture* GetSheenRoughnessMap() const;
|
||||
const wiGraphics::Texture* GetClearcoatMap() const;
|
||||
const wiGraphics::Texture* GetClearcoatRoughnessMap() const;
|
||||
const wiGraphics::Texture* GetClearcoatNormalMap() const;
|
||||
|
||||
inline float GetOpacity() const { return baseColor.w; }
|
||||
inline float GetEmissiveStrength() const { return emissiveColor.w; }
|
||||
inline int GetCustomShaderID() const { return customShaderID; }
|
||||
@@ -300,22 +286,13 @@ namespace wiScene
|
||||
inline void SetClearcoatRoughness(float value) { clearcoatRoughness = value; SetDirty(); }
|
||||
inline void SetCustomShaderID(int id) { customShaderID = id; }
|
||||
inline void DisableCustomShader() { customShaderID = -1; }
|
||||
inline void SetUVSet_BaseColorMap(uint32_t value) { uvset_baseColorMap = value; SetDirty(); }
|
||||
inline void SetUVSet_NormalMap(uint32_t value) { uvset_normalMap = value; SetDirty(); }
|
||||
inline void SetUVSet_SurfaceMap(uint32_t value) { uvset_surfaceMap = value; SetDirty(); }
|
||||
inline void SetUVSet_DisplacementMap(uint32_t value) { uvset_displacementMap = value; SetDirty(); }
|
||||
inline void SetUVSet_EmissiveMap(uint32_t value) { uvset_emissiveMap = value; SetDirty(); }
|
||||
inline void SetUVSet_OcclusionMap(uint32_t value) { uvset_occlusionMap = value; SetDirty(); }
|
||||
inline void SetUVSet_TransmissionMap(uint32_t value) { uvset_transmissionMap = value; SetDirty(); }
|
||||
inline void SetUVSet_SheenColorMap(uint32_t value) { uvset_sheenColorMap = value; SetDirty(); }
|
||||
inline void SetUVSet_SheenRoughnessMap(uint32_t value) { uvset_sheenRoughnessMap = value; SetDirty(); }
|
||||
inline void SetUVSet_ClearcoatMap(uint32_t value) { uvset_clearcoatMap = value; SetDirty(); }
|
||||
inline void SetUVSet_ClearcoatRoughnessMap(uint32_t value) { uvset_clearcoatRoughnessMap = value; SetDirty(); }
|
||||
inline void SetUVSet_ClearcoatNormalMap(uint32_t value) { uvset_clearcoatNormalMap = value; SetDirty(); }
|
||||
|
||||
// The MaterialComponent will be written to ShaderMaterial (a struct that is optimized for GPU use)
|
||||
void WriteShaderMaterial(ShaderMaterial* dest) const;
|
||||
|
||||
// Retrieve the array of textures from the material
|
||||
void WriteTextures(const wiGraphics::GPUResource** dest, int count) const;
|
||||
|
||||
// Returns the bitwise OR of all the RENDERTYPE flags applicable to this material
|
||||
uint32_t GetRenderTypes() const;
|
||||
|
||||
|
||||
@@ -113,26 +113,26 @@ namespace wiScene
|
||||
archive >> texAnimFrameRate;
|
||||
archive >> texAnimElapsedTime;
|
||||
|
||||
archive >> baseColorMapName;
|
||||
archive >> surfaceMapName;
|
||||
archive >> normalMapName;
|
||||
archive >> displacementMapName;
|
||||
archive >> textures[BASECOLORMAP].name;
|
||||
archive >> textures[SURFACEMAP].name;
|
||||
archive >> textures[NORMALMAP].name;
|
||||
archive >> textures[DISPLACEMENTMAP].name;
|
||||
|
||||
if (archive.GetVersion() >= 24)
|
||||
{
|
||||
archive >> emissiveMapName;
|
||||
archive >> textures[EMISSIVEMAP].name;
|
||||
}
|
||||
|
||||
if (archive.GetVersion() >= 28)
|
||||
{
|
||||
archive >> occlusionMapName;
|
||||
archive >> textures[OCCLUSIONMAP].name;
|
||||
|
||||
archive >> uvset_baseColorMap;
|
||||
archive >> uvset_surfaceMap;
|
||||
archive >> uvset_normalMap;
|
||||
archive >> uvset_displacementMap;
|
||||
archive >> uvset_emissiveMap;
|
||||
archive >> uvset_occlusionMap;
|
||||
archive >> textures[BASECOLORMAP].uvset;
|
||||
archive >> textures[SURFACEMAP].uvset;
|
||||
archive >> textures[NORMALMAP].uvset;
|
||||
archive >> textures[DISPLACEMENTMAP].uvset;
|
||||
archive >> textures[EMISSIVEMAP].uvset;
|
||||
archive >> textures[OCCLUSIONMAP].uvset;
|
||||
|
||||
archive >> displacementMapping;
|
||||
}
|
||||
@@ -182,27 +182,27 @@ namespace wiScene
|
||||
if (archive.GetVersion() >= 59)
|
||||
{
|
||||
archive >> transmission;
|
||||
archive >> transmissionMapName;
|
||||
archive >> uvset_transmissionMap;
|
||||
archive >> textures[TRANSMISSIONMAP].name;
|
||||
archive >> textures[TRANSMISSIONMAP].uvset;
|
||||
}
|
||||
|
||||
if (archive.GetVersion() >= 61)
|
||||
{
|
||||
archive >> sheenColor;
|
||||
archive >> sheenRoughness;
|
||||
archive >> sheenColorMapName;
|
||||
archive >> sheenRoughnessMapName;
|
||||
archive >> uvset_sheenColorMap;
|
||||
archive >> uvset_sheenRoughnessMap;
|
||||
archive >> textures[SHEENCOLORMAP].name;
|
||||
archive >> textures[SHEENROUGHNESSMAP].name;
|
||||
archive >> textures[SHEENCOLORMAP].uvset;
|
||||
archive >> textures[SHEENROUGHNESSMAP].uvset;
|
||||
|
||||
archive >> clearcoat;
|
||||
archive >> clearcoatRoughness;
|
||||
archive >> clearcoatMapName;
|
||||
archive >> clearcoatRoughnessMapName;
|
||||
archive >> clearcoatNormalMapName;
|
||||
archive >> uvset_clearcoatMap;
|
||||
archive >> uvset_clearcoatRoughnessMap;
|
||||
archive >> uvset_clearcoatNormalMap;
|
||||
archive >> textures[CLEARCOATMAP].name;
|
||||
archive >> textures[CLEARCOATROUGHNESSMAP].name;
|
||||
archive >> textures[CLEARCOATNORMALMAP].name;
|
||||
archive >> textures[CLEARCOATMAP].uvset;
|
||||
archive >> textures[CLEARCOATROUGHNESSMAP].uvset;
|
||||
archive >> textures[CLEARCOATNORMALMAP].uvset;
|
||||
}
|
||||
|
||||
wiJobSystem::Execute(seri.ctx, [&](wiJobArgs args) {
|
||||
@@ -244,99 +244,36 @@ namespace wiScene
|
||||
// If detecting an absolute path in textures, remove it and convert to relative:
|
||||
if(!dir.empty())
|
||||
{
|
||||
size_t found = baseColorMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
for (auto& x : textures)
|
||||
{
|
||||
baseColorMapName = baseColorMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = surfaceMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
surfaceMapName = surfaceMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = normalMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
normalMapName = normalMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = displacementMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
displacementMapName = displacementMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = emissiveMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
emissiveMapName = emissiveMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = occlusionMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
occlusionMapName = occlusionMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = transmissionMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
transmissionMapName = transmissionMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = sheenColorMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
sheenColorMapName = sheenColorMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = sheenRoughnessMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
sheenRoughnessMapName = sheenRoughnessMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = clearcoatMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
clearcoatMapName = clearcoatMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = clearcoatRoughnessMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
clearcoatRoughnessMapName = clearcoatRoughnessMapName.substr(found + dir.length());
|
||||
}
|
||||
|
||||
found = clearcoatNormalMapName.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
clearcoatNormalMapName = clearcoatNormalMapName.substr(found + dir.length());
|
||||
size_t found = x.name.rfind(dir);
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
x.name = x.name.substr(found + dir.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archive << baseColorMapName;
|
||||
archive << surfaceMapName;
|
||||
archive << normalMapName;
|
||||
archive << displacementMapName;
|
||||
archive << textures[BASECOLORMAP].name;
|
||||
archive << textures[SURFACEMAP].name;
|
||||
archive << textures[NORMALMAP].name;
|
||||
archive << textures[DISPLACEMENTMAP].name;
|
||||
|
||||
if (archive.GetVersion() >= 24)
|
||||
{
|
||||
archive << emissiveMapName;
|
||||
archive << textures[EMISSIVEMAP].name;
|
||||
}
|
||||
|
||||
if (archive.GetVersion() >= 28)
|
||||
{
|
||||
archive << occlusionMapName;
|
||||
archive << textures[OCCLUSIONMAP].name;
|
||||
|
||||
archive << uvset_baseColorMap;
|
||||
archive << uvset_surfaceMap;
|
||||
archive << uvset_normalMap;
|
||||
archive << uvset_displacementMap;
|
||||
archive << uvset_emissiveMap;
|
||||
archive << uvset_occlusionMap;
|
||||
archive << textures[BASECOLORMAP].uvset;
|
||||
archive << textures[SURFACEMAP].uvset;
|
||||
archive << textures[NORMALMAP].uvset;
|
||||
archive << textures[DISPLACEMENTMAP].uvset;
|
||||
archive << textures[EMISSIVEMAP].uvset;
|
||||
archive << textures[OCCLUSIONMAP].uvset;
|
||||
|
||||
archive << displacementMapping;
|
||||
}
|
||||
@@ -365,27 +302,27 @@ namespace wiScene
|
||||
if (archive.GetVersion() >= 59)
|
||||
{
|
||||
archive << transmission;
|
||||
archive << transmissionMapName;
|
||||
archive << uvset_transmissionMap;
|
||||
archive << textures[TRANSMISSIONMAP].name;
|
||||
archive << textures[TRANSMISSIONMAP].uvset;
|
||||
}
|
||||
|
||||
if (archive.GetVersion() >= 61)
|
||||
{
|
||||
archive << sheenColor;
|
||||
archive << sheenRoughness;
|
||||
archive << sheenColorMapName;
|
||||
archive << sheenRoughnessMapName;
|
||||
archive << uvset_sheenColorMap;
|
||||
archive << uvset_sheenRoughnessMap;
|
||||
archive << textures[SHEENCOLORMAP].name;
|
||||
archive << textures[SHEENROUGHNESSMAP].name;
|
||||
archive << textures[SHEENCOLORMAP].uvset;
|
||||
archive << textures[SHEENROUGHNESSMAP].uvset;
|
||||
|
||||
archive << clearcoat;
|
||||
archive << clearcoatRoughness;
|
||||
archive << clearcoatMapName;
|
||||
archive << clearcoatRoughnessMapName;
|
||||
archive << clearcoatNormalMapName;
|
||||
archive << uvset_clearcoatMap;
|
||||
archive << uvset_clearcoatRoughnessMap;
|
||||
archive << uvset_clearcoatNormalMap;
|
||||
archive << textures[CLEARCOATMAP].name;
|
||||
archive << textures[CLEARCOATROUGHNESSMAP].name;
|
||||
archive << textures[CLEARCOATNORMALMAP].name;
|
||||
archive << textures[CLEARCOATMAP].uvset;
|
||||
archive << textures[CLEARCOATROUGHNESSMAP].uvset;
|
||||
archive << textures[CLEARCOATNORMALMAP].uvset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 52;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 19;
|
||||
const int revision = 20;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user