crt shader improvements
This commit is contained in:
@@ -41,12 +41,12 @@ static const float maskLight=1.5;
|
||||
// sRGB to Linear.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToLinear1(float c){return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);}
|
||||
float3 ToLinear(float3 c){return float3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));}
|
||||
float3 ToLinear(float3 c){return postprocess.params0.y ? float3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b)) : c;}
|
||||
|
||||
// Linear to sRGB.
|
||||
// Assuing using sRGB typed textures this should not be needed.
|
||||
float ToSrgb1(float c){return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);}
|
||||
float3 ToSrgb(float3 c){return float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));}
|
||||
float3 ToSrgb(float3 c){return postprocess.params0.y ? float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b)) : c;}
|
||||
|
||||
// Nearest emulated sample given floating point position and texel offset.
|
||||
// Also zero's off screen.
|
||||
@@ -157,7 +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 *= 1 + postprocess.params0.x;
|
||||
color.rgb=ToSrgb(color.rgb);
|
||||
|
||||
output[DTid.xy] = color;
|
||||
|
||||
@@ -2505,7 +2505,7 @@ namespace wi
|
||||
|
||||
if (getCRTFilterEnabled())
|
||||
{
|
||||
wi::renderer::Postprocess_CRT(*rt_read, *rt_write, cmd);
|
||||
wi::renderer::Postprocess_CRT(*rt_read, *rt_write, cmd, 0, 0, true);
|
||||
|
||||
std::swap(rt_read, rt_write);
|
||||
}
|
||||
@@ -2730,7 +2730,7 @@ namespace wi
|
||||
|
||||
if (camera.IsCRT() && getSceneUpdateEnabled())
|
||||
{
|
||||
wi::renderer::Postprocess_CRT(camera.render_to_texture.rendertarget_render, camera.render_to_texture.rendertarget_display, cmd, 0.2f);
|
||||
wi::renderer::Postprocess_CRT(camera.render_to_texture.rendertarget_render, camera.render_to_texture.rendertarget_display, cmd, 0.2f, frameCB.time * 100, false);
|
||||
std::swap(camera.render_to_texture.rendertarget_render, camera.render_to_texture.rendertarget_display);
|
||||
}
|
||||
|
||||
|
||||
@@ -16851,7 +16851,9 @@ void Postprocess_CRT(
|
||||
const Texture& input,
|
||||
const Texture& output,
|
||||
CommandList cmd,
|
||||
float flicker
|
||||
float flicker_amount,
|
||||
float flicker_time,
|
||||
bool srgb
|
||||
)
|
||||
{
|
||||
ScopedGPUProfiling("Postprocess_CRT", cmd);
|
||||
@@ -16868,7 +16870,8 @@ 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;
|
||||
postprocess.params0.x = std::sin(flicker_time) * flicker_amount;
|
||||
postprocess.params0.y = srgb ? 1.0f : 0.0f;
|
||||
device->PushConstants(&postprocess, sizeof(postprocess), cmd);
|
||||
|
||||
const GPUResource* uavs[] = {
|
||||
|
||||
@@ -849,7 +849,9 @@ namespace wi::renderer
|
||||
const wi::graphics::Texture& input,
|
||||
const wi::graphics::Texture& output,
|
||||
wi::graphics::CommandList cmd,
|
||||
float flicker = 0
|
||||
float flicker_amount = 0,
|
||||
float flicker_timer = 0,
|
||||
bool srgb = true // if true, then srgb->linear->crt filter->srgb conversion will be done
|
||||
);
|
||||
enum class Tonemap
|
||||
{
|
||||
|
||||
@@ -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 = 828;
|
||||
const int revision = 829;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user