diff --git a/Editor/PostprocessWindow.cpp b/Editor/PostprocessWindow.cpp index a0d8a378c..cb7dc134c 100644 --- a/Editor/PostprocessWindow.cpp +++ b/Editor/PostprocessWindow.cpp @@ -146,13 +146,13 @@ PostprocessWindow::PostprocessWindow(wiGUI* gui, RenderPath3D* comp) : GUI(gui), }); ppWindow->AddWidget(bloomCheckBox); - bloomStrengthSlider = new wiSlider(0.0f, 40, 10, 1000, "Radius: "); - bloomStrengthSlider->SetTooltip("Set bloom strength."); + bloomStrengthSlider = new wiSlider(0.0f, 10, 1, 1000, "Threshold: "); + bloomStrengthSlider->SetTooltip("Set bloom threshold. The values below this will not glow on the screen."); bloomStrengthSlider->SetSize(XMFLOAT2(100, 20)); bloomStrengthSlider->SetPos(XMFLOAT2(x + 100, y)); - bloomStrengthSlider->SetValue(component->getBloomStrength()); + bloomStrengthSlider->SetValue(component->getBloomThreshold()); bloomStrengthSlider->OnSlide([&](wiEventArgs args) { - component->setBloomStrength(args.fValue); + component->setBloomThreshold(args.fValue); }); ppWindow->AddWidget(bloomStrengthSlider); diff --git a/WickedEngine/RenderPath3D.cpp b/WickedEngine/RenderPath3D.cpp index 915cb095b..0ff3b6ef8 100644 --- a/WickedEngine/RenderPath3D.cpp +++ b/WickedEngine/RenderPath3D.cpp @@ -28,8 +28,9 @@ wiRenderTarget , RenderPath3D::rtFinal[2] , RenderPath3D::rtDof[3] , RenderPath3D::rtTemporalAA[2] + , RenderPath3D::rtBloom ; -std::vector RenderPath3D::rtSun, RenderPath3D::rtBloom, RenderPath3D::rtSSAO; +std::vector RenderPath3D::rtSun, RenderPath3D::rtSSAO; wiDepthTarget RenderPath3D::dtDepthCopy; Texture2D* RenderPath3D::smallDepth = nullptr; void RenderPath3D::ResizeBuffers() @@ -121,15 +122,7 @@ void RenderPath3D::ResizeBuffers() , false, defaultTextureFormat ); - rtBloom.resize(3); - rtBloom[0].Initialize( - wiRenderer::GetInternalResolution().x, wiRenderer::GetInternalResolution().y - , false, defaultTextureFormat, 0); - for (unsigned int i = 1; iEventBegin("Temporal AA Resolve", threadID); wiProfiler::BeginRange("Temporal AA Resolve", wiProfiler::DOMAIN_GPU, threadID); + fx.enableHDR(); fx.blendFlag = BLENDMODE_OPAQUE; int current = wiRenderer::GetDevice()->GetFrameCount() % 2 == 0 ? 0 : 1; int history = 1 - current; @@ -494,6 +484,7 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg wiImage::Draw(rtTemporalAA[current].GetTexture(), fx, threadID); fx.disableFullScreen(); } + fx.disableHDR(); wiProfiler::EndRange(threadID); wiRenderer::GetDevice()->EventEnd(threadID); } @@ -501,42 +492,34 @@ void RenderPath3D::RenderComposition(wiRenderTarget& shadedSceneRT, wiRenderTarg if (getBloomEnabled()) { wiRenderer::GetDevice()->EventBegin("Bloom", threadID); + fx.setMaskMap(nullptr); fx.process.clear(); fx.disableFullScreen(); fx.quality = QUALITY_BILINEAR; - rtBloom[0].Set(threadID); // separate bright parts + fx.blendFlag = BLENDMODE_OPAQUE; + fx.sampleFlag = SAMPLEMODE_CLAMP; + rtBloom.Set(threadID); // separate bright parts { - fx.process.setBloom(getBloomThreshold(), getBloomSaturation()); - fx.blendFlag = BLENDMODE_OPAQUE; - fx.sampleFlag = SAMPLEMODE_CLAMP; + fx.process.setBloom(getBloomThreshold()); wiImage::Draw(shadedSceneRT.GetTextureResolvedMSAA(threadID), fx, threadID); + wiRenderer::GetDevice()->UnbindResources(TEXSLOT_ONDEMAND0, 1, threadID); } fx.process.clear(); - wiRenderer::GenerateMipChain(rtBloom[0].GetTexture(), wiRenderer::MIPGENFILTER_LINEAR, threadID); - - rtBloom[1].Set(threadID); //horizontal - { - fx.mipLevel = 5.32f; - fx.process.setBlur(XMFLOAT2(getBloomStrength(), 0)); - fx.blendFlag = BLENDMODE_OPAQUE; - wiImage::Draw(rtBloom[0].GetTexture(), fx, threadID); - } - rtBloom[2].Set(threadID); //vertical - { - fx.process.setBlur(XMFLOAT2(0, getBloomStrength())); - fx.blendFlag = BLENDMODE_OPAQUE; - wiImage::Draw(rtBloom[1].GetTexture(), fx, threadID); - } - fx.process.clear(); - + wiRenderer::GenerateMipChain(rtBloom.GetTexture(), wiRenderer::MIPGENFILTER_GAUSSIAN, threadID); shadedSceneRT.Set(threadID, false, 0); { // add to the scene fx.blendFlag = BLENDMODE_ADDITIVE; - fx.enableFullScreen(); + //fx.quality = QUALITY_BICUBIC; fx.process.clear(); - wiImage::Draw(rtBloom.back().GetTexture(), fx, threadID); - fx.disableFullScreen(); + fx.mipLevel = 1.5f; + wiImage::Draw(rtBloom.GetTexture(), fx, threadID); + fx.mipLevel = 3.5f; + wiImage::Draw(rtBloom.GetTexture(), fx, threadID); + fx.mipLevel = 5.5f; + wiImage::Draw(rtBloom.GetTexture(), fx, threadID); + fx.quality = QUALITY_BILINEAR; } + wiRenderer::GetDevice()->EventEnd(threadID); } diff --git a/WickedEngine/RenderPath3D.h b/WickedEngine/RenderPath3D.h index 041e9005f..65ac82848 100644 --- a/WickedEngine/RenderPath3D.h +++ b/WickedEngine/RenderPath3D.h @@ -9,10 +9,7 @@ class RenderPath3D : private: float exposure = 1.0f; float lightShaftQuality; - float bloomDownSample; - float bloomStren; float bloomThreshold; - float bloomSaturation; float particleDownSample; float reflectionQuality; float ssaoQuality; @@ -59,8 +56,9 @@ protected: , rtFinal[2] , rtDof[3] , rtTemporalAA[2] + , rtBloom ; - static std::vector rtSun, rtBloom, rtSSAO; + static std::vector rtSun, rtSSAO; static wiGraphicsTypes::Texture2D* depthBuffer; static wiDepthTarget dtDepthCopy; static wiGraphicsTypes::Texture2D* smallDepth; @@ -80,10 +78,7 @@ public: inline float getExposure() { return exposure; } inline float getLightShaftQuality(){ return lightShaftQuality; } - inline float getBloomDownSample(){ return bloomDownSample; } - inline float getBloomStrength(){ return bloomStren; } inline float getBloomThreshold(){ return bloomThreshold; } - inline float getBloomSaturation(){ return bloomSaturation; } inline float getParticleDownSample(){ return particleDownSample; } inline float getReflectionQuality(){ return reflectionQuality; } inline float getSSAOQuality(){ return ssaoQuality; } @@ -119,10 +114,7 @@ public: inline void setExposure(float value) { exposure = value; } inline void setLightShaftQuality(float value){ lightShaftQuality = value; } - inline void setBloomDownSample(float value){ bloomDownSample = value; } - inline void setBloomStrength(float value){ bloomStren = value; } inline void setBloomThreshold(float value){ bloomThreshold = value; } - inline void setBloomSaturation(float value){ bloomSaturation = value; } inline void setParticleDownSample(float value){ particleDownSample = value; } inline void setReflectionQuality(float value){ reflectionQuality = value; } inline void setSSAOQuality(float value){ ssaoQuality = value; } diff --git a/WickedEngine/WickedEngine_SHADERS.vcxproj b/WickedEngine/WickedEngine_SHADERS.vcxproj index 86111caca..48ff97cdb 100644 --- a/WickedEngine/WickedEngine_SHADERS.vcxproj +++ b/WickedEngine/WickedEngine_SHADERS.vcxproj @@ -329,6 +329,26 @@ Compute 5.0 + + Pixel + 5.0 + + + Pixel + 5.0 + + + Pixel + 5.0 + + + Pixel + 5.0 + + + Pixel + 5.0 + Pixel @@ -688,6 +708,10 @@ Pixel + + Pixel + 5.0 + Vertex diff --git a/WickedEngine/WickedEngine_SHADERS.vcxproj.filters b/WickedEngine/WickedEngine_SHADERS.vcxproj.filters index 11d61f2bc..9ab451eae 100644 --- a/WickedEngine/WickedEngine_SHADERS.vcxproj.filters +++ b/WickedEngine/WickedEngine_SHADERS.vcxproj.filters @@ -843,6 +843,24 @@ PS + + PS + + + PS + + + PS + + + PS + + + PS + + + PS + diff --git a/WickedEngine/bloomSeparatePS.hlsl b/WickedEngine/bloomSeparatePS.hlsl index 528d5168a..4dac4c748 100644 --- a/WickedEngine/bloomSeparatePS.hlsl +++ b/WickedEngine/bloomSeparatePS.hlsl @@ -1,7 +1,24 @@ #include "postProcessHF.hlsli" +// This will cut out bright parts (>1) and also downsample 4x float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET { - return max(float4(xTexture.SampleLevel(Sampler,PSIn.tex,0).rgb - 1,1), 0); + float2 dim; + xTexture.GetDimensions(dim.x, dim.y); + dim = 1.0 / dim; + + float3 color = 0; + + color += xTexture.SampleLevel(sampler_linear_clamp, PSIn.tex + float2(-1, -1) * dim, 0).rgb; + color += xTexture.SampleLevel(sampler_linear_clamp, PSIn.tex + float2(1, -1) * dim, 0).rgb; + color += xTexture.SampleLevel(sampler_linear_clamp, PSIn.tex + float2(-1, 1) * dim, 0).rgb; + color += xTexture.SampleLevel(sampler_linear_clamp, PSIn.tex + float2(1, 1) * dim, 0).rgb; + + color /= 4.0f; + + const float bloomThreshold = xPPParams0.x; + color = max(0, color - bloomThreshold); + + return float4(color, 1); } \ No newline at end of file diff --git a/WickedEngine/generateMIPChain2D_float4_GaussianCS.hlsl b/WickedEngine/generateMIPChain2D_float4_GaussianCS.hlsl index 4e070e47b..dd0b77863 100644 --- a/WickedEngine/generateMIPChain2D_float4_GaussianCS.hlsl +++ b/WickedEngine/generateMIPChain2D_float4_GaussianCS.hlsl @@ -6,13 +6,13 @@ #endif TEXTURE2D(input, float4, TEXSLOT_UNIQUE0); -RWTEXTURE2D(input_output, MIP_OUTPUT_FORMAT, 0); +RWTEXTURE2D(output, MIP_OUTPUT_FORMAT, 0); static const uint TILE_BORDER = 4; static const uint TILE_SIZE = TILE_BORDER + GENERATEMIPCHAIN_2D_BLOCK_SIZE + TILE_BORDER; groupshared float4 tile[TILE_SIZE * TILE_SIZE]; -#define FAKE_GAUSS // this is not completely correct, but two-pass, so faster +//#define FAKE_GAUSS // this is not completely correct, but two-pass, so faster [numthreads(GENERATEMIPCHAIN_2D_BLOCK_SIZE, GENERATEMIPCHAIN_2D_BLOCK_SIZE, 1)] void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID) @@ -20,15 +20,16 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 uint i; // First, we prewarm the tile cache, including border region: - const uint2 tile_upperleft = Gid.xy * GENERATEMIPCHAIN_2D_BLOCK_SIZE - TILE_BORDER; - const uint2 co[] = { + const int2 tile_upperleft = Gid.xy * GENERATEMIPCHAIN_2D_BLOCK_SIZE - TILE_BORDER; + const int2 co[] = { uint2(0, 0), uint2(1, 0), uint2(0, 1), uint2(1, 1) }; for (i = 0; i < 4; ++i) { - const uint2 coord = GTid.xy * 2 + co[i]; - tile[flatten2D(coord, TILE_SIZE)] = input.SampleLevel(sampler_linear_clamp, (tile_upperleft + coord + 0.5f) / (float2)outputResolution.xy, 0); + const int2 coord = GTid.xy * 2 + co[i]; + const float2 uv = (tile_upperleft + coord + 0.5f) / (float2)outputResolution.xy; + tile[flatten2D(coord, TILE_SIZE)] = input.SampleLevel(sampler_linear_clamp, uv, 0); } GroupMemoryBarrierWithGroupSync(); @@ -75,12 +76,16 @@ void main(uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint3 sum += sumY * gaussianWeightsNormalized[i]; } -#endif // FAST_GAUSS +#endif // FAKE_GAUSS if (DTid.x < outputResolution.x && DTid.y < outputResolution.y) { // Each valid thread writes out one pixel: - input_output[DTid.xy] = sum; + output[DTid.xy] = sum; + + //const int2 a = max(TILE_BORDER, Gid.xy * GENERATEMIPCHAIN_2D_BLOCK_SIZE) - TILE_BORDER; + //const int2 b = Gid.xy * GENERATEMIPCHAIN_2D_BLOCK_SIZE - TILE_BORDER; + //output[DTid.xy] = float4((a-b) / (float2)outputResolution, 0, 1); } } \ No newline at end of file diff --git a/WickedEngine/globals.hlsli b/WickedEngine/globals.hlsli index c0c503095..ff92c2a63 100644 --- a/WickedEngine/globals.hlsli +++ b/WickedEngine/globals.hlsli @@ -184,7 +184,7 @@ inline float3 UV_to_CubeMap(in float2 uv, in uint faceIndex) // Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16. ( https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1#file-tex2dcatmullrom-hlsl ) // See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details -float4 SampleTextureCatmullRom(in Texture2D tex, in float2 uv) +float4 SampleTextureCatmullRom(in Texture2D tex, in float2 uv, in float mipLevel = 0) { float2 texSize; tex.GetDimensions(texSize.x, texSize.y); @@ -222,17 +222,17 @@ float4 SampleTextureCatmullRom(in Texture2D tex, in float2 uv) texPos12 /= texSize; float4 result = 0.0f; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos0.y), 0.0f) * w0.x * w0.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos0.y), 0.0f) * w12.x * w0.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos0.y), 0.0f) * w3.x * w0.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos0.y), mipLevel) * w0.x * w0.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos0.y), mipLevel) * w12.x * w0.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos0.y), mipLevel) * w3.x * w0.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos12.y), 0.0f) * w0.x * w12.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos12.y), 0.0f) * w12.x * w12.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos12.y), 0.0f) * w3.x * w12.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos12.y), mipLevel) * w0.x * w12.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos12.y), mipLevel) * w12.x * w12.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos12.y), mipLevel) * w3.x * w12.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos3.y), 0.0f) * w0.x * w3.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos3.y), 0.0f) * w12.x * w3.y; - result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos3.y), 0.0f) * w3.x * w3.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos0.x, texPos3.y), mipLevel) * w0.x * w3.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos12.x, texPos3.y), mipLevel) * w12.x * w3.y; + result += tex.SampleLevel(sampler_linear_clamp, float2(texPos3.x, texPos3.y), mipLevel) * w3.x * w3.y; return result; } diff --git a/WickedEngine/imagePS_bicubic.hlsl b/WickedEngine/imagePS_bicubic.hlsl new file mode 100644 index 000000000..74315661b --- /dev/null +++ b/WickedEngine/imagePS_bicubic.hlsl @@ -0,0 +1,8 @@ +#include "imageHF.hlsli" + +float4 main(VertextoPixel PSIn) : SV_TARGET +{ + float4 color = SampleTextureCatmullRom(xTexture, PSIn.tex.xy, xMipLevel) * xColor; + + return color; +} \ No newline at end of file diff --git a/WickedEngine/imagePS_distortion_bicubic.hlsl b/WickedEngine/imagePS_distortion_bicubic.hlsl new file mode 100644 index 000000000..8791d7a12 --- /dev/null +++ b/WickedEngine/imagePS_distortion_bicubic.hlsl @@ -0,0 +1,12 @@ +#include "imageHF.hlsli" + +float4 main(VertextoPixel PSIn) : SV_TARGET +{ + float2 distortionCo = PSIn.pos2D.xy / PSIn.pos2D.w * float2(0.5f, -0.5f) + 0.5f; + float2 distort = xDistortionTex.SampleLevel(Sampler, PSIn.tex.xy, 0).rg * 2 - 1; + PSIn.tex.xy = distortionCo + distort; + + float4 color = SampleTextureCatmullRom(xTexture, PSIn.tex.xy, xMipLevel) * xColor; + + return color; +} \ No newline at end of file diff --git a/WickedEngine/imagePS_distortion_masked_bicubic.hlsl b/WickedEngine/imagePS_distortion_masked_bicubic.hlsl new file mode 100644 index 000000000..44065dcab --- /dev/null +++ b/WickedEngine/imagePS_distortion_masked_bicubic.hlsl @@ -0,0 +1,14 @@ +#include "imageHF.hlsli" + +float4 main(VertextoPixel PSIn) : SV_TARGET +{ + float2 distortionCo = PSIn.pos2D.xy / PSIn.pos2D.w * float2(0.5f, -0.5f) + 0.5f; + float2 distort = xDistortionTex.SampleLevel(Sampler, PSIn.tex.xy, 0).rg * 2 - 1; + PSIn.tex.xy = distortionCo + distort; + + float4 color = SampleTextureCatmullRom(xTexture, PSIn.tex.xy, xMipLevel) * xColor; + + color *= xMaskTex.SampleLevel(Sampler, PSIn.tex.xy, xMipLevel); + + return color; +} \ No newline at end of file diff --git a/WickedEngine/imagePS_masked_bicubic.hlsl b/WickedEngine/imagePS_masked_bicubic.hlsl new file mode 100644 index 000000000..8fbc3278c --- /dev/null +++ b/WickedEngine/imagePS_masked_bicubic.hlsl @@ -0,0 +1,10 @@ +#include "imageHF.hlsli" + +float4 main(VertextoPixel PSIn) : SV_TARGET +{ + float4 color = SampleTextureCatmullRom(xTexture, PSIn.tex.xy, xMipLevel) * xColor; + + color *= xMaskTex.SampleLevel(Sampler, PSIn.tex_original.xy, xMipLevel); + + return color; +} \ No newline at end of file diff --git a/WickedEngine/imagePS_separatenormalmap_bicubic.hlsl b/WickedEngine/imagePS_separatenormalmap_bicubic.hlsl new file mode 100644 index 000000000..a1ec88672 --- /dev/null +++ b/WickedEngine/imagePS_separatenormalmap_bicubic.hlsl @@ -0,0 +1,12 @@ +#include "imageHF.hlsli" + +float4 main(VertextoPixel PSIn) : SV_TARGET +{ + float4 color = SampleTextureCatmullRom(xTexture, PSIn.tex.xy, xMipLevel); + + color = 2 * color - 1; + + color *= xColor; + + return color; +} \ No newline at end of file diff --git a/WickedEngine/screenPS_bicubic.hlsl b/WickedEngine/screenPS_bicubic.hlsl new file mode 100644 index 000000000..866e3792f --- /dev/null +++ b/WickedEngine/screenPS_bicubic.hlsl @@ -0,0 +1,6 @@ +#include "imageHF.hlsli" + +float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET +{ + return SampleTextureCatmullRom(xTexture, PSIn.tex, 0); +} \ No newline at end of file diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp index 1bce33d69..e45c08dcc 100644 --- a/WickedEngine/wiImage.cpp +++ b/WickedEngine/wiImage.cpp @@ -32,12 +32,18 @@ namespace wiImage IMAGE_HDR_ENABLED, IMAGE_HDR_COUNT }; + enum IMAGE_SAMPLING + { + IMAGE_SAMPLING_SIMPLE, + IMAGE_SAMPLING_BICUBIC, + IMAGE_SAMPLING_COUNT, + }; GPUBuffer constantBuffer; GPUBuffer processCb; VertexShader* vertexShader = nullptr; VertexShader* screenVS = nullptr; - PixelShader* imagePS[IMAGE_SHADER_COUNT]; + PixelShader* imagePS[IMAGE_SHADER_COUNT][IMAGE_SAMPLING_COUNT]; PixelShader* postprocessPS[wiImageParams::PostProcess::POSTPROCESS_COUNT]; PixelShader* deferredPS = nullptr; BlendState blendStates[BLENDMODE_COUNT]; @@ -45,7 +51,7 @@ namespace wiImage DepthStencilState depthStencilStates[STENCILMODE_COUNT]; BlendState blendStateDisableColor; DepthStencilState depthStencilStateDepthWrite; - GraphicsPSO imagePSO[IMAGE_SHADER_COUNT][BLENDMODE_COUNT][STENCILMODE_COUNT][IMAGE_HDR_COUNT]; + GraphicsPSO imagePSO[IMAGE_SHADER_COUNT][BLENDMODE_COUNT][STENCILMODE_COUNT][IMAGE_HDR_COUNT][IMAGE_SAMPLING_COUNT]; GraphicsPSO postprocessPSO[wiImageParams::PostProcess::POSTPROCESS_COUNT]; GraphicsPSO deferredPSO; @@ -68,6 +74,8 @@ namespace wiImage device->BindStencilRef(params.stencilRef, threadID); + IMAGE_SAMPLING sampling_type = params.quality == QUALITY_BICUBIC ? IMAGE_SAMPLING_BICUBIC : IMAGE_SAMPLING_SIMPLE; + if (params.quality == QUALITY_NEAREST) { if (params.sampleFlag == SAMPLEMODE_MIRROR) @@ -98,7 +106,7 @@ namespace wiImage if (params.isFullScreenEnabled()) { - device->BindGraphicsPSO(&imagePSO[IMAGE_SHADER_FULLSCREEN][params.blendFlag][params.stencilComp][params.isHDREnabled()], threadID); + device->BindGraphicsPSO(&imagePSO[IMAGE_SHADER_FULLSCREEN][params.blendFlag][params.stencilComp][params.isHDREnabled()][sampling_type], threadID); device->Draw(3, 0, threadID); device->EventEnd(threadID); return; @@ -213,7 +221,7 @@ namespace wiImage } } - device->BindGraphicsPSO(&imagePSO[targetShader][params.blendFlag][params.stencilComp][params.isHDREnabled()], threadID); + device->BindGraphicsPSO(&imagePSO[targetShader][params.blendFlag][params.stencilComp][params.isHDREnabled()][sampling_type], threadID); fullScreenEffect = false; } @@ -251,8 +259,7 @@ namespace wiImage case wiImageParams::PostProcess::MOTIONBLUR: break; case wiImageParams::PostProcess::BLOOMSEPARATE: - prcb.xPPParams1.y = params.process.params.bloom.threshold; - prcb.xPPParams1.z = params.process.params.bloom.saturation; + prcb.xPPParams0.x = params.process.params.bloomThreshold; device->UpdateBuffer(&processCb, &prcb, threadID); break; case wiImageParams::PostProcess::FXAA: @@ -334,12 +341,19 @@ namespace wiImage vertexShader = static_cast(wiResourceManager::GetShaderManager().add(path + "imageVS.cso", wiResourceManager::VERTEXSHADER)); screenVS = static_cast(wiResourceManager::GetShaderManager().add(path + "screenVS.cso", wiResourceManager::VERTEXSHADER)); - imagePS[IMAGE_SHADER_STANDARD] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS.cso", wiResourceManager::PIXELSHADER)); - imagePS[IMAGE_SHADER_SEPARATENORMALMAP] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap.cso", wiResourceManager::PIXELSHADER)); - imagePS[IMAGE_SHADER_DISTORTION] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion.cso", wiResourceManager::PIXELSHADER)); - imagePS[IMAGE_SHADER_DISTORTION_MASKED] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked.cso", wiResourceManager::PIXELSHADER)); - imagePS[IMAGE_SHADER_MASKED] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_masked.cso", wiResourceManager::PIXELSHADER)); - imagePS[IMAGE_SHADER_FULLSCREEN] = static_cast(wiResourceManager::GetShaderManager().add(path + "screenPS.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_masked.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_SIMPLE] = static_cast(wiResourceManager::GetShaderManager().add(path + "screenPS.cso", wiResourceManager::PIXELSHADER)); + + imagePS[IMAGE_SHADER_STANDARD][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_bicubic.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_SEPARATENORMALMAP][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_separatenormalmap_bicubic.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_DISTORTION][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_bicubic.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_DISTORTION_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_distortion_masked_bicubic.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_MASKED][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "imagePS_masked_bicubic.cso", wiResourceManager::PIXELSHADER)); + imagePS[IMAGE_SHADER_FULLSCREEN][IMAGE_SAMPLING_BICUBIC] = static_cast(wiResourceManager::GetShaderManager().add(path + "screenPS_bicubic.cso", wiResourceManager::PIXELSHADER)); postprocessPS[wiImageParams::PostProcess::BLUR] = static_cast(wiResourceManager::GetShaderManager().add(path + "blurPS.cso", wiResourceManager::PIXELSHADER)); postprocessPS[wiImageParams::PostProcess::LIGHTSHAFT] = static_cast(wiResourceManager::GetShaderManager().add(path + "lightShaftPS.cso", wiResourceManager::PIXELSHADER)); @@ -373,33 +387,38 @@ namespace wiImage { desc.vs = screenVS; } - desc.ps = imagePS[i]; desc.rs = &rasterizerState; desc.pt = TRIANGLESTRIP; - for (int j = 0; j < BLENDMODE_COUNT; ++j) + for (int l = 0; l < IMAGE_SAMPLING_COUNT; ++l) { - desc.bs = &blendStates[j]; - for (int k = 0; k < STENCILMODE_COUNT; ++k) + desc.ps = imagePS[i][l]; + + for (int j = 0; j < BLENDMODE_COUNT; ++j) { - desc.dss = &depthStencilStates[k]; - - if (k == STENCILMODE_DISABLED) + desc.bs = &blendStates[j]; + for (int k = 0; k < STENCILMODE_COUNT; ++k) { - desc.DSFormat = FORMAT_UNKNOWN; + desc.dss = &depthStencilStates[k]; + + if (k == STENCILMODE_DISABLED) + { + desc.DSFormat = FORMAT_UNKNOWN; + } + else + { + desc.DSFormat = wiRenderer::DSFormat_full; + } + + desc.numRTs = 1; + + desc.RTFormats[0] = device->GetBackBufferFormat(); + device->CreateGraphicsPSO(&desc, &imagePSO[i][j][k][0][l]); + + desc.RTFormats[0] = wiRenderer::RTFormat_hdr; + device->CreateGraphicsPSO(&desc, &imagePSO[i][j][k][1][l]); + } - else - { - desc.DSFormat = wiRenderer::DSFormat_full; - } - - desc.numRTs = 1; - - desc.RTFormats[0] = device->GetBackBufferFormat(); - device->CreateGraphicsPSO(&desc, &imagePSO[i][j][k][0]); - - desc.RTFormats[0] = wiRenderer::RTFormat_hdr; - device->CreateGraphicsPSO(&desc, &imagePSO[i][j][k][1]); } } } diff --git a/WickedEngine/wiImage.h b/WickedEngine/wiImage.h index 66f733336..3b2f4ace4 100644 --- a/WickedEngine/wiImage.h +++ b/WickedEngine/wiImage.h @@ -38,6 +38,7 @@ enum QUALITY QUALITY_NEAREST, QUALITY_BILINEAR, QUALITY_ANISOTROPIC, + QUALITY_BICUBIC, QUALITY_COUNT }; enum ImageType @@ -117,11 +118,6 @@ struct wiImageParams union PostProcessParams { - struct Bloom - { - float threshold; - float saturation; - } bloom; struct Blur { float x; @@ -132,12 +128,13 @@ struct wiImageParams float dofStrength; float sharpen; float exposure; + float bloomThreshold; } params; bool isActive() const { return type != DISABLED; } void clear() { type = DISABLED; } void setBlur(const XMFLOAT2& direction) { type = BLUR; params.blur.x = direction.x; params.blur.y = direction.y; } - void setBloom(float threshold, float saturation) { type = BLOOMSEPARATE; params.bloom.saturation = saturation; params.bloom.threshold = threshold; } + void setBloom(float threshold) { type = BLOOMSEPARATE; params.bloomThreshold = threshold; } void setDOF(float value) { if (value > 0) { type = DEPTHOFFIELD; params.dofStrength = value; } } void setMotionBlur() { type = MOTIONBLUR; } void setOutline() { type = OUTLINE; } diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index be2f8e841..86d538d93 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 24; // minor bug fixes, alterations, refactors, updates - const int revision = 21; + const int revision = 22; long GetVersion()