added CRT effect option for camera feed
This commit is contained in:
@@ -242,6 +242,13 @@ void CameraComponentWindow::Create(EditorComponent* _editor)
|
||||
}));
|
||||
AddWidget(&samplecountSlider);
|
||||
|
||||
crtCheckbox.Create("CRT: ");
|
||||
crtCheckbox.SetTooltip("Toggle CRT TV mode for this camera (when render to texture is enabled)");
|
||||
crtCheckbox.OnClick(forEachSelectedCameraComponent([](auto camera, auto args) {
|
||||
camera->SetCRT(args.bValue);
|
||||
}));
|
||||
AddWidget(&crtCheckbox);
|
||||
|
||||
|
||||
AddWidget(&preview);
|
||||
|
||||
@@ -275,6 +282,7 @@ void CameraComponentWindow::SetEntity(Entity entity)
|
||||
resolutionXSlider.SetValue((int)camera->render_to_texture.resolution.x);
|
||||
resolutionYSlider.SetValue((int)camera->render_to_texture.resolution.y);
|
||||
samplecountSlider.SetValue((int)camera->render_to_texture.sample_count);
|
||||
crtCheckbox.SetCheck(camera->IsCRT());
|
||||
|
||||
preview.entity = entity;
|
||||
preview.renderpath.scene = &scene;
|
||||
@@ -311,16 +319,19 @@ void CameraComponentWindow::ResizeLayout()
|
||||
resolutionXSlider.SetVisible(true);
|
||||
resolutionYSlider.SetVisible(true);
|
||||
samplecountSlider.SetVisible(true);
|
||||
crtCheckbox.SetVisible(true);
|
||||
|
||||
layout.add(resolutionXSlider);
|
||||
layout.add(resolutionYSlider);
|
||||
layout.add(samplecountSlider);
|
||||
layout.add_right(crtCheckbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
resolutionXSlider.SetVisible(false);
|
||||
resolutionYSlider.SetVisible(false);
|
||||
samplecountSlider.SetVisible(false);
|
||||
crtCheckbox.SetVisible(false);
|
||||
}
|
||||
|
||||
layout.jump();
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
wi::gui::Slider resolutionXSlider;
|
||||
wi::gui::Slider resolutionYSlider;
|
||||
wi::gui::Slider samplecountSlider;
|
||||
wi::gui::CheckBox crtCheckbox;
|
||||
|
||||
CameraPreview preview;
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
|
||||
float2 uv = (DTid.xy + 0.5) * postprocess.resolution_rcp.xy;
|
||||
//uv = Warp(uv);
|
||||
color.rgb=Tri(uv)*Mask(DTid.xy);
|
||||
color.rgb *= 1 + sin(GetTime() * 100) * postprocess.params0.x;
|
||||
color.rgb=ToSrgb(color.rgb);
|
||||
|
||||
output[DTid.xy] = color;
|
||||
|
||||
@@ -2642,7 +2642,7 @@ namespace wi
|
||||
|
||||
wi::jobsystem::Execute(ctx, [this, cmd, i](wi::jobsystem::JobArgs args) {
|
||||
GraphicsDevice* device = GetDevice();
|
||||
const wi::scene::CameraComponent& camera = scene->cameras[i]; // reload, not captured in lambda (alloc)
|
||||
wi::scene::CameraComponent& camera = scene->cameras[i]; // reload, not captured in lambda (alloc)
|
||||
wi::renderer::Visibility& visibility = *(wi::renderer::Visibility*)camera.render_to_texture.visibility.get();
|
||||
visibility.layerMask = getLayerMask();
|
||||
visibility.scene = scene;
|
||||
@@ -2728,6 +2728,12 @@ namespace wi
|
||||
wi::renderer::DrawLightVisualizers(visibility, cmd);
|
||||
device->RenderPassEnd(cmd);
|
||||
|
||||
if (camera.IsCRT() && getSceneUpdateEnabled())
|
||||
{
|
||||
wi::renderer::Postprocess_CRT(camera.render_to_texture.rendertarget_render, camera.render_to_texture.rendertarget_display, cmd, 0.2f);
|
||||
std::swap(camera.render_to_texture.rendertarget_render, camera.render_to_texture.rendertarget_display);
|
||||
}
|
||||
|
||||
wi::renderer::GenerateMipChain(camera.render_to_texture.rendertarget_render, wi::renderer::MIPGENFILTER_LINEAR, cmd);
|
||||
}
|
||||
device->EventEnd(cmd);
|
||||
|
||||
@@ -16850,7 +16850,8 @@ void Postprocess_Sharpen(
|
||||
void Postprocess_CRT(
|
||||
const Texture& input,
|
||||
const Texture& output,
|
||||
CommandList cmd
|
||||
CommandList cmd,
|
||||
float flicker
|
||||
)
|
||||
{
|
||||
ScopedGPUProfiling("Postprocess_CRT", cmd);
|
||||
@@ -16867,6 +16868,7 @@ void Postprocess_CRT(
|
||||
postprocess.resolution.y = desc.height;
|
||||
postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x;
|
||||
postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y;
|
||||
postprocess.params0.x = flicker;
|
||||
device->PushConstants(&postprocess, sizeof(postprocess), cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
|
||||
@@ -848,7 +848,8 @@ namespace wi::renderer
|
||||
void Postprocess_CRT(
|
||||
const wi::graphics::Texture& input,
|
||||
const wi::graphics::Texture& output,
|
||||
wi::graphics::CommandList cmd
|
||||
wi::graphics::CommandList cmd,
|
||||
float flicker = 0
|
||||
);
|
||||
enum class Tonemap
|
||||
{
|
||||
|
||||
@@ -1408,6 +1408,7 @@ namespace wi::scene
|
||||
DIRTY = 1 << 0,
|
||||
CUSTOM_PROJECTION = 1 << 1,
|
||||
ORTHO = 1 << 2,
|
||||
CRT_FILTER = 1 << 3,
|
||||
};
|
||||
uint32_t _flags = EMPTY;
|
||||
|
||||
@@ -1496,9 +1497,11 @@ namespace wi::scene
|
||||
constexpr void SetDirty(bool value = true) { if (value) { _flags |= DIRTY; } else { _flags &= ~DIRTY; } }
|
||||
constexpr void SetCustomProjectionEnabled(bool value = true) { if (value) { _flags |= CUSTOM_PROJECTION; } else { _flags &= ~CUSTOM_PROJECTION; } }
|
||||
constexpr void SetOrtho(bool value = true) { if (value) { _flags |= ORTHO; } else { _flags &= ~ORTHO; } SetDirty(); }
|
||||
constexpr void SetCRT(bool value = true) { if (value) { _flags |= CRT_FILTER; } else { _flags &= ~CRT_FILTER; } SetDirty(); }
|
||||
constexpr bool IsDirty() const { return _flags & DIRTY; }
|
||||
constexpr bool IsCustomProjectionEnabled() const { return _flags & CUSTOM_PROJECTION; }
|
||||
constexpr bool IsOrtho() const { return _flags & ORTHO; }
|
||||
constexpr bool IsCRT() const { return _flags & CRT_FILTER; }
|
||||
|
||||
void Lerp(const CameraComponent& a, const CameraComponent& b, float t);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 826;
|
||||
const int revision = 827;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user