depth of field params moved to CameraComponent

This commit is contained in:
Turanszki Janos
2021-04-04 17:07:27 +02:00
parent 8b2333ba70
commit ea673fb3b7
24 changed files with 202 additions and 126 deletions
@@ -512,6 +512,12 @@ Describes an orientation in 3D space.
- SetNearPlane(float value)
- GetFarPlane() : float result
- SetFarPlane(float value)
- GetFocalDistance() : float result
- SetFocalDistance(float value)
- GetApertureSize() : float result
- SetApertureSize(float value)
- GetApertureShape() : float result
- SetApertureShape(Vector value)
- GetView() : Matrix result
- GetProjection() : Matrix result
- GetViewProjection() : Matrix result
@@ -629,9 +635,9 @@ It can hold Sprites and SpriteFonts and can sort them by layers, update and rend
- SetFontOrder(SpriteFont font, int order)
#### RenderPath3D
A 3D scene can either be rendered by a Forward or Deferred render path, or path tracing.
This is the default scene render path.
It inherits functions from RenderPath2D, so it can render a 2D overlay.
- [void-constructor]RenderPath3D()
- [constructor]RenderPath3D()
- SetAO(int value) -- Sets up the ambient occlusion effect (possible values below)
- AO_DISABLED : int -- turn off AO computation (use in SetAO() function)
- AO_SSAO : int -- enable simple brute force screen space ambient occlusion (use in SetAO() function)
@@ -655,32 +661,12 @@ It inherits functions from RenderPath2D, so it can render a 2D overlay.
- SetSSSEnabled(bool value)
- SetDitherEnabled(bool value)
- SetDepthOfFieldEnabled(bool value)
- SetDepthOfFieldFocus(float value)
- SetDepthOfFieldStrength(float value)
- SetDepthOfFieldAspect(float value)
- SetMSAASampleCount(int count)
- SetSharpenFilterEnabled(bool value)
- SetSharpenFilterAmount(float value)
- SetExposure(float value)
##### RenderPath3D_Forward
It renders the scene contained by the Renderer in a forward render path. The component does not hold the scene information,
only the effects to render the scene. The scene is managed and ultimately rendered by the Renderer.
It inherits functions from RenderPath3D.
- [constructor]RenderPath3D_Forward()
##### RenderPath3D_TiledForward
It renders the scene contained by the Renderer in a tiled forward render path. The component does not hold the scene information,
only the effects to render the scene. The scene is managed and ultimately rendered by the Renderer.
It inherits functions from RenderPath3D_Forward3D.
- [constructor]RenderPath3D_TiledForward()
##### RenderPath3D_Deferred
It renders the scene contained by the Renderer in a deferred render path. The component does not hold the scene information,
only the effects to render the scene. The scene is managed and ultimately rendered by the Renderer.
It inherits functions from RenderPath3D.
- [constructor]RenderPath3D_Deferred()
#### LoadingScreen
It is a RenderPath2D but one that internally manages resource loading and can display information about the process.
It inherits functions from RenderPath2D.
+59 -1
View File
@@ -24,7 +24,7 @@ void CameraWindow::Create(EditorComponent* editor)
camera_transform.MatrixTransform(wiScene::GetCamera().GetInvView());
camera_transform.UpdateTransform();
SetSize(XMFLOAT2(380, 260));
SetSize(XMFLOAT2(380, 340));
float x = 200;
float y = 10;
@@ -32,6 +32,7 @@ void CameraWindow::Create(EditorComponent* editor)
float step = hei + 2;
farPlaneSlider.Create(1, 5000, 1000, 100000, "Far Plane: ");
farPlaneSlider.SetTooltip("Controls the camera's far clip plane, geometry farther than this will be clipped.");
farPlaneSlider.SetSize(XMFLOAT2(100, hei));
farPlaneSlider.SetPos(XMFLOAT2(x, y += step));
farPlaneSlider.SetValue(wiScene::GetCamera().zFarP);
@@ -40,10 +41,12 @@ void CameraWindow::Create(EditorComponent* editor)
CameraComponent& camera = wiScene::GetCamera();
camera.zFarP = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&farPlaneSlider);
nearPlaneSlider.Create(0.01f, 10, 0.1f, 10000, "Near Plane: ");
nearPlaneSlider.SetTooltip("Controls the camera's near clip plane, geometry closer than this will be clipped.");
nearPlaneSlider.SetSize(XMFLOAT2(100, hei));
nearPlaneSlider.SetPos(XMFLOAT2(x, y += step));
nearPlaneSlider.SetValue(wiScene::GetCamera().zNearP);
@@ -52,10 +55,12 @@ void CameraWindow::Create(EditorComponent* editor)
CameraComponent& camera = wiScene::GetCamera();
camera.zNearP = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&nearPlaneSlider);
fovSlider.Create(1, 179, 60, 10000, "FOV: ");
fovSlider.SetTooltip("Controls the camera's top-down field of view (in degrees)");
fovSlider.SetSize(XMFLOAT2(100, hei));
fovSlider.SetPos(XMFLOAT2(x, y += step));
fovSlider.OnSlide([&](wiEventArgs args) {
@@ -63,9 +68,62 @@ void CameraWindow::Create(EditorComponent* editor)
CameraComponent& camera = wiScene::GetCamera();
camera.fov = args.fValue / 180.f * XM_PI;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&fovSlider);
focalLengthSlider.Create(0.001f, 100, 1, 10000, "Focal Length: ");
focalLengthSlider.SetTooltip("Controls the depth of field effect's focus distance");
focalLengthSlider.SetSize(XMFLOAT2(100, hei));
focalLengthSlider.SetPos(XMFLOAT2(x, y += step));
focalLengthSlider.OnSlide([&](wiEventArgs args) {
Scene& scene = wiScene::GetScene();
CameraComponent& camera = wiScene::GetCamera();
camera.focal_length = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&focalLengthSlider);
apertureSizeSlider.Create(0, 1, 0, 10000, "Aperture Size: ");
apertureSizeSlider.SetTooltip("Controls the depth of field effect's strength");
apertureSizeSlider.SetSize(XMFLOAT2(100, hei));
apertureSizeSlider.SetPos(XMFLOAT2(x, y += step));
apertureSizeSlider.OnSlide([&](wiEventArgs args) {
Scene& scene = wiScene::GetScene();
CameraComponent& camera = wiScene::GetCamera();
camera.aperture_size = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&apertureSizeSlider);
apertureShapeXSlider.Create(0, 2, 1, 10000, "Aperture Shape X: ");
apertureShapeXSlider.SetTooltip("Controls the depth of field effect's bokeh shape");
apertureShapeXSlider.SetSize(XMFLOAT2(100, hei));
apertureShapeXSlider.SetPos(XMFLOAT2(x, y += step));
apertureShapeXSlider.OnSlide([&](wiEventArgs args) {
Scene& scene = wiScene::GetScene();
CameraComponent& camera = wiScene::GetCamera();
camera.aperture_shape.x = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&apertureShapeXSlider);
apertureShapeYSlider.Create(0, 2, 1, 10000, "Aperture Shape Y: ");
apertureShapeYSlider.SetTooltip("Controls the depth of field effect's bokeh shape");
apertureShapeYSlider.SetSize(XMFLOAT2(100, hei));
apertureShapeYSlider.SetPos(XMFLOAT2(x, y += step));
apertureShapeYSlider.OnSlide([&](wiEventArgs args) {
Scene& scene = wiScene::GetScene();
CameraComponent& camera = wiScene::GetCamera();
camera.aperture_shape.y = args.fValue;
camera.UpdateCamera();
camera.SetDirty();
});
AddWidget(&apertureShapeYSlider);
movespeedSlider.Create(1, 100, 10, 10000, "Movement Speed: ");
movespeedSlider.SetSize(XMFLOAT2(100, hei));
movespeedSlider.SetPos(XMFLOAT2(x, y += step));
+4
View File
@@ -20,6 +20,10 @@ public:
wiSlider farPlaneSlider;
wiSlider nearPlaneSlider;
wiSlider fovSlider;
wiSlider focalLengthSlider;
wiSlider apertureSizeSlider;
wiSlider apertureShapeXSlider;
wiSlider apertureShapeYSlider;
wiSlider movespeedSlider;
wiSlider rotationspeedSlider;
wiButton resetButton;
+4 -26
View File
@@ -11,7 +11,7 @@ using namespace wiGraphics;
void PostprocessWindow::Create(EditorComponent* editor)
{
wiWindow::Create("PostProcess Window");
SetSize(XMFLOAT2(420, 540));
SetSize(XMFLOAT2(420, 500));
float x = 150;
float y = 10;
@@ -249,39 +249,17 @@ void PostprocessWindow::Create(EditorComponent* editor)
});
AddWidget(&depthOfFieldCheckBox);
depthOfFieldFocusSlider.Create(1.0f, 100, 10, 10000, "Focus: ");
depthOfFieldFocusSlider.SetTooltip("Set the focus distance from the camera. The picture will be sharper near the focus, and blurrier further from it.");
depthOfFieldFocusSlider.SetScriptTip("RenderPath3D::SetDepthOfFieldFocus(float value)");
depthOfFieldFocusSlider.SetSize(XMFLOAT2(100, hei));
depthOfFieldFocusSlider.SetPos(XMFLOAT2(x + 100, y));
depthOfFieldFocusSlider.SetValue(editor->renderPath->getDepthOfFieldFocus());
depthOfFieldFocusSlider.OnSlide([=](wiEventArgs args) {
editor->renderPath->setDepthOfFieldFocus(args.fValue);
});
AddWidget(&depthOfFieldFocusSlider);
depthOfFieldScaleSlider.Create(1.0f, 20, 100, 1000, "Scale: ");
depthOfFieldScaleSlider.SetTooltip("Set depth of field scale/falloff.");
depthOfFieldScaleSlider.Create(1.0f, 20, 100, 1000, "Strength: ");
depthOfFieldScaleSlider.SetTooltip("Set depth of field strength. This is used to scale the Camera's ApertureSize setting");
depthOfFieldScaleSlider.SetScriptTip("RenderPath3D::SetDepthOfFieldStrength(float value)");
depthOfFieldScaleSlider.SetSize(XMFLOAT2(100, hei));
depthOfFieldScaleSlider.SetPos(XMFLOAT2(x + 100, y += step));
depthOfFieldScaleSlider.SetPos(XMFLOAT2(x + 100, y));
depthOfFieldScaleSlider.SetValue(editor->renderPath->getDepthOfFieldStrength());
depthOfFieldScaleSlider.OnSlide([=](wiEventArgs args) {
editor->renderPath->setDepthOfFieldStrength(args.fValue);
});
AddWidget(&depthOfFieldScaleSlider);
depthOfFieldAspectSlider.Create(0.01f, 2, 1, 1000, "Aspect: ");
depthOfFieldAspectSlider.SetTooltip("Set depth of field bokeh aspect ratio (width/height).");
depthOfFieldAspectSlider.SetScriptTip("RenderPath3D::SetDepthOfFieldAspect(float value)");
depthOfFieldAspectSlider.SetSize(XMFLOAT2(100, hei));
depthOfFieldAspectSlider.SetPos(XMFLOAT2(x + 100, y += step));
depthOfFieldAspectSlider.SetValue(editor->renderPath->getDepthOfFieldAspect());
depthOfFieldAspectSlider.OnSlide([=](wiEventArgs args) {
editor->renderPath->setDepthOfFieldAspect(args.fValue);
});
AddWidget(&depthOfFieldAspectSlider);
bloomCheckBox.Create("Bloom: ");
bloomCheckBox.SetTooltip("Enable bloom. The effect adds color bleeding to the brightest parts of the scene.");
bloomCheckBox.SetScriptTip("RenderPath3D::SetBloomEnabled(bool value)");
-2
View File
@@ -27,9 +27,7 @@ public:
wiCheckBox motionBlurCheckBox;
wiSlider motionBlurStrengthSlider;
wiCheckBox depthOfFieldCheckBox;
wiSlider depthOfFieldFocusSlider;
wiSlider depthOfFieldScaleSlider;
wiSlider depthOfFieldAspectSlider;
wiCheckBox bloomCheckBox;
wiSlider bloomStrengthSlider;
wiCheckBox fxaaCheckBox;
+1
View File
@@ -1,5 +1,6 @@
This file contains changelog of wiArchive versions
65: serialized CameraComponent focal_length, aperture_size and aperture_shape
64: serialized per-emitter gravity, velocity, drag and random_color
63: serialized wiResourceManager embedded resources
62: serialized WeatherComponent::colorGradingMapName property
+3 -5
View File
@@ -1274,7 +1274,7 @@ void RenderPath3D::RenderPostprocessChain(CommandList cmd) const
rt_first = &rtTemporalAA[output];
}
if (getDepthOfFieldEnabled())
if (getDepthOfFieldEnabled() && camera->aperture_size > 0 && getDepthOfFieldStrength() > 0)
{
wiRenderer::Postprocess_DepthOfField(
depthoffieldResources,
@@ -1282,9 +1282,7 @@ void RenderPath3D::RenderPostprocessChain(CommandList cmd) const
*rt_write,
rtLinearDepth,
cmd,
getDepthOfFieldFocus(),
getDepthOfFieldStrength(),
getDepthOfFieldAspect()
getDepthOfFieldStrength()
);
rt_first = nullptr;
@@ -1292,7 +1290,7 @@ void RenderPath3D::RenderPostprocessChain(CommandList cmd) const
device->UnbindResources(TEXSLOT_ONDEMAND0, 1, cmd);
}
if (getMotionBlurEnabled())
if (getMotionBlurEnabled() && getMotionBlurStrength() > 0)
{
wiRenderer::Postprocess_MotionBlur(
motionblurResources,
+1 -7
View File
@@ -24,9 +24,7 @@ private:
float exposure = 1.0f;
float bloomThreshold = 1.0f;
float motionBlurStrength = 100.0f;
float dofFocus = 2.0f;
float dofStrength = 10.0f;
float dofAspect = 1.0f;
float sharpenFilterAmount = 0.28f;
float outlineThreshold = 0.2f;
float outlineThickness = 1.0f;
@@ -53,7 +51,7 @@ private:
bool lightShaftsEnabled = false;
bool lensFlareEnabled = true;
bool motionBlurEnabled = false;
bool depthOfFieldEnabled = false;
bool depthOfFieldEnabled = true;
bool eyeAdaptionEnabled = false;
bool sharpenFilterEnabled = false;
bool outlineEnabled = false;
@@ -182,9 +180,7 @@ public:
constexpr float getExposure() const { return exposure; }
constexpr float getBloomThreshold() const { return bloomThreshold; }
constexpr float getMotionBlurStrength() const { return motionBlurStrength; }
constexpr float getDepthOfFieldFocus() const { return dofFocus; }
constexpr float getDepthOfFieldStrength() const { return dofStrength; }
constexpr float getDepthOfFieldAspect() const { return dofAspect; }
constexpr float getSharpenFilterAmount() const { return sharpenFilterAmount; }
constexpr float getOutlineThreshold() const { return outlineThreshold; }
constexpr float getOutlineThickness() const { return outlineThickness; }
@@ -226,9 +222,7 @@ public:
constexpr void setExposure(float value) { exposure = value; }
constexpr void setBloomThreshold(float value){ bloomThreshold = value; }
constexpr void setMotionBlurStrength(float value) { motionBlurStrength = value; }
constexpr void setDepthOfFieldFocus(float value){ dofFocus = value; }
constexpr void setDepthOfFieldStrength(float value) { dofStrength = value; }
constexpr void setDepthOfFieldAspect(float value){ dofAspect = value; }
constexpr void setSharpenFilterAmount(float value) { sharpenFilterAmount = value; }
constexpr void setOutlineThreshold(float value) { outlineThreshold = value; }
constexpr void setOutlineThickness(float value) { outlineThickness = value; }
-32
View File
@@ -43,9 +43,7 @@ Luna<RenderPath3D_BindLua>::FunctionType RenderPath3D_BindLua::methods[] = {
lunamethod(RenderPath3D_BindLua, SetSharpenFilterAmount),
lunamethod(RenderPath3D_BindLua, SetExposure),
lunamethod(RenderPath3D_BindLua, SetMotionBlurStrength),
lunamethod(RenderPath3D_BindLua, SetDepthOfFieldFocus),
lunamethod(RenderPath3D_BindLua, SetDepthOfFieldStrength),
lunamethod(RenderPath3D_BindLua, SetDepthOfFieldAspect),
{ NULL, NULL }
};
Luna<RenderPath3D_BindLua>::PropertyType RenderPath3D_BindLua::properties[] = {
@@ -348,21 +346,6 @@ int RenderPath3D_BindLua::SetMotionBlurStrength(lua_State* L)
wiLua::SError(L, "SetMotionBlurStrength(float value) not enough arguments!");
return 0;
}
int RenderPath3D_BindLua::SetDepthOfFieldFocus(lua_State* L)
{
if (component == nullptr)
{
wiLua::SError(L, "SetDepthOfFieldFocus(float value) component is null!");
return 0;
}
if (wiLua::SGetArgCount(L) > 0)
{
((RenderPath3D*)component)->setDepthOfFieldFocus(wiLua::SGetFloat(L, 1));
}
else
wiLua::SError(L, "SetDepthOfFieldFocus(float value) not enough arguments!");
return 0;
}
int RenderPath3D_BindLua::SetDepthOfFieldStrength(lua_State* L)
{
if (component == nullptr)
@@ -378,21 +361,6 @@ int RenderPath3D_BindLua::SetDepthOfFieldStrength(lua_State* L)
wiLua::SError(L, "SetDepthOfFieldStrength(float value) not enough arguments!");
return 0;
}
int RenderPath3D_BindLua::SetDepthOfFieldAspect(lua_State* L)
{
if (component == nullptr)
{
wiLua::SError(L, "SetDepthOfFieldAspect(float value) component is null!");
return 0;
}
if (wiLua::SGetArgCount(L) > 0)
{
((RenderPath3D*)component)->setDepthOfFieldAspect(wiLua::SGetFloat(L, 1));
}
else
wiLua::SError(L, "SetDepthOfFieldAspect(float value) not enough arguments!");
return 0;
}
void RenderPath3D_BindLua::Bind()
{
-2
View File
@@ -44,9 +44,7 @@ public:
int SetSharpenFilterAmount(lua_State* L);
int SetExposure(lua_State* L);
int SetMotionBlurStrength(lua_State* L);
int SetDepthOfFieldFocus(lua_State* L);
int SetDepthOfFieldStrength(lua_State* L);
int SetDepthOfFieldAspect(lua_State* L);
static void Bind();
};
@@ -75,10 +75,8 @@ static const uint MOTIONBLUR_TILESIZE = 32;
#define motionblur_strength xPPParams0.x
static const uint DEPTHOFFIELD_TILESIZE = 32;
#define dof_focus xPPParams0.x
#define dof_scale xPPParams0.y
#define dof_aspect xPPParams0.z
#define dof_maxcoc xPPParams0.w
#define dof_cocscale xPPParams0.x
#define dof_maxcoc xPPParams0.y
struct PushConstantsTonemap
{
@@ -434,6 +434,10 @@ CBUFFER(CameraCB, CBSLOT_RENDERER_CAMERA)
float4x4 g_xCamera_PrevVP; // PrevView*PrevProjection
float4x4 g_xCamera_PrevInvVP; // Inverse(PrevView*PrevProjection)
float4x4 g_xCamera_ReflVP; // ReflectionView*ReflectionProjection
float2 g_xCamera_ApertureShape;
float g_xCamera_ApertureSize;
float g_xCamera_FocalLength;
};
+1 -1
View File
@@ -3,7 +3,7 @@
inline float get_coc(in float linear_depth)
{
return min(dof_maxcoc, dof_scale * pow(abs(1 - dof_focus / (linear_depth * g_xCamera_ZFarP)), 2.0f));
return min(dof_maxcoc, dof_cocscale * g_xCamera_ApertureSize * pow(abs(1 - g_xCamera_FocalLength / (linear_depth * g_xCamera_ZFarP)), 2.0f));
}
#define DOF_DEPTH_SCALE_FOREGROUND (g_xCamera_ZFarP * 1.5)
@@ -46,7 +46,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
const uint ringCount = clamp(ceil(pow(maxcoc, 0.5f) * DOF_RING_COUNT), 1, DOF_RING_COUNT);
const float spreadScale = ringCount / maxcoc;
const float2 ringScale = float(ringCount) / float(DOF_RING_COUNT) * maxcoc * float2(max(1, dof_aspect), max(1, 2 - dof_aspect)) * xPPResolution_rcp;
const float2 ringScale = float(ringCount) / float(DOF_RING_COUNT) * maxcoc * g_xCamera_ApertureShape * xPPResolution_rcp;
const float3 center_color = texture_prefilter[pixel];
const float3 center_presort = texture_presort[pixel];
@@ -56,8 +56,6 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
const float2 uv = (pixel + 0.5f) * xPPResolution_rcp;
float seed = 12345;
#ifdef DEPTHOFFIELD_CHEAP
color = center_color;
[unroll(DOF_RING_COUNT)]
@@ -47,9 +47,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID)
[branch]
if (backgroundFactor < 1.0f)
{
float seed = 54321;
const float2 ringScale = 0.5f * coc * float2(max(1, dof_aspect), max(1, 2 - dof_aspect)) * xPPResolution_rcp;
const float2 ringScale = 0.5f * coc * g_xCamera_ApertureShape * xPPResolution_rcp;
[unroll]
for (uint i = ringSampleCount[0]; i < ringSampleCount[1]; ++i)
{
+14 -4
View File
@@ -24,6 +24,17 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
// Create starting ray:
RayDesc ray = CreateCameraRay(uv);
// Depth of field setup:
float3 focal_point = ray.Origin + ray.Direction * g_xCamera_FocalLength;
float3 coc = float3(hemispherepoint_cos(rand(seed, pixel), rand(seed, pixel)).xy, 0);
coc.xy *= g_xCamera_ApertureShape.xy;
coc = mul(coc, float3x3(cross(g_xCamera_Up, g_xCamera_At), g_xCamera_Up, g_xCamera_At));
coc *= g_xCamera_FocalLength;
coc *= g_xCamera_ApertureSize;
coc *= 0.1f;
ray.Origin = ray.Origin + coc;
ray.Direction = focal_point - ray.Origin; // will be normalized before tracing!
uint bounces = xTraceUserData.x;
const uint bouncelimit = 16;
for (uint bounce = 0; ((bounce < min(bounces, bouncelimit)) && any(energy)); ++bounce)
@@ -169,7 +180,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
}
}
float3 lightColor = 0;
float3 lightColor = 1;
SurfaceToLight surfaceToLight = (SurfaceToLight)0;
// Light sampling:
@@ -204,7 +215,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
atmosphereTransmittance = GetAtmosphericLightTransmittance(Atmosphere, surface.P, L, texture_transmittancelut);
}
lightColor = light.GetColor().rgb * light.GetEnergy() * atmosphereTransmittance;
lightColor *= atmosphereTransmittance;
}
}
break;
@@ -229,7 +240,6 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
const float att = saturate(1 - (dist2 / range2));
const float attenuation = att * att;
lightColor = light.GetColor().rgb * light.GetEnergy();
lightColor *= attenuation;
}
}
@@ -263,7 +273,6 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
float attenuation = att * att;
attenuation *= saturate((1 - (1 - SpotFactor) * 1 / (1 - spotCutOff)));
lightColor = light.GetColor().rgb * light.GetEnergy();
lightColor *= attenuation;
}
}
@@ -326,6 +335,7 @@ void main(uint3 DTid : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex)
#endif // RTAPI
if (any(shadow))
{
lightColor *= light.GetColor().rgb * light.GetEnergy();
lighting.direct.specular = lightColor * BRDF_GetSpecular(surface, surfaceToLight);
lighting.direct.diffuse = lightColor * BRDF_GetDiffuse(surface, surfaceToLight);
result += max(0, shadow * (surface.albedo * lighting.direct.diffuse + lighting.direct.specular));
+1 -1
View File
@@ -6,7 +6,7 @@
using namespace std;
// this should always be only INCREMENTED and only if a new serialization is implemeted somewhere!
uint64_t __archiveVersion = 64;
uint64_t __archiveVersion = 65;
// this is the version number of which below the archive is not compatible with the current version
uint64_t __archiveVersionBarrier = 22;
+8 -8
View File
@@ -7901,7 +7901,7 @@ void RayTraceScene(
cb.xTraceResolution_rcp.y = 1.0f / cb.xTraceResolution.y;
cb.xTraceUserData.x = raytraceBounceCount;
cb.xTraceUserData.y = accumulation_sample;
cb.xTraceRandomSeed = (accumulation_sample + 1) * 0.0001f;
cb.xTraceRandomSeed = wiRandom::getRandom(1000000) / 1000000.f;
device->UpdateBuffer(&constantBuffers[CBTYPE_RAYTRACE], &cb, cmd);
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_RAYTRACE], CB_GETBINDSLOT(RaytracingCB), cmd);
@@ -8277,7 +8277,7 @@ void RenderObjectLightMap(const Scene& scene, const ObjectComponent& object, Com
cb.xTracePixelOffset.y = (halton.y * 2 - 1) * cb.xTraceResolution_rcp.y;
cb.xTracePixelOffset.x *= 1.4f; // boost the jitter by a bit
cb.xTracePixelOffset.y *= 1.4f; // boost the jitter by a bit
cb.xTraceRandomSeed = (lightmapIterationCount + 1) * 0.0001f; // random seed
cb.xTraceRandomSeed = wiRandom::getRandom(1000000) / 1000000.f;
cb.xTraceAccumulationFactor = 1.0f / (lightmapIterationCount + 1.0f); // accumulation factor (alpha)
cb.xTraceUserData.x = raytraceBounceCount;
device->UpdateBuffer(&constantBuffers[CBTYPE_RAYTRACE], &cb, cmd);
@@ -8435,6 +8435,10 @@ void UpdateCameraCB(
XMStoreFloat4x4(&cb.g_xCamera_PrevInvVP, camera_previous.GetInvViewProjection());
XMStoreFloat4x4(&cb.g_xCamera_ReflVP, camera_reflection.GetViewProjection());
cb.g_xCamera_FocalLength = camera.focal_length;
cb.g_xCamera_ApertureSize = camera.aperture_size;
cb.g_xCamera_ApertureShape = camera.aperture_shape;
device->UpdateBuffer(&constantBuffers[CBTYPE_CAMERA], &cb, cmd);
}
@@ -10651,9 +10655,7 @@ void Postprocess_DepthOfField(
const Texture& output,
const Texture& lineardepth,
CommandList cmd,
float focus,
float scale,
float aspect,
float coc_scale,
float max_coc
)
{
@@ -10669,9 +10671,7 @@ void Postprocess_DepthOfField(
cb.xPPResolution.y = desc.Height;
cb.xPPResolution_rcp.x = 1.0f / cb.xPPResolution.x;
cb.xPPResolution_rcp.y = 1.0f / cb.xPPResolution.y;
cb.dof_focus = focus;
cb.dof_scale = scale;
cb.dof_aspect = aspect;
cb.dof_cocscale = coc_scale;
cb.dof_maxcoc = max_coc;
device->UpdateBuffer(&constantBuffers[CBTYPE_POSTPROCESS], &cb, cmd);
device->BindConstantBuffer(CS, &constantBuffers[CBTYPE_POSTPROCESS], CB_GETBINDSLOT(PostProcessCB), cmd);
+2 -4
View File
@@ -490,10 +490,8 @@ namespace wiRenderer
const wiGraphics::Texture& output,
const wiGraphics::Texture& lineardepth,
wiGraphics::CommandList cmd,
float focus = 10.0f,
float scale = 1.0f,
float aspect = 1.0f,
float max_coc = 18.0f
float coc_scale = 10,
float max_coc = 18
);
void Postprocess_Outline(
const wiGraphics::Texture& input,
+3
View File
@@ -892,6 +892,9 @@ namespace wiScene
float zNearP = 0.1f;
float zFarP = 800.0f;
float fov = XM_PI / 3.0f;
float focal_length = 1;
float aperture_size = 0;
XMFLOAT2 aperture_shape = XMFLOAT2(1, 1);
// Non-serialized attributes:
XMFLOAT3 Eye = XMFLOAT3(0, 0, 0);
+64
View File
@@ -1477,6 +1477,12 @@ Luna<CameraComponent_BindLua>::FunctionType CameraComponent_BindLua::methods[] =
lunamethod(CameraComponent_BindLua, SetNearPlane),
lunamethod(CameraComponent_BindLua, GetFarPlane),
lunamethod(CameraComponent_BindLua, SetFarPlane),
lunamethod(CameraComponent_BindLua, GetFocalLength),
lunamethod(CameraComponent_BindLua, SetFocalLength),
lunamethod(CameraComponent_BindLua, GetApertureSize),
lunamethod(CameraComponent_BindLua, SetApertureSize),
lunamethod(CameraComponent_BindLua, GetApertureShape),
lunamethod(CameraComponent_BindLua, SetApertureShape),
lunamethod(CameraComponent_BindLua, GetView),
lunamethod(CameraComponent_BindLua, GetProjection),
lunamethod(CameraComponent_BindLua, GetViewProjection),
@@ -1583,6 +1589,64 @@ int CameraComponent_BindLua::SetFarPlane(lua_State* L)
}
return 0;
}
int CameraComponent_BindLua::GetFocalLength(lua_State* L)
{
wiLua::SSetFloat(L, component->focal_length);
return 1;
}
int CameraComponent_BindLua::SetFocalLength(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
component->focal_length = wiLua::SGetFloat(L, 1);
}
else
{
wiLua::SError(L, "SetFocalLength(float value) not enough arguments!");
}
return 0;
}
int CameraComponent_BindLua::GetApertureSize(lua_State* L)
{
wiLua::SSetFloat(L, component->aperture_size);
return 1;
}
int CameraComponent_BindLua::SetApertureSize(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
component->aperture_size = wiLua::SGetFloat(L, 1);
}
else
{
wiLua::SError(L, "SetApertureSize(float value) not enough arguments!");
}
return 0;
}
int CameraComponent_BindLua::GetApertureShape(lua_State* L)
{
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat2(&component->aperture_shape)));
return 1;
}
int CameraComponent_BindLua::SetApertureShape(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* param = Luna<Vector_BindLua>::lightcheck(L, 1);
if (param != nullptr)
{
XMStoreFloat2(&component->aperture_shape, param->vector);
}
}
else
{
wiLua::SError(L, "SetApertureShape(Vector value) not enough arguments!");
}
return 0;
}
int CameraComponent_BindLua::GetView(lua_State* L)
{
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(component->GetView()));
+6
View File
@@ -167,6 +167,12 @@ namespace wiScene_BindLua
int SetNearPlane(lua_State* L);
int GetFarPlane(lua_State* L);
int SetFarPlane(lua_State* L);
int GetFocalLength(lua_State* L);
int SetFocalLength(lua_State* L);
int GetApertureSize(lua_State* L);
int SetApertureSize(lua_State* L);
int GetApertureShape(lua_State* L);
int SetApertureShape(lua_State* L);
int GetView(lua_State* L);
int GetProjection(lua_State* L);
int GetViewProjection(lua_State* L);
+14
View File
@@ -749,6 +749,13 @@ namespace wiScene
archive >> zFarP;
archive >> fov;
if (archive.GetVersion() >= 65)
{
archive >> focal_length;
archive >> aperture_size;
archive >> aperture_shape;
}
SetDirty();
}
else
@@ -759,6 +766,13 @@ namespace wiScene
archive << zNearP;
archive << zFarP;
archive << fov;
if (archive.GetVersion() >= 65)
{
archive << focal_length;
archive << aperture_size;
archive << aperture_shape;
}
}
}
void EnvironmentProbeComponent::Serialize(wiArchive& archive, EntitySerializer& seri)
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates, breaking compatibility changes
const int minor = 55;
// minor bug fixes, alterations, refactors, updates
const int revision = 12;
const int revision = 13;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);