aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-28 20:50:44 +0000
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-28 20:50:44 +0000
commitc7d842ba602f50e58424f18e57d87d14d87b5df3 (patch)
treee1eacd1fb8a41b9899324b0915a978e1de7b2c3f
parent2a588d5d146e7cb6ce14fef5f151fbb0b19d5f3d (diff)
optional tesselation, default is off
-rw-r--r--shaders/GBuffPbrInstanced.vert25
-rw-r--r--shaders/GBuffPbrInstancedTesselation.vert30
-rw-r--r--src/VkChess.cs13
-rw-r--r--src/deferredPbrRendererBase.cs32
-rw-r--r--ui/debug.crow6
-rw-r--r--ui/winOptions.crow6
-rw-r--r--ui/winSSR.crow8
7 files changed, 73 insertions, 47 deletions
diff --git a/shaders/GBuffPbrInstanced.vert b/shaders/GBuffPbrInstanced.vert
index 12d2bd9..f0821a3 100644
--- a/shaders/GBuffPbrInstanced.vert
+++ b/shaders/GBuffPbrInstanced.vert
@@ -14,31 +14,20 @@ layout (set = 0, binding = 0) uniform UBO {
mat4 view;
} ubo;
-layout (location = 0) out vec3 outNormal;
-layout (location = 1) out vec2 outUV0;
-layout (location = 2) out vec2 outUV1;
-layout (location = 3) out vec4 outColor;
-
-/*out gl_PerVertex
-{
- vec4 gl_Position;
-};*/
+layout (location = 0) out vec3 outWorldPos;
+layout (location = 1) out vec3 outNormal;
+layout (location = 2) out vec2 outUV0;
+layout (location = 3) out vec2 outUV1;
+layout (location = 4) out vec4 outColor;
void main()
{
- /*vec4 locPos = ubo.model * inModel * vec4(inPos, 1.0);
+ vec4 locPos = ubo.model * inModel * vec4(inPos, 1.0);
outNormal = normalize(transpose(inverse(mat3(ubo.model * inModel))) * inNormal);
outColor = inColor;
outWorldPos = locPos.xyz;
outUV0 = inUV0;
outUV1 = inUV1;
- gl_Position = ubo.projection * ubo.view * vec4(outWorldPos, 1.0);*/
-
- outNormal = normalize(transpose(inverse(mat3(ubo.model * inModel))) * inNormal);
- outUV0 = inUV0;
- outUV1 = inUV1;
- outColor = inColor;
-
- gl_Position = ubo.model * inModel * vec4(inPos, 1.0);
+ gl_Position = ubo.projection * ubo.view * vec4(outWorldPos, 1.0);
}
diff --git a/shaders/GBuffPbrInstancedTesselation.vert b/shaders/GBuffPbrInstancedTesselation.vert
new file mode 100644
index 0000000..4afb5c2
--- /dev/null
+++ b/shaders/GBuffPbrInstancedTesselation.vert
@@ -0,0 +1,30 @@
+#version 450
+
+layout (location = 0) in vec3 inPos;
+layout (location = 1) in vec3 inNormal;
+layout (location = 2) in vec2 inUV0;
+layout (location = 3) in vec2 inUV1;
+//instanced
+layout (location = 4) in vec4 inColor;
+layout (location = 5) in mat4 inModel;
+
+layout (set = 0, binding = 0) uniform UBO {
+ mat4 projection;
+ mat4 model;
+ mat4 view;
+} ubo;
+
+layout (location = 0) out vec3 outNormal;
+layout (location = 1) out vec2 outUV0;
+layout (location = 2) out vec2 outUV1;
+layout (location = 3) out vec4 outColor;
+
+void main()
+{
+ outNormal = normalize(transpose(inverse(mat3(ubo.model * inModel))) * inNormal);
+ outUV0 = inUV0;
+ outUV1 = inUV1;
+ outColor = inColor;
+
+ gl_Position = ubo.model * inModel * vec4(inPos, 1.0);
+}
diff --git a/src/VkChess.cs b/src/VkChess.cs
index 0aeab0f..de8f19f 100644
--- a/src/VkChess.cs
+++ b/src/VkChess.cs
@@ -107,7 +107,9 @@ namespace vkChess
#if PIPELINE_STATS
enabled_features.pipelineStatisticsQuery = available_features.pipelineStatisticsQuery;
#endif
- enabled_features.tessellationShader = available_features.tessellationShader;
+ if (!available_features.tessellationShader)
+ EnableTesselation = false;
+ enabled_features.tessellationShader = EnableTesselation;
}
#if PIPELINE_STATS
@@ -840,6 +842,15 @@ namespace vkChess
NotifyValueChanged ("SampleCount", value);
}
}
+ public bool EnableTesselation {
+ get => Configuration.Global.Get<bool> ("EnableTesselation", false);
+ set {
+ if (value == EnableTesselation)
+ return;
+ Configuration.Global.Set ("EnableTesselation", value);
+ NotifyValueChanged ("EnableTesselation", value);
+ }
+ }
public bool EnableReflections {
get => Configuration.Global.Get<bool> ("EnableReflections", false);
set {
diff --git a/src/deferredPbrRendererBase.cs b/src/deferredPbrRendererBase.cs
index 9e18607..9bfa612 100644
--- a/src/deferredPbrRendererBase.cs
+++ b/src/deferredPbrRendererBase.cs
@@ -57,16 +57,6 @@ namespace vkChess
public Matrices matrices = new Matrices {
scaleIBLAmbient = 0.5f
};
- //public Light[] lights = {
- // new Light {
- // position = new Vector4(3.5f,12.5f,2,0f),
- // color = new Vector4(1,0.8f,0.8f,1)
- // },
- // new Light {
- // position = new Vector4(-3.5f,12.5f,2,0f),
- // color = new Vector4(0.8f,0.8f,1,1)
- // }
- //};
public Light [] lights = {
new Light {
position = new Vector4(5.5f,12.5f,2,0f),
@@ -77,9 +67,6 @@ namespace vkChess
color = new Vector4(1,1,1,1)
}*/
};
-
- //public DescriptorSetWrites UiImageUpdate => new DescriptorSetWrites (dsMain, descLayoutMain.Bindings [8]);
-
const float lightMoveSpeed = 0.1f;
FrameBuffers frameBuffers;
@@ -111,10 +98,11 @@ namespace vkChess
const int SP_DEPTH_PREPASS = 1;
const int SP_MODELS = 2;
const int SP_COMPOSE = 3;
- //const int SP_TONE_MAPPING = 4;
public Model.Scene mainScene;
+ bool enableTesselation => Crow.Configuration.Global.Get<bool> ("EnableTesselation", false);
+
public DeferredPbrRendererBase (Device dev, SwapChain swapChain, PresentQueue presentQueue, string cubemapPath, float nearPlane, float farPlane) {
this.dev = dev;
this.swapChain = swapChain;
@@ -266,13 +254,17 @@ namespace vkChess
new SpecializationConstant<float> (0, nearPlane),
new SpecializationConstant<float> (1, farPlane),
new SpecializationConstant<int> (2, MAX_MATERIAL_COUNT))) {
- cfg.inputAssemblyState.topology = VkPrimitiveTopology.PatchList;
-
- cfg.AddShader (dev, VkShaderStageFlags.TessellationControl, "#vkChess.net.pntriangles.tesc.spv");
- cfg.AddShader (dev, VkShaderStageFlags.TessellationEvaluation, "#vkChess.net.pntriangles.tese.spv");
- cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#vkChess.net.GBuffPbrInstanced.vert.spv");
- cfg.TessellationPatchControlPoints = 3;
+ if (enableTesselation) {
+ cfg.inputAssemblyState.topology = VkPrimitiveTopology.PatchList;
+ cfg.AddShader (dev, VkShaderStageFlags.TessellationControl, "#vkChess.net.pntriangles.tesc.spv");
+ cfg.AddShader (dev, VkShaderStageFlags.TessellationEvaluation, "#vkChess.net.pntriangles.tese.spv");
+ cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#vkChess.net.GBuffPbrInstancedTesselation.vert.spv");
+ cfg.TessellationPatchControlPoints = 3;
+ } else {
+ cfg.inputAssemblyState.topology = VkPrimitiveTopology.TriangleList;
+ cfg.AddShader (dev, VkShaderStageFlags.Vertex, "#vkChess.net.GBuffPbrInstanced.vert.spv");
+ }
cfg.SubpassIndex = SP_DEPTH_PREPASS;
diff --git a/ui/debug.crow b/ui/debug.crow
index 44669a8..bc2aaa4 100644
--- a/ui/debug.crow
+++ b/ui/debug.crow
@@ -14,10 +14,10 @@
<Expandable Caption="Debug Views" Margin="5">
<VerticalStack Spacing="1" Margin="10" >
<HorizontalStack Height="Fit">
- <Label Text="Fps:" Width="80"/>
- <Label Text="{fps}" Width="Stretched" TextAlignment="Center"/>
+ <Label Text="Fps:" Width="80"/>
+ <Label Text="{fps}" Width="Stretched" TextAlignment="Center"/>
</HorizontalStack>
- <EnumSelector Margin="20" EnumValue="{²CurrentDebugView}" />
+ <EnumSelector Margin="20" EnumValue="{²CurrentDebugView}" />
</VerticalStack>
</Expandable>
<Expandable Caption="Materials" Margin="5">
diff --git a/ui/winOptions.crow b/ui/winOptions.crow
index 0f7a96e..528ca5e 100644
--- a/ui/winOptions.crow
+++ b/ui/winOptions.crow
@@ -74,7 +74,11 @@
<Label Text="IBL Ambient:" Width="100" />
<Slider Style="LightingSlider" Value="{²IBLAmbient}" Maximum="50.0" SmallIncrement="0.01" LargeIncrement="0.1"/>
</HorizontalStack>
- <CheckBox Caption="Enable Reflections" IsChecked="{²EnableReflections}" />
+ <HorizontalStack >
+ <CheckBox Caption="Enable Reflections" IsChecked="{²EnableReflections}" />
+ <CheckBox Caption="Enable Tesselation" IsChecked="{²EnableTesselation}" />
+ <Label Text="(restart required)"/>
+ </HorizontalStack >
<EnumSelector Caption="Sample count" ForceRadioButton="true" BitFieldExcludeMask="{AvailableSampleCount}" EnumValue="{²SampleCount}" Height="Fit" Width="Stretched">
<Template>
<GroupBox Caption="{./Caption}" CornerRadius="{./CornerRadius}" Foreground="{./Foreground}" Background="{./Background}">
diff --git a/ui/winSSR.crow b/ui/winSSR.crow
index 6454b08..8e94100 100644
--- a/ui/winSSR.crow
+++ b/ui/winSSR.crow
@@ -1,10 +1,10 @@
<?xml version="1.0"?>
<Window Caption="SSR" Width="90%" Height="Fit" >
- <VerticalStack Spacing="1" Margin="10" >
+ <VerticalStack Spacing="1" Margin="10" >
<HorizontalStack Style="Slid" >
<Label Text="Step:" Width="100"/>
<Slider Style="LightingSlider" Value="{²SSRStep}" Decimals="4" Maximum="1.0" SmallIncrement="0.0001" LargeIncrement="0.01"/>
- </HorizontalStack>
+ </HorizontalStack>
<HorizontalStack Style="Slid" >
<Label Text="Depth Threshold:" Width="100" />
<Slider Style="LightingSlider" Value="{²SSRThreshold}" Decimals="4" Maximum="1.0" SmallIncrement="0.0001" LargeIncrement="0.01"/>
@@ -12,7 +12,7 @@
<HorizontalStack Style="Slid" >
<Label Text="Max Step Count:" Width="100" />
<Slider Style="LightingSlider" Value="{²SSRMaxStepCount}" Maximum="1000" SmallIncrement="1" LargeIncrement="10"/>
- </HorizontalStack>
- </VerticalStack>
+ </HorizontalStack>
+ </VerticalStack>
</Window>