diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-09-06 14:45:35 +0000 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-09-06 14:56:03 +0000 |
| commit | d36205befa1e2bf45a3c6283ace18259bce12377 (patch) | |
| tree | d2936f5c95f569da81d02a583bbad3fca3bf3428 | |
| parent | ed2691f4385c5ab4dd050beac808a695eed2da45 (diff) | |
ssr
| -rw-r--r-- | data/chess.blend | bin | 9170440 -> 9294348 bytes | |||
| -rw-r--r-- | data/models/chess.glb | bin | 5164648 -> 5150236 bytes | |||
| -rw-r--r-- | shaders/compose.frag | 2 | ||||
| -rw-r--r-- | shaders/compose_with_shadows.frag | 5 | ||||
| -rw-r--r-- | shaders/tone_mapping.frag | 62 | ||||
| -rw-r--r-- | shaders/tone_mapping2.frag | 166 | ||||
| -rw-r--r-- | src/VkChess.cs | 68 | ||||
| -rw-r--r-- | src/deferredPbrRendererBase.cs | 16 | ||||
| -rw-r--r-- | ui/winSSR.crow | 18 |
9 files changed, 201 insertions, 136 deletions
diff --git a/data/chess.blend b/data/chess.blend Binary files differindex 548e173..7f2f5f5 100644 --- a/data/chess.blend +++ b/data/chess.blend diff --git a/data/models/chess.glb b/data/models/chess.glb Binary files differindex bb96743..f2f683b 100644 --- a/data/models/chess.glb +++ b/data/models/chess.glb diff --git a/shaders/compose.frag b/shaders/compose.frag index caaeae3..d1a9554 100644 --- a/shaders/compose.frag +++ b/shaders/compose.frag @@ -7,8 +7,6 @@ layout (set = 0, binding = 0) uniform UBO { mat4 model; mat4 view; vec4 camPos; - float exposure; - float gamma; float prefilteredCubeMipLevels; float scaleIBLAmbient; } ubo; diff --git a/shaders/compose_with_shadows.frag b/shaders/compose_with_shadows.frag index 558a26e..1747768 100644 --- a/shaders/compose_with_shadows.frag +++ b/shaders/compose_with_shadows.frag @@ -7,8 +7,6 @@ layout (set = 0, binding = 0) uniform UBO { mat4 model; mat4 view; vec4 camPos; - float exposure; - float gamma; float prefilteredCubeMipLevels; float scaleIBLAmbient; } ubo; @@ -78,7 +76,6 @@ vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection) vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y); // For presentation, this allows us to disable IBL terms - // For presentation, this allows us to disable IBL terms diffuse *= ubo.scaleIBLAmbient; specular *= ubo.scaleIBLAmbient; @@ -271,5 +268,5 @@ void main() colors = mix(colors, colors * subpassLoad(samplerN_AO, gl_SampleID).a, u_OcclusionStrength); colors += emissive; - outColor = vec4(colors, baseColor.a); + outColor = vec4(colors, 0);//baseColor.a); }
\ No newline at end of file diff --git a/shaders/tone_mapping.frag b/shaders/tone_mapping.frag deleted file mode 100644 index fcbd5e4..0000000 --- a/shaders/tone_mapping.frag +++ /dev/null @@ -1,62 +0,0 @@ -#version 450 -#extension GL_ARB_separate_shader_objects : enable -#extension GL_ARB_shading_language_420pack : enable - -layout (set = 0, binding = 0) uniform UBO { - mat4 projection; - mat4 model; - mat4 view; - vec4 camPos; - float exposure; - float gamma; -} ubo; - -layout (input_attachment_index = 0, set = 1, binding = 4) uniform subpassInputMS samplerHDR; -//layout (set = 0, binding = 8) uniform sampler2D samplerUI; - -layout (location = 0) in vec2 inUV; -layout (location = 0) out vec4 outColor; - -vec3 Uncharted2Tonemap(vec3 color) -{ - const float A = 0.15; - const float B = 0.50; - const float C = 0.10; - const float D = 0.20; - const float E = 0.02; - const float F = 0.30; - const float W = 11.2; - return ((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F; -} - -vec3 tonemap(vec3 color) -{ - vec3 outcol = Uncharted2Tonemap(color.rgb * ubo.exposure); - outcol = outcol * (1.0f / Uncharted2Tonemap(vec3(11.2f))); - return pow(outcol, vec3(1.0f / ubo.gamma)); -} - -vec3 SRGBtoLINEAR(vec3 srgbIn) -{ - #ifdef MANUAL_SRGB - #ifdef SRGB_FAST_APPROXIMATION - return pow(srgbIn.xyz,vec3(2.2)); - #else //SRGB_FAST_APPROXIMATION - vec3 bLess = step(vec3(0.04045),srgbIn.xyz); - return linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); - #endif //SRGB_FAST_APPROXIMATION - #else //MANUAL_SRGB - return srgbIn; - #endif //MANUAL_SRGB -} - -void main() -{ - vec4 hdrColor = subpassLoad(samplerHDR, gl_SampleID); - //vec4 ui = texture(samplerUI, inUV); - //outColor = (hdrColor.a - ui.a) * vec4(SRGBtoLINEAR(tonemap(hdrColor.rgb)), 1.0) + ui; - - vec3 mapped = vec3(1.0) - exp(-hdrColor.rgb * ubo.exposure); - mapped = pow(mapped, vec3(1.0 / ubo.gamma)); - outColor = vec4(mapped, hdrColor.a); -}
\ No newline at end of file diff --git a/shaders/tone_mapping2.frag b/shaders/tone_mapping2.frag index 3bcbe1b..6343912 100644 --- a/shaders/tone_mapping2.frag +++ b/shaders/tone_mapping2.frag @@ -4,69 +4,149 @@ layout(push_constant) uniform PushConsts { float exposure; - float gamma; + float gamma; + float step; + float depthTreshold; + int maxStep; }; vec3 Uncharted2Tonemap(vec3 color) { - const float A = 0.15; - const float B = 0.50; - const float C = 0.10; - const float D = 0.20; - const float E = 0.02; - const float F = 0.30; - const float W = 11.2; - return ((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F; + const float A = 0.15; + const float B = 0.50; + const float C = 0.10; + const float D = 0.20; + const float E = 0.02; + const float F = 0.30; + const float W = 11.2; + return ((color*(A*color+C*B)+D*E)/(color*(A*color+B)+D*F))-E/F; } vec4 tonemap(vec4 color, float exposure, float gamma) { - vec3 outcol = Uncharted2Tonemap(color.rgb * exposure); - outcol = outcol * (1.0f / Uncharted2Tonemap(vec3(11.2f))); - return vec4(pow(outcol, vec3(1.0f / gamma)), color.a); + vec3 outcol = Uncharted2Tonemap(color.rgb * exposure); + outcol = outcol * (1.0f / Uncharted2Tonemap(vec3(11.2f))); + return vec4(pow(outcol, vec3(1.0f / gamma)), color.a); } vec4 SRGBtoLINEAR(vec4 srgbIn) { - #ifdef MANUAL_SRGB - #ifdef SRGB_FAST_APPROXIMATION - vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); - #else //SRGB_FAST_APPROXIMATION - vec3 bLess = step(vec3(0.04045),srgbIn.xyz); - vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); - #endif //SRGB_FAST_APPROXIMATION - return vec4(linOut,srgbIn.w);; - #else //MANUAL_SRGB - return srgbIn; - #endif //MANUAL_SRGB + #ifdef MANUAL_SRGB + #ifdef SRGB_FAST_APPROXIMATION + vec3 linOut = pow(srgbIn.xyz,vec3(2.2)); + #else //SRGB_FAST_APPROXIMATION + vec3 bLess = step(vec3(0.04045),srgbIn.xyz); + vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess ); + #endif //SRGB_FAST_APPROXIMATION + return vec4(linOut,srgbIn.w);; + #else //MANUAL_SRGB + return srgbIn; + #endif //MANUAL_SRGB } +layout (constant_id = 0) const float NEAR_PLANE = 0.1f; +layout (constant_id = 1) const float FAR_PLANE = 32.0f; + layout (set = 0, binding = 0) uniform sampler2D uiImage; layout (set = 0, binding = 1) uniform sampler2D samplerHDR; +layout (set = 0, binding = 2) uniform sampler2D gbPos;//gbuffer world pos + linear depth +layout (set = 0, binding = 3) uniform sampler2D gbN_AO;//gbuffer normal + +layout (set = 0, binding = 4) uniform UBO { + mat4 projection; + mat4 model; + mat4 view; + vec4 camPos; +} ubo; layout (location = 0) in vec2 inUV; layout (location = 0) out vec4 outColor; - + +const float flteps = 0.001; + +bool float_equ (float a, float b) { + return abs(a - b) < flteps; +} + +float linearDepth(float depth) +{ + float z = depth * 2.0f - 1.0f; + return (2.0f * NEAR_PLANE * FAR_PLANE) / (FAR_PLANE + NEAR_PLANE - z * (FAR_PLANE - NEAR_PLANE)); +} + void main() { - //ivec2 ts = textureSize(samplerHDR); - //vec4 hdrColor = texelFetch (samplerHDR, ivec2(gl_FragCoord.xy), gl_SampleID); - - //vec4 hdrColor = texelFetch (samplerHDR, inUV); - //vec4 c = texture (bloom, inUV); - //float lum = (0.299*c.r + 0.587*c.g + 0.114*c.b); - //if (lum>1.0) - // hdrColor.rgb += c.rgb * 0.05; - //outColor = SRGBtoLINEAR(tonemap(hdrColor, exposure, gamma)); - vec4 hdrColor = texture(samplerHDR, inUV); - vec4 uiColor = texture(uiImage, inUV); - outColor = tonemap(hdrColor, exposure, gamma); - outColor = vec4(outColor.rgb * (1 - uiColor.a) + uiColor.rgb * uiColor.a, 1); - - /* - outColor = vec4(SRGBtoLINEAR(tonemap(hdrColor.rgb)), hdrColor.a);;*/ - + const float reflectionCoef = 0.6; + //ivec2 ts = textureSize(samplerHDR, 0); + //vec4 hdrColor = texelFetch (samplerHDR, ivec2(gl_FragCoord.xy), gl_SampleID); + + //vec4 hdrColor = texelFetch (samplerHDR, inUV); + //vec4 c = texture (bloom, inUV); + //float lum = (0.299*c.r + 0.587*c.g + 0.114*c.b); + //if (lum>1.0) + // hdrColor.rgb += c.rgb * 0.05; + //outColor = SRGBtoLINEAR(tonemap(hdrColor, exposure, gamma)); + vec4 hdrColor = texture(samplerHDR, inUV); + vec4 uiColor = texture(uiImage, inUV); + vec3 pos = texture(gbPos, inUV).rgb; + float depth = texture(gbPos, inUV).a; + vec3 n = texture(gbN_AO, inUV).rgb; + + + //outColor = vec4 (vec3(linDepth/100.0), 1); + if (float_equ (n.g, 1.0) && float_equ (pos.y, 0.0)) { + //reflecting plane + vec3 v = normalize(pos - ubo.camPos.xyz); // Vector from surface point to camera + vec3 reflection = normalize(reflect(v, n)); + + /*outColor = vec4 (reflection, 1); + return;*/ + + float curLength = step; + bool hit = false; + vec2 uv; + + for (int i=0; i<maxStep; i++) { + + vec3 curPos = pos + reflection * curLength; + + vec4 ndc = ubo.projection * ubo.view * vec4(curPos, 1.0); + uv = vec2 ((ndc.x / ndc.w + 1.0) / 2.0, (ndc.y / ndc.w + 1.0) / 2.0); + + if (uv.x < 0 || uv.y < 0 || uv.x > 1 || uv.y > 1) + break; + + vec4 cp = texture(gbPos, uv); + + float linDepthCP = linearDepth (ndc.z / ndc.w); + //outColor = vec4 (vec3 (linDepthCP/100.0), 1); + /*outColor = vec4 (1,0,0, 1); + return;*/ + + if (abs(linDepthCP - cp.a) < depthTreshold) { + hit = true; + break; + } + + curLength += step; + } + + + if (hit) + hdrColor = mix (hdrColor, texture(samplerHDR, uv), reflectionCoef); + //hdrColor = vec4 (1,0,0,1);// texture(samplerHDR, uv); + + } + + outColor = tonemap(hdrColor, exposure, gamma); + outColor = vec4(outColor.rgb * (1 - uiColor.a) + uiColor.rgb * uiColor.a, 1); + + //outColor = vec4 (vec3 (depth/100.0), 1); + + /* + outColor = vec4(SRGBtoLINEAR(tonemap(hdrColor.rgb)), hdrColor.a);;*/ + /* vec3 mapped = vec3(1.0) - exp(-hdrColor.rgb * pc.exposure); - mapped = pow(mapped, vec3(1.0 / pc.gamma)); - outColor = vec4(mapped, hdrColor.a);*/ + mapped = pow(mapped, vec3(1.0 / pc.gamma)); + outColor = vec4(mapped, hdrColor.a);*/ } diff --git a/src/VkChess.cs b/src/VkChess.cs index 37975c8..e31c27d 100644 --- a/src/VkChess.cs +++ b/src/VkChess.cs @@ -42,12 +42,11 @@ namespace vkChess Instance.VALIDATION = true; Instance.RENDER_DOC_CAPTURE = false; //SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Unorm; - DeferredPbrRendererBase.MAX_MATERIAL_COUNT = 5; + DeferredPbrRendererBase.MAX_MATERIAL_COUNT = 3; DeferredPbrRendererBase.MRT_FORMAT = VkFormat.R16g16b16a16Sfloat; DeferredPbrRendererBase.HDR_FORMAT = VkFormat.R16g16b16a16Sfloat; PbrModelTexArray.TEXTURE_DIM = 512; - ShadowMapRenderer.SHADOWMAP_SIZE = 1024; - + ShadowMapRenderer.SHADOWMAP_SIZE = 1024; using (VkChess app = new VkChess ()) app.Run (); } @@ -104,8 +103,9 @@ namespace vkChess DescriptorSetLayout dslToneMap; protected override void CreateDescriptors () { dsPool = new DescriptorPool (dev, 1, - new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler, 2)); - descSet = dsPool.Allocate (dslToneMap); + new VkDescriptorPoolSize (VkDescriptorType.CombinedImageSampler, 4), + new VkDescriptorPoolSize (VkDescriptorType.UniformBuffer, 1)); + descSet = dsPool.Allocate (dslToneMap); } protected override void CreatePipeline () { using (GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, DeferredPbrRendererBase.NUM_SAMPLES)) { @@ -115,10 +115,13 @@ namespace vkChess } dslToneMap = new DescriptorSetLayout (dev, 0, new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler), - new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler) + new VkDescriptorSetLayoutBinding (1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler), + new VkDescriptorSetLayoutBinding (2, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler), + new VkDescriptorSetLayoutBinding (3, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler), + new VkDescriptorSetLayoutBinding (4, VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer) ); cfg.Layout = new PipelineLayout (dev, - new VkPushConstantRange (VkShaderStageFlags.Fragment, 2 * sizeof (float)), dslToneMap); + new VkPushConstantRange (VkShaderStageFlags.Fragment, 20u), dslToneMap); cfg.RenderPass = renderPass; cfg.AddShaders ( @@ -136,7 +139,8 @@ namespace vkChess cmd.SetViewport (frameBuffers[imageIndex].Width, frameBuffers[imageIndex].Height); cmd.SetScissor (frameBuffers[imageIndex].Width, frameBuffers[imageIndex].Height); - cmd.PushConstant (plToneMap.Layout, VkShaderStageFlags.Fragment, 8, new float[] { Exposure, Gamma }, 0); + cmd.PushConstant (plToneMap.Layout, VkShaderStageFlags.Fragment, 16, new float[] { Exposure, Gamma, SSRStep, SSRThreshold }, 0); + cmd.PushConstant (plToneMap.Layout, VkShaderStageFlags.Fragment, 4, SSRMaxStepCount, 16); plToneMap.BindDescriptorSet (cmd, descSet); plToneMap.Bind (cmd); cmd.Draw (3, 1, 0, 0); @@ -176,16 +180,19 @@ namespace vkChess DeferredPbrRendererBase.NUM_SAMPLES = SampleCount; - renderer = new DeferredPbrRenderer (dev, swapChain, presentQueue, cubemapPathes [0], camera.NearPlane, camera.FarPlane); + renderer = new DeferredPbrRenderer (dev, swapChain, presentQueue, cubemapPathes [1], camera.NearPlane, camera.FarPlane); - renderer.matrices.gamma = Gamma; - renderer.matrices.exposure = Exposure; renderer.matrices.scaleIBLAmbient = IBLAmbient; renderer.lights[0].color = new Vector4 (LightStrength); //renderer.LoadModel (transferQ, "data/models/chess.glb"); renderer.LoadModel (transferQ, "/mnt/devel/vkChess.net/data/models/chess2.glb"); camera.Model = Matrix4x4.CreateScale (0.5f);// Matrix4x4.CreateScale(1f / Math.Max(Math.Max(renderer.modelAABB.Width, renderer.modelAABB.Height), renderer.modelAABB.Depth)); + DescriptorSetWrites dsw = new DescriptorSetWrites (descSet, + dslToneMap.Bindings[4]); + dsw.Write (dev, renderer.uboMatrices.Descriptor); + + UpdateFrequency = 5; curRenderer = renderer; @@ -327,8 +334,9 @@ namespace vkChess base.OnResize (); renderer.Resize (); - DescriptorSetWrites dsw = new DescriptorSetWrites (descSet, dslToneMap.Bindings[1]); - dsw.Write (dev, renderer.HDROutput.Descriptor); + DescriptorSetWrites dsw = new DescriptorSetWrites (descSet, + dslToneMap.Bindings[1], dslToneMap.Bindings[2], dslToneMap.Bindings[3]); + dsw.Write (dev, renderer.HDROutput.Descriptor, renderer.GBuffPosDepthOutput.Descriptor, renderer.GBuffN_AO.Descriptor); buildCommandBuffers (); updateViewRequested = true; @@ -493,7 +501,7 @@ namespace vkChess protected override void onKeyDown (Glfw.Key key, int scanCode, Modifier modifiers) { switch (key) { case Glfw.Key.F1: - loadWindow (@"ui/main.crow", this); + loadWindow (@"ui/winSSR.crow", this); break; case Glfw.Key.F2: /*loadWindow (@"ui/board.crow", this); @@ -694,7 +702,6 @@ namespace vkChess if (value == Gamma) return; Configuration.Global.Set ("Gamma", value); - renderer.matrices.gamma = value; NotifyValueChanged ("Gamma", value); rebuildBuffers = true; } @@ -705,7 +712,6 @@ namespace vkChess if (value == Exposure) return; Configuration.Global.Set ("Exposure", value); - renderer.matrices.exposure = value; NotifyValueChanged ("Exposure", value); rebuildBuffers = true; } @@ -742,6 +748,36 @@ namespace vkChess NotifyValueChanged ("SampleCount", value); } } + public float SSRStep { + get => Configuration.Global.Get<float> ("SSRStep", 0.1f); + set { + if (value == SSRStep) + return; + Configuration.Global.Set ("SSRStep", value); + NotifyValueChanged ("SSRStep", value); + rebuildBuffers = true; + } + } + public float SSRThreshold { + get => Configuration.Global.Get<float> ("SSRThreshold", 0.05f); + set { + if (value == SSRThreshold) + return; + Configuration.Global.Set ("SSRThreshold", value); + NotifyValueChanged ("SSRThreshold", value); + rebuildBuffers = true; + } + } + public int SSRMaxStepCount { + get => Configuration.Global.Get<int> ("SSRMaxStepCount", 100); + set { + if (value == SSRMaxStepCount) + return; + Configuration.Global.Set ("SSRMaxStepCount", value); + NotifyValueChanged ("SSRMaxStepCount", value); + rebuildBuffers = true; + } + } #endregion #region LOGS diff --git a/src/deferredPbrRendererBase.cs b/src/deferredPbrRendererBase.cs index dd42f9f..75f2a3f 100644 --- a/src/deferredPbrRendererBase.cs +++ b/src/deferredPbrRendererBase.cs @@ -42,8 +42,6 @@ namespace vkChess public Matrix4x4 model; public Matrix4x4 view; public Vector4 camPos; - public float exposure; - public float gamma; public float prefilteredCubeMipLevels; public float scaleIBLAmbient; } @@ -54,9 +52,7 @@ namespace vkChess } public Matrices matrices = new Matrices { - gamma = 1.2f, - exposure = 2.0f, - scaleIBLAmbient = 0.5f, + scaleIBLAmbient = 0.5f }; //public Light[] lights = { // new Light { @@ -87,6 +83,8 @@ namespace vkChess Image gbColorRough, gbEmitMetal, gbN_AO, gbPos, hdrImg; public Image HDROutput => hdrImg; + public Image GBuffPosDepthOutput => gbPos; + public Image GBuffN_AO => gbN_AO; DescriptorPool descriptorPool; DescriptorSetLayout descLayoutMain, descLayoutGBuff; @@ -152,8 +150,8 @@ namespace vkChess renderPass.AddAttachment (dev.GetSuitableDepthFormat (), VkImageLayout.DepthStencilAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare); renderPass.AddAttachment (swapChain.ColorFormat, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff0 (color + roughness) and final color before resolve renderPass.AddAttachment (VkFormat.R8g8b8a8Unorm, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff1 (emit + metal) - renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff2 (normals + AO) - renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ColorAttachmentOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.DontCare);//GBuff3 (Pos + depth) + renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ShaderReadOnlyOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.Store, VkImageLayout.ShaderReadOnlyOptimal);//GBuff2 (normals + AO) + renderPass.AddAttachment (MRT_FORMAT, VkImageLayout.ShaderReadOnlyOptimal, NUM_SAMPLES, VkAttachmentLoadOp.Clear, VkAttachmentStoreOp.Store, VkImageLayout.ShaderReadOnlyOptimal);//GBuff3 (Pos + depth) renderPass.ClearValues.Add (new VkClearValue { color = new VkClearColorValue (0.0f, 0.0f, 0.0f) }); renderPass.ClearValues.Add (new VkClearValue { depthStencil = new VkClearDepthStencilValue (1.0f, 0) }); @@ -425,8 +423,8 @@ namespace vkChess gbColorRough = new Image (dev, swapChain.ColorFormat, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); gbEmitMetal = new Image (dev, VkFormat.R8g8b8a8Unorm, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); - gbN_AO = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); - gbPos = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); + gbN_AO = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment | VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); + gbPos = new Image (dev, MRT_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment | VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, layerCount); hdrImg = new Image (dev, HDR_FORMAT, VkImageUsageFlags.InputAttachment | VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransientAttachment | VkImageUsageFlags.Sampled, VkMemoryPropertyFlags.DeviceLocal | VkMemoryPropertyFlags.DeviceLocal, swapChain.Width, swapChain.Height, VkImageType.Image2D, NUM_SAMPLES, VkImageTiling.Optimal, 1, 1); gbColorRough.CreateView (); diff --git a/ui/winSSR.crow b/ui/winSSR.crow new file mode 100644 index 0000000..86ce8b8 --- /dev/null +++ b/ui/winSSR.crow @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<Window Caption="SSR" Width="90%" Height="Fit" > + <VerticalStack Spacing="1" Margin="10" > + <HorizontalStack Style="Slid" > + <Label Text="Step:" Width="100"/> + <Slider Style="LightingSlider" Value="{²SSRStep}" Decimals="4" Maximum="0.1" SmallIncrement="0.0001" LargeIncrement="0.01"/> + </HorizontalStack> + <HorizontalStack Style="Slid" > + <Label Text="Depth Threshold:" Width="100" /> + <Slider Style="LightingSlider" Value="{²SSRThreshold}" Decimals="4" Maximum="0.1" SmallIncrement="0.0001" LargeIncrement="0.01"/> + </HorizontalStack> + <HorizontalStack Style="Slid" > + <Label Text="Max Step Count:" Width="100" /> + <Slider Style="LightingSlider" Value="{²SSRMaxStepCount}" Maximum="1000" SmallIncrement="1" LargeIncrement="10"/> + </HorizontalStack> + </VerticalStack> +</Window> + |