various updates: editor, wind, hairparticle

This commit is contained in:
turanszkij
2020-04-05 13:10:13 +01:00
parent 1f8c699408
commit 3f219076fb
13 changed files with 77 additions and 49 deletions
+36 -35
View File
@@ -13,22 +13,10 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
assert(GUI && "Invalid GUI!");
materialWindow = new wiWindow(GUI, "Material Window");
materialWindow->SetSize(XMFLOAT2(760, 890));
materialWindow->SetSize(XMFLOAT2(700, 760));
GUI->AddWidget(materialWindow);
materialNameField = new wiTextInputField("MaterialName");
materialNameField->SetPos(XMFLOAT2(10, 60));
materialNameField->SetSize(XMFLOAT2(300, 20));
materialNameField->OnInputAccepted([&](wiEventArgs args) {
NameComponent* name = wiScene::GetScene().names.GetComponent(entity);
if (name != nullptr)
{
*name = args.sValue;
}
});
materialWindow->AddWidget(materialNameField);
float x = 540, y = 30;
float x = 540, y = 0;
float step = 25;
waterCheckBox = new wiCheckBox("Water: ");
@@ -112,11 +100,12 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
materialWindow->AddWidget(occlusionSecondaryCheckBox);
step = 35;
step = 30;
float hei = 25;
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));
normalMapSlider->SetSize(XMFLOAT2(100, hei));
normalMapSlider->SetPos(XMFLOAT2(x, y += step));
normalMapSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -127,7 +116,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
roughnessSlider = new wiSlider(0, 1, 0.5f, 1000, "Roughness: ");
roughnessSlider->SetTooltip("Adjust the surface roughness. Rough surfaces are less shiny, more matte.");
roughnessSlider->SetSize(XMFLOAT2(100, 30));
roughnessSlider->SetSize(XMFLOAT2(100, hei));
roughnessSlider->SetPos(XMFLOAT2(x, y += step));
roughnessSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -138,7 +127,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
reflectanceSlider = new wiSlider(0, 1, 0.5f, 1000, "Reflectance: ");
reflectanceSlider->SetTooltip("Adjust the overall surface reflectivity.");
reflectanceSlider->SetSize(XMFLOAT2(100, 30));
reflectanceSlider->SetSize(XMFLOAT2(100, hei));
reflectanceSlider->SetPos(XMFLOAT2(x, y += step));
reflectanceSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -149,7 +138,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
metalnessSlider = new wiSlider(0, 1, 0.0f, 1000, "Metalness: ");
metalnessSlider->SetTooltip("The more metal-like the surface is, the more the its color will contribute to the reflection color.");
metalnessSlider->SetSize(XMFLOAT2(100, 30));
metalnessSlider->SetSize(XMFLOAT2(100, hei));
metalnessSlider->SetPos(XMFLOAT2(x, y += step));
metalnessSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -160,7 +149,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
alphaRefSlider = new wiSlider(0, 1, 1.0f, 1000, "AlphaRef: ");
alphaRefSlider->SetTooltip("Adjust the alpha cutoff threshold. Some performance optimizations will be disabled.");
alphaRefSlider->SetSize(XMFLOAT2(100, 30));
alphaRefSlider->SetSize(XMFLOAT2(100, hei));
alphaRefSlider->SetPos(XMFLOAT2(x, y += step));
alphaRefSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -171,7 +160,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
refractionIndexSlider = new wiSlider(0, 1.0f, 0.02f, 1000, "Refraction Index: ");
refractionIndexSlider->SetTooltip("Adjust the IOR (index of refraction). It controls the amount of distortion of the scene visible through the transparent object. No effect when BlendMode is set to OPAQUE.");
refractionIndexSlider->SetSize(XMFLOAT2(100, 30));
refractionIndexSlider->SetSize(XMFLOAT2(100, hei));
refractionIndexSlider->SetPos(XMFLOAT2(x, y += step));
refractionIndexSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -182,7 +171,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
emissiveSlider = new wiSlider(0, 1, 0.0f, 1000, "Emissive: ");
emissiveSlider->SetTooltip("Adjust the light emission of the surface. The color of the light emitted is that of the color of the material.");
emissiveSlider->SetSize(XMFLOAT2(100, 30));
emissiveSlider->SetSize(XMFLOAT2(100, hei));
emissiveSlider->SetPos(XMFLOAT2(x, y += step));
emissiveSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -193,7 +182,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
sssSlider = new wiSlider(0, 1, 0.0f, 1000, "Subsurface Scattering: ");
sssSlider->SetTooltip("Adjust how much the light is scattered when entered inside the surface of the object. (SSS postprocess must be enabled)");
sssSlider->SetSize(XMFLOAT2(100, 30));
sssSlider->SetSize(XMFLOAT2(100, hei));
sssSlider->SetPos(XMFLOAT2(x, y += step));
sssSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -204,7 +193,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
pomSlider = new wiSlider(0, 0.1f, 0.0f, 1000, "Parallax Occlusion Mapping: ");
pomSlider->SetTooltip("Adjust how much the bump map should modulate the surface parallax effect.");
pomSlider->SetSize(XMFLOAT2(100, 30));
pomSlider->SetSize(XMFLOAT2(100, hei));
pomSlider->SetPos(XMFLOAT2(x, y += step));
pomSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -215,7 +204,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
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->SetSize(XMFLOAT2(100, hei));
displacementMappingSlider->SetPos(XMFLOAT2(x, y += step));
displacementMappingSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -226,7 +215,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
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));
texAnimFrameRateSlider->SetSize(XMFLOAT2(100, hei));
texAnimFrameRateSlider->SetPos(XMFLOAT2(x, y += step));
texAnimFrameRateSlider->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -239,7 +228,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
texAnimDirectionSliderU = new wiSlider(-0.05f, 0.05f, 0, 1000, "Texcoord anim U: ");
texAnimDirectionSliderU->SetTooltip("Adjust the texture animation speed along the U direction in texture space.");
texAnimDirectionSliderU->SetSize(XMFLOAT2(100, 30));
texAnimDirectionSliderU->SetSize(XMFLOAT2(100, hei));
texAnimDirectionSliderU->SetPos(XMFLOAT2(x, y += step));
texAnimDirectionSliderU->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -252,7 +241,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
texAnimDirectionSliderV = new wiSlider(-0.05f, 0.05f, 0, 1000, "Texcoord anim V: ");
texAnimDirectionSliderV->SetTooltip("Adjust the texture animation speed along the V direction in texture space.");
texAnimDirectionSliderV->SetSize(XMFLOAT2(100, 30));
texAnimDirectionSliderV->SetSize(XMFLOAT2(100, hei));
texAnimDirectionSliderV->SetPos(XMFLOAT2(x, y += step));
texAnimDirectionSliderV->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -265,7 +254,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
texMulSliderX = new wiSlider(0.01f, 10.0f, 0, 1000, "Texture TileSize X: ");
texMulSliderX->SetTooltip("Adjust the texture mapping size.");
texMulSliderX->SetSize(XMFLOAT2(100, 30));
texMulSliderX->SetSize(XMFLOAT2(100, hei));
texMulSliderX->SetPos(XMFLOAT2(x, y += step));
texMulSliderX->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -279,7 +268,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
texMulSliderY = new wiSlider(0.01f, 10.0f, 0, 1000, "Texture TileSize Y: ");
texMulSliderY->SetTooltip("Adjust the texture mapping size.");
texMulSliderY->SetSize(XMFLOAT2(100, 30));
texMulSliderY->SetSize(XMFLOAT2(100, hei));
texMulSliderY->SetPos(XMFLOAT2(x, y += step));
texMulSliderY->OnSlide([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
@@ -293,7 +282,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
baseColorPicker = new wiColorPicker(GUI, "Base Color", false);
baseColorPicker->SetPos(XMFLOAT2(10, 300));
baseColorPicker->SetPos(XMFLOAT2(10, 240));
baseColorPicker->SetVisible(true);
baseColorPicker->SetEnabled(true);
baseColorPicker->OnColorChanged([&](wiEventArgs args) {
@@ -307,7 +296,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
emissiveColorPicker = new wiColorPicker(GUI, "Emissive Color", false);
emissiveColorPicker->SetPos(XMFLOAT2(10, 570));
emissiveColorPicker->SetPos(XMFLOAT2(10, 500));
emissiveColorPicker->SetVisible(true);
emissiveColorPicker->SetEnabled(true);
emissiveColorPicker->OnColorChanged([&](wiEventArgs args) {
@@ -323,7 +312,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
blendModeComboBox = new wiComboBox("Blend mode: ");
blendModeComboBox->SetPos(XMFLOAT2(x, y += step));
blendModeComboBox->SetSize(XMFLOAT2(100, 25));
blendModeComboBox->SetSize(XMFLOAT2(100, hei));
blendModeComboBox->OnSelect([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
if (material != nullptr && args.iValue >= 0)
@@ -343,7 +332,7 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
shaderTypeComboBox = new wiComboBox("Custom Shader: ");
shaderTypeComboBox->SetTooltip("Select a custom shader for his material. See wiRenderer:RegisterCustomShader() for more info.");
shaderTypeComboBox->SetPos(XMFLOAT2(x, y += step));
shaderTypeComboBox->SetSize(XMFLOAT2(100, 25));
shaderTypeComboBox->SetSize(XMFLOAT2(100, hei));
shaderTypeComboBox->OnSelect([&](wiEventArgs args) {
MaterialComponent* material = wiScene::GetScene().materials.GetComponent(entity);
if (material != nullptr)
@@ -364,7 +353,19 @@ MaterialWindow::MaterialWindow(wiGUI* gui) : GUI(gui)
// Textures:
x = 10;
y = 60;
y = 0;
materialNameField = new wiTextInputField("MaterialName");
materialNameField->SetPos(XMFLOAT2(10, y += step));
materialNameField->SetSize(XMFLOAT2(300, 25));
materialNameField->OnInputAccepted([&](wiEventArgs args) {
NameComponent* name = wiScene::GetScene().names.GetComponent(entity);
if (name != nullptr)
{
*name = args.sValue;
}
});
materialWindow->AddWidget(materialNameField);
texture_baseColor_Label = new wiLabel("BaseColorMap: ");
texture_baseColor_Label->SetPos(XMFLOAT2(x, y += step));
+16 -4
View File
@@ -68,14 +68,22 @@ WeatherWindow::WeatherWindow(wiGUI* gui) : GUI(gui)
});
weatherWindow->AddWidget(cloudSpeedSlider);
windSpeedSlider = new wiSlider(0.0f, 0.2f, 0.0f, 10000, "Wind Speed: ");
windSpeedSlider = new wiSlider(0.0f, 4.0f, 1.0f, 10000, "Wind Speed: ");
windSpeedSlider->SetSize(XMFLOAT2(100, 30));
windSpeedSlider->SetPos(XMFLOAT2(x, y += step));
windSpeedSlider->OnSlide([&](wiEventArgs args) {
UpdateWind();
GetWeather().windSpeed = args.fValue;
});
weatherWindow->AddWidget(windSpeedSlider);
windMagnitudeSlider = new wiSlider(0.0f, 0.2f, 0.0f, 10000, "Wind Magnitude: ");
windMagnitudeSlider->SetSize(XMFLOAT2(100, 30));
windMagnitudeSlider->SetPos(XMFLOAT2(x, y += step));
windMagnitudeSlider->OnSlide([&](wiEventArgs args) {
UpdateWind();
});
weatherWindow->AddWidget(windMagnitudeSlider);
windDirectionSlider = new wiSlider(0, 1, 0, 10000, "Wind Direction: ");
windDirectionSlider->SetSize(XMFLOAT2(100, 30));
windDirectionSlider->SetPos(XMFLOAT2(x, y += step));
@@ -92,7 +100,7 @@ WeatherWindow::WeatherWindow(wiGUI* gui) : GUI(gui)
});
weatherWindow->AddWidget(windWaveSizeSlider);
windRandomnessSlider = new wiSlider(0, 1, 0, 10000, "Wind Randomness: ");
windRandomnessSlider = new wiSlider(0, 10, 5, 10000, "Wind Randomness: ");
windRandomnessSlider->SetSize(XMFLOAT2(100, 30));
windRandomnessSlider->SetPos(XMFLOAT2(x, y += step));
windRandomnessSlider->OnSlide([&](wiEventArgs args) {
@@ -484,6 +492,10 @@ void WeatherWindow::Update()
cloudinessSlider->SetValue(weather.cloudiness);
cloudScaleSlider->SetValue(weather.cloudScale);
cloudSpeedSlider->SetValue(weather.cloudSpeed);
windSpeedSlider->SetValue(weather.windSpeed);
windWaveSizeSlider->SetValue(weather.windWaveSize);
windRandomnessSlider->SetValue(weather.windRandomness);
windMagnitudeSlider->SetValue(XMVectorGetX(XMVector3Length(XMLoadFloat3(&weather.windDirection))));
ambientColorPicker->SetPickColor(wiColor::fromFloat3(weather.ambient));
horizonColorPicker->SetPickColor(wiColor::fromFloat3(weather.horizon));
@@ -529,6 +541,6 @@ void WeatherWindow::UpdateWind()
XMMATRIX rot = XMMatrixRotationY(windDirectionSlider->GetValue() * XM_PI * 2);
XMVECTOR dir = XMVectorSet(1, 0, 0, 0);
dir = XMVector3TransformNormal(dir, rot);
dir *= windSpeedSlider->GetValue();
dir *= windMagnitudeSlider->GetValue();
XMStoreFloat3(&GetWeather().windDirection, dir);
}
+1
View File
@@ -30,6 +30,7 @@ public:
wiSlider* cloudScaleSlider;
wiSlider* cloudSpeedSlider;
wiSlider* windSpeedSlider;
wiSlider* windMagnitudeSlider;
wiSlider* windDirectionSlider;
wiSlider* windWaveSizeSlider;
wiSlider* windRandomnessSlider;
+1
View File
@@ -1,5 +1,6 @@
This file contains changelog of wiArchive versions
40: Serialized WeatherComponent::windSpeed
39: Serialized indices and weights for Hair Particle
38: Serialized SpringComponent
37: Serialized InverseKinematicsComponent
+2 -1
View File
@@ -207,7 +207,8 @@ CBUFFER(FrameCB, CBSLOT_RENDERER_FRAME)
float g_xFrame_Time;
float g_xFrame_TimePrev;
float2 _padding0_frameCB;
float _padding0_frameCB;
float g_xFrame_WindSpeed;
float g_xFrame_DeltaTime;
uint g_xFrame_FrameCount;
+8 -6
View File
@@ -30,8 +30,8 @@ VertexToPixel main(uint fakeIndex : SV_VERTEXID)
const uint segmentID = (fakeIndex / 12) % xHairSegmentCount;
const uint particleID = fakeIndex / 12;
float3 position = particleBuffer[particleID].position;
Out.fade = saturate(distance(position.xyz, g_xCamera_CamPos.xyz) / xHairViewDistance);
float3 rootposition = particleBuffer[particleID - segmentID].position;
Out.fade = saturate(distance(rootposition.xyz, g_xCamera_CamPos.xyz) / xHairViewDistance);
Out.fade = saturate(Out.fade - 0.8f) * 5.0f; // fade will be on edge and inwards 20%
[branch]
@@ -74,15 +74,17 @@ VertexToPixel main(uint fakeIndex : SV_VERTEXID)
patchPos.xyz *= frame.xyx * 0.5f;
// simplistic wind effect only affects the top, but leaves the base as is:
const float3 posrand = (position.x + position.y + position.z) * g_xFrame_WindRandomness;
float3 wind = sin(g_xFrame_Time * (1 + g_xFrame_WindWaveSize) + posrand) * g_xFrame_WindDirection * patchPos.y;
float3 windPrev = sin(g_xFrame_TimePrev * (1 + g_xFrame_WindWaveSize) + posrand) * g_xFrame_WindDirection * patchPos.y;
const float waveoffset = dot(rootposition, g_xFrame_WindDirection) * g_xFrame_WindWaveSize + rand / 255.0f * g_xFrame_WindRandomness;
const float3 wavedir = g_xFrame_WindDirection * (segmentID + patchPos.y);
const float3 wind = sin(g_xFrame_Time * g_xFrame_WindSpeed + waveoffset) * wavedir;
const float3 windPrev = sin(g_xFrame_TimePrev * g_xFrame_WindSpeed + waveoffset) * wavedir;
// rotate the patch into the tangent space of the emitting triangle:
float3x3 TBN = float3x3(tangent, normal, binormal); // don't derive binormal, because we want the shear!
patchPos = mul(patchPos, TBN);
// inset to the emitter a bit, to avoid disconnect:
float3 position = particleBuffer[particleID].position;
position.xyz -= normal * 0.1 * len;
@@ -94,7 +96,7 @@ VertexToPixel main(uint fakeIndex : SV_VERTEXID)
Out.pos3D = Out.pos.xyz;
Out.pos = mul(g_xCamera_VP, Out.pos);
Out.nor = normal;
Out.nor = normalize(normal + wind);
Out.tex = uv;
Out.pos2D = Out.pos;
+1 -1
View File
@@ -3,7 +3,7 @@
float4 main(PixelInputType_Simple PSIn) : SV_TARGET
{
const uint2 pixel = (xPaintRadUVSET == 0 ? PSIn.uvsets.xy : PSIn.uvsets.zw) * xPaintRadResolution;
const float2 pixel = (xPaintRadUVSET == 0 ? PSIn.uvsets.xy : PSIn.uvsets.zw) * xPaintRadResolution;
const float dist = distance(pixel, xPaintRadCenter);
float circle = dist - xPaintRadRadius;
float3 color = circle < 0 ? float3(0, 0, 0) : float3(1, 1, 1);
+1 -1
View File
@@ -7,7 +7,7 @@
using namespace std;
// this should always be only INCREMENTED and only if a new serialization is implemeted somewhere!
uint64_t __archiveVersion = 39;
uint64_t __archiveVersion = 40;
// this is the version number of which below the archive is not compatible with the current version
uint64_t __archiveVersionBarrier = 22;
+1
View File
@@ -8437,6 +8437,7 @@ void UpdateFrameCB(CommandList cmd)
cb.g_xFrame_ForceFieldArrayCount = entityArrayCount_ForceFields;
cb.g_xFrame_EnvProbeArrayOffset = entityArrayOffset_EnvProbes;
cb.g_xFrame_EnvProbeArrayCount = entityArrayCount_EnvProbes;
cb.g_xFrame_WindSpeed = scene.weather.windSpeed;
cb.g_xFrame_WindRandomness = scene.weather.windRandomness;
cb.g_xFrame_WindWaveSize = scene.weather.windWaveSize;
cb.g_xFrame_WindDirection = scene.weather.windDirection;
+1
View File
@@ -935,6 +935,7 @@ namespace wiScene
XMFLOAT3 windDirection = XMFLOAT3(0, 0, 0);
float windRandomness = 5;
float windWaveSize = 1;
float windSpeed = 1;
struct OceanParameters
{
+8
View File
@@ -701,6 +701,10 @@ namespace wiScene
archive >> skyMapName;
skyMap = wiResourceManager::Load(dir + skyMapName);
}
if (archive.GetVersion() >= 40)
{
archive >> windSpeed;
}
}
else
@@ -747,6 +751,10 @@ namespace wiScene
}
archive << skyMapName;
}
if (archive.GetVersion() >= 40)
{
archive << windSpeed;
}
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 39;
// minor bug fixes, alterations, refactors, updates
const int revision = 39;
const int revision = 40;
long GetVersion()
Binary file not shown.