added feature: multiple uv sets; gltf updates; editor updates;

This commit is contained in:
turanszkij
2019-03-16 18:19:49 +00:00
parent 4163f09a76
commit 45e344cbfa
58 changed files with 5670 additions and 4203 deletions
+208 -10
View File
@@ -19,7 +19,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight();
materialWindow = new wiWindow(GUI, "Material Window");
materialWindow->SetSize(XMFLOAT2(760, 840));
materialWindow->SetSize(XMFLOAT2(760, 860));
materialWindow->SetEnabled(false);
GUI->AddWidget(materialWindow);
@@ -40,7 +40,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
waterCheckBox = new wiCheckBox("Water: ");
waterCheckBox->SetTooltip("Set material as special water material.");
waterCheckBox->SetPos(XMFLOAT2(570, y += step));
waterCheckBox->SetPos(XMFLOAT2(670, y += step));
waterCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -50,7 +50,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
planarReflCheckBox = new wiCheckBox("Planar Reflections: ");
planarReflCheckBox->SetTooltip("Enable planar reflections. The mesh should be a single plane for best results.");
planarReflCheckBox->SetPos(XMFLOAT2(570, y += step));
planarReflCheckBox->SetPos(XMFLOAT2(670, y += step));
planarReflCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -60,7 +60,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
shadowCasterCheckBox = new wiCheckBox("Cast Shadow: ");
shadowCasterCheckBox->SetTooltip("The subset will contribute to the scene shadows if enabled.");
shadowCasterCheckBox->SetPos(XMFLOAT2(570, y += step));
shadowCasterCheckBox->SetPos(XMFLOAT2(670, y += step));
shadowCasterCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -70,7 +70,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
flipNormalMapCheckBox = new wiCheckBox("Flip Normal Map: ");
flipNormalMapCheckBox->SetTooltip("The normal map green channel will be inverted. Useful for imported models coming from OpenGL space (such as GLTF).");
flipNormalMapCheckBox->SetPos(XMFLOAT2(570, y += step));
flipNormalMapCheckBox->SetPos(XMFLOAT2(670, y += step));
flipNormalMapCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -80,7 +80,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
useVertexColorsCheckBox = new wiCheckBox("Use vertex colors: ");
useVertexColorsCheckBox->SetTooltip("Enable if you want to render the mesh with vertex colors (must have appropriate vertex buffer)");
useVertexColorsCheckBox->SetPos(XMFLOAT2(570, y += step));
useVertexColorsCheckBox->SetPos(XMFLOAT2(670, y += step));
useVertexColorsCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -88,6 +88,16 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(useVertexColorsCheckBox);
specularGlossinessCheckBox = new wiCheckBox("Specular-glossiness workflow: ");
specularGlossinessCheckBox->SetTooltip("If enabled, surface map will be viewed like it contains specular color (RGB) and smoothness (A)");
specularGlossinessCheckBox->SetPos(XMFLOAT2(670, y += step));
specularGlossinessCheckBox->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
material->SetUseSpecularGlossinessWorkflow(args.bValue);
});
materialWindow->AddWidget(specularGlossinessCheckBox);
normalMapSlider = new wiSlider(0, 4, 1, 4000, "Normalmap: ");
normalMapSlider->SetTooltip("How much the normal map should distort the face normals (bumpiness).");
normalMapSlider->SetSize(XMFLOAT2(100, 30));
@@ -188,7 +198,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
materialWindow->AddWidget(sssSlider);
pomSlider = new wiSlider(0, 0.1f, 0.0f, 1000, "Parallax Occlusion Mapping: ");
pomSlider->SetTooltip("Adjust how much the bump map should affect the object (slow).");
pomSlider->SetTooltip("Adjust how much the bump map should modulate the surface parallax effect.");
pomSlider->SetSize(XMFLOAT2(100, 30));
pomSlider->SetPos(XMFLOAT2(x, y += step));
pomSlider->OnSlide([&](wiEventArgs args) {
@@ -198,6 +208,17 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(pomSlider);
displacementMappingSlider = new wiSlider(0, 0.1f, 0.0f, 1000, "Displacement Mapping: ");
displacementMappingSlider->SetTooltip("Adjust how much the bump map should modulate the geometry when using tessellation.");
displacementMappingSlider->SetSize(XMFLOAT2(100, 30));
displacementMappingSlider->SetPos(XMFLOAT2(x, y += step));
displacementMappingSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
material->SetDisplacementMapping(args.fValue);
});
materialWindow->AddWidget(displacementMappingSlider);
texAnimFrameRateSlider = new wiSlider(0, 60, 0, 60, "Texcoord anim FPS: ");
texAnimFrameRateSlider->SetTooltip("Adjust the texture animation frame rate (frames per second). Any value above 0 will make the material dynamic.");
texAnimFrameRateSlider->SetSize(XMFLOAT2(100, 30));
@@ -267,7 +288,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
baseColorPicker = new wiColorPicker(GUI, "Base Color");
baseColorPicker->SetPos(XMFLOAT2(10, 280));
baseColorPicker->SetPos(XMFLOAT2(10, 300));
baseColorPicker->RemoveWidgets();
baseColorPicker->SetVisible(true);
baseColorPicker->SetEnabled(true);
@@ -283,7 +304,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
emissiveColorPicker = new wiColorPicker(GUI, "Emissive Color");
emissiveColorPicker->SetPos(XMFLOAT2(10, 550));
emissiveColorPicker->SetPos(XMFLOAT2(10, 570));
emissiveColorPicker->RemoveWidgets();
emissiveColorPicker->SetVisible(true);
emissiveColorPicker->SetEnabled(true);
@@ -362,6 +383,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
{
material->baseColorMap = nullptr;
material->baseColorMapName = "";
material->SetDirty();
texture_baseColor_Button->SetText("");
}
else
@@ -387,6 +409,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
string fileName = ofn.lpstrFile;
material->baseColorMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->baseColorMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_baseColor_Button->SetText(fileName);
}
@@ -394,6 +417,20 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(texture_baseColor_Button);
texture_baseColor_uvset_Field = new wiTextInputField("uvset_baseColor");
texture_baseColor_uvset_Field->SetText("");
texture_baseColor_uvset_Field->SetTooltip("uv set number");
texture_baseColor_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_baseColor_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_baseColor_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_BaseColorMap(args.iValue);
}
});
materialWindow->AddWidget(texture_baseColor_uvset_Field);
texture_normal_Label = new wiLabel("NormalMap: ");
@@ -415,6 +452,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
{
material->normalMap = nullptr;
material->normalMapName = "";
material->SetDirty();
texture_normal_Button->SetText("");
}
else
@@ -440,6 +478,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
string fileName = ofn.lpstrFile;
material->normalMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->normalMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_normal_Button->SetText(fileName);
}
@@ -447,6 +486,20 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(texture_normal_Button);
texture_normal_uvset_Field = new wiTextInputField("uvset_normal");
texture_normal_uvset_Field->SetText("");
texture_normal_uvset_Field->SetTooltip("uv set number");
texture_normal_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_normal_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_normal_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_NormalMap(args.iValue);
}
});
materialWindow->AddWidget(texture_normal_uvset_Field);
texture_surface_Label = new wiLabel("SurfaceMap: ");
@@ -468,6 +521,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
{
material->surfaceMap = nullptr;
material->surfaceMapName = "";
material->SetDirty();
texture_surface_Button->SetText("");
}
else
@@ -493,6 +547,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
string fileName = ofn.lpstrFile;
material->surfaceMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->surfaceMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_surface_Button->SetText(fileName);
}
@@ -500,6 +555,20 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(texture_surface_Button);
texture_surface_uvset_Field = new wiTextInputField("uvset_surface");
texture_surface_uvset_Field->SetText("");
texture_surface_uvset_Field->SetTooltip("uv set number");
texture_surface_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_surface_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_surface_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_SurfaceMap(args.iValue);
}
});
materialWindow->AddWidget(texture_surface_uvset_Field);
texture_displacement_Label = new wiLabel("DisplacementMap: ");
@@ -521,6 +590,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
{
material->displacementMap = nullptr;
material->displacementMapName = "";
material->SetDirty();
texture_displacement_Button->SetText("");
}
else
@@ -546,6 +616,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
string fileName = ofn.lpstrFile;
material->displacementMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->displacementMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_displacement_Button->SetText(fileName);
}
@@ -553,6 +624,20 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(texture_displacement_Button);
texture_displacement_uvset_Field = new wiTextInputField("uvset_displacement");
texture_displacement_uvset_Field->SetText("");
texture_displacement_uvset_Field->SetTooltip("uv set number");
texture_displacement_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_displacement_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_displacement_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_DisplacementMap(args.iValue);
}
});
materialWindow->AddWidget(texture_displacement_uvset_Field);
texture_emissive_Label = new wiLabel("EmissiveMap: ");
@@ -574,6 +659,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
{
material->emissiveMap = nullptr;
material->emissiveMapName = "";
material->SetDirty();
texture_emissive_Button->SetText("");
}
else
@@ -599,6 +685,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
string fileName = ofn.lpstrFile;
material->emissiveMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->emissiveMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_emissive_Button->SetText(fileName);
}
@@ -606,8 +693,92 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
});
materialWindow->AddWidget(texture_emissive_Button);
texture_emissive_uvset_Field = new wiTextInputField("uvset_emissive");
texture_emissive_uvset_Field->SetText("");
texture_emissive_uvset_Field->SetTooltip("uv set number");
texture_emissive_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_emissive_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_emissive_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_EmissiveMap(args.iValue);
}
});
materialWindow->AddWidget(texture_emissive_uvset_Field);
materialWindow->Translate(XMFLOAT3(screenW - 760, 120, 0));
texture_occlusion_Label = new wiLabel("OcclusionMap: ");
texture_occlusion_Label->SetPos(XMFLOAT2(x, y += step));
texture_occlusion_Label->SetSize(XMFLOAT2(120, 20));
materialWindow->AddWidget(texture_occlusion_Label);
texture_occlusion_Button = new wiButton("OcclusionMap");
texture_occlusion_Button->SetText("");
texture_occlusion_Button->SetTooltip("Load the occlusion map texture. R: occlusion factor");
texture_occlusion_Button->SetPos(XMFLOAT2(x + 122, y));
texture_occlusion_Button->SetSize(XMFLOAT2(260, 20));
texture_occlusion_Button->OnClick([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material == nullptr)
return;
if (material->occlusionMap != nullptr)
{
material->occlusionMap = nullptr;
material->occlusionMapName = "";
material->SetDirty();
texture_occlusion_Button->SetText("");
}
else
{
char szFile[260];
OPENFILENAMEA ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = nullptr;
ofn.lpstrFile = szFile;
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Texture\0*.dds;*.png;*.jpg;*.tga;\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = 0;
if (GetSaveFileNameA(&ofn) == TRUE) {
string fileName = ofn.lpstrFile;
material->occlusionMap = (Texture2D*)wiResourceManager::GetGlobal().add(fileName);
material->occlusionMapName = fileName;
material->SetDirty();
fileName = wiHelper::GetFileNameFromPath(fileName);
texture_occlusion_Button->SetText(fileName);
}
}
});
materialWindow->AddWidget(texture_occlusion_Button);
texture_occlusion_uvset_Field = new wiTextInputField("uvset_occlusion");
texture_occlusion_uvset_Field->SetText("");
texture_occlusion_uvset_Field->SetTooltip("uv set number");
texture_occlusion_uvset_Field->SetPos(XMFLOAT2(x + 392, y));
texture_occlusion_uvset_Field->SetSize(XMFLOAT2(20, 20));
texture_occlusion_uvset_Field->OnInputAccepted([&](wiEventArgs args) {
MaterialComponent* material = wiRenderer::GetScene().materials.GetComponent(entity);
if (material != nullptr)
{
material->SetUVSet_OcclusionMap(args.iValue);
}
});
materialWindow->AddWidget(texture_occlusion_uvset_Field);
materialWindow->Translate(XMFLOAT3(screenW - 880, 120, 0));
materialWindow->SetVisible(false);
SetEntity(INVALID_ENTITY);
@@ -646,6 +817,7 @@ void MaterialWindow::SetEntity(Entity entity)
shadowCasterCheckBox->SetCheck(material->IsCastingShadow());
flipNormalMapCheckBox->SetCheck(material->IsFlipNormalMap());
useVertexColorsCheckBox->SetCheck(material->IsUsingVertexColors());
specularGlossinessCheckBox->SetCheck(material->IsUsingSpecularGlossinessWorkflow());
normalMapSlider->SetValue(material->normalMapStrength);
roughnessSlider->SetValue(material->roughness);
reflectanceSlider->SetValue(material->reflectance);
@@ -655,6 +827,7 @@ void MaterialWindow::SetEntity(Entity entity)
emissiveSlider->SetValue(material->emissiveColor.w);
sssSlider->SetValue(material->subsurfaceScattering);
pomSlider->SetValue(material->parallaxOcclusionMapping);
displacementMappingSlider->SetValue(material->displacementMapping);
texAnimFrameRateSlider->SetValue(material->texAnimFrameRate);
texAnimDirectionSliderU->SetValue(material->texAnimDirection.x);
texAnimDirectionSliderV->SetValue(material->texAnimDirection.y);
@@ -672,6 +845,23 @@ void MaterialWindow::SetEntity(Entity entity)
texture_surface_Button->SetText(wiHelper::GetFileNameFromPath(material->surfaceMapName));
texture_displacement_Button->SetText(wiHelper::GetFileNameFromPath(material->displacementMapName));
texture_emissive_Button->SetText(wiHelper::GetFileNameFromPath(material->emissiveMapName));
texture_occlusion_Button->SetText(wiHelper::GetFileNameFromPath(material->occlusionMapName));
ss.str("");
ss << material->uvset_baseColorMap;
texture_baseColor_uvset_Field->SetText(ss.str());
ss.str("");
ss << material->uvset_normalMap;
texture_normal_uvset_Field->SetText(ss.str());
ss.str("");
ss << material->uvset_surfaceMap;
texture_surface_uvset_Field->SetText(ss.str());
ss.str("");
ss << material->uvset_emissiveMap;
texture_emissive_uvset_Field->SetText(ss.str());
ss.str("");
ss << material->uvset_occlusionMap;
texture_occlusion_uvset_Field->SetText(ss.str());
}
else
{
@@ -685,5 +875,13 @@ void MaterialWindow::SetEntity(Entity entity)
texture_surface_Button->SetText("");
texture_displacement_Button->SetText("");
texture_emissive_Button->SetText("");
texture_occlusion_Button->SetText("");
texture_baseColor_uvset_Field->SetText("");
texture_normal_uvset_Field->SetText("");
texture_surface_uvset_Field->SetText("");
texture_displacement_uvset_Field->SetText("");
texture_emissive_uvset_Field->SetText("");
texture_occlusion_uvset_Field->SetText("");
}
}