From 0edd2f24e35c45c4f49c431c9e737f8a50da8711 Mon Sep 17 00:00:00 2001 From: Xiao Qi Date: Wed, 23 Nov 2022 13:02:33 +0800 Subject: [PATCH] Added VS and FS shaders to tile singular textures Added shader stage flag bit for vertex shaders --- Assets/Shaders/TestCube_Tile_FS.glsl | 48 ++++++++++++ Assets/Shaders/TestCube_Tile_FS.shshaderb | Bin 0 -> 2185 bytes .../Shaders/TestCube_Tile_FS.shshaderb.shmeta | 3 + Assets/Shaders/TestCube_Tile_VS.glsl | 74 ++++++++++++++++++ Assets/Shaders/TestCube_Tile_VS.shshaderb | Bin 0 -> 4205 bytes .../Shaders/TestCube_Tile_VS.shshaderb.shmeta | 3 + .../GlobalData/SHGraphicsGlobalData.cpp | 2 +- 7 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 Assets/Shaders/TestCube_Tile_FS.glsl create mode 100644 Assets/Shaders/TestCube_Tile_FS.shshaderb create mode 100644 Assets/Shaders/TestCube_Tile_FS.shshaderb.shmeta create mode 100644 Assets/Shaders/TestCube_Tile_VS.glsl create mode 100644 Assets/Shaders/TestCube_Tile_VS.shshaderb create mode 100644 Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta diff --git a/Assets/Shaders/TestCube_Tile_FS.glsl b/Assets/Shaders/TestCube_Tile_FS.glsl new file mode 100644 index 00000000..84403a7c --- /dev/null +++ b/Assets/Shaders/TestCube_Tile_FS.glsl @@ -0,0 +1,48 @@ +#version 450 +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable +#extension GL_EXT_nonuniform_qualifier : require + +struct MatPropData +{ + vec2 tileMult; + uint textureIndex; +}; + +layout(location = 0) in struct +{ + vec4 vertPos; // location 0 + vec2 uv; // location = 1 + vec4 normal; // location = 2 + +} In; + +// material stuff +layout(location = 3) flat in struct +{ + int materialIndex; + uint eid; + uint lightLayerIndex; +} In2; + +layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global) +layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials +{ + MatPropData data[]; +} MatProp; + +layout(location = 0) out vec4 position; +layout(location = 1) out uint outEntityID; +layout(location = 2) out uint lightLayerIndices; +layout(location = 3) out vec4 normals; +layout(location = 4) out vec4 albedo; + +void main() +{ + position = In.vertPos; + normals = In.normal; + albedo = texture(textures[nonuniformEXT(MatProp.data[In2.materialIndex].textureIndex)], In.uv); + + outEntityID = In2.eid; + lightLayerIndices = In2.lightLayerIndex; +} \ No newline at end of file diff --git a/Assets/Shaders/TestCube_Tile_FS.shshaderb b/Assets/Shaders/TestCube_Tile_FS.shshaderb new file mode 100644 index 0000000000000000000000000000000000000000..c7444c7d62831fed446340965286f26e5e41220e GIT binary patch literal 2185 zcmY+FTXPge6vrF(LJYSc0wNM8#5)==21F67LXlciwG=61sc%!mP7_)uGwV!mioE%u z)ED3URK8f{|JO4uLsy+W*FKkjpQ&B>ZOMc)IJthxm=k8%oHY+xleu6{%3=clHc)1@%hHqo!g{7X9l4H zxzC$3W+)CFX0F8Xn&_gmsR=9^bz=)%(A`c^#Rk<)5aecHZ5Ff)7;gnPjD&bsRd>iSl8WFBSq5eDq*l{(mf(6z<@; zpJvClZllS`Zta$v%0CJ_RxSKa>775`eI(1Nuye26bF%=HS+(kGbNk(S{!zpDy>_5g&_IM8qWGoOo}d4if3H4{AbveN8%t zSTH#kZPKkb*lUVHcJ00w?5x*=>Jh@giKi>(l*x}?jBThf~$brs#VY?)qd6Q1R+3Dw{ zbGQ$-#P)mOed!^_3zpDB?2-4ze^s0ErZ_#4qkp1)O_5jSAnv;4x5Uw@eNCK$joj$$ z4u{^aizg^LtJ1-m*|C$0{lK;=IT1%E@0vK6B_i^o-w;I{*Cm5Xo2R|=uJjWkeB422 zU$Bw${Z8gy#O0%&|6|GIZ+jk^4auB1>t~Y5MgQcxBMyedQxBd00&Mud5GTIxXW#JO z)hp>dN0yQJwtjij3nKP_w|<~V-uHD8_HT59JwuQ2mn0LyFwpsPNk~eT5jFCb$doS4<+Rq8$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A4>IAxE6&n?}ze@#x`qH74$|2J<-wp8xwA^Si5W)YL_e+|3@W zfg9tpCjG=Bu7@0P%^vi@V=v?M6N|V(Bd*zlAL_X1fqr7~UD-tTyRsXKS-*}f9{LUB z7ohmA+(gz#Jm%sS@(Cz<|0A-PE3luC#q42VKi8P`#kb=ZWaIVMeiHh#eowz5yT3kh UkGGLGpdFCCQP=N3b~*|D4~}t61^@s6 literal 0 HcmV?d00001 diff --git a/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta b/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta new file mode 100644 index 00000000..0603263f --- /dev/null +++ b/Assets/Shaders/TestCube_Tile_VS.shshaderb.shmeta @@ -0,0 +1,3 @@ +Name: TestCube_Tile_VS +ID: 44231040 +Type: 2 diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp index d0fbaf2c..87234a6b 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.cpp @@ -90,7 +90,7 @@ namespace SHADE SHVkDescriptorSetLayout::Binding materialDataBinding { .Type = vk::DescriptorType::eStorageBufferDynamic, - .Stage = vk::ShaderStageFlagBits::eFragment, + .Stage = vk::ShaderStageFlagBits::eFragment | vk::ShaderStageFlagBits::eVertex, .BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA, .DescriptorCount = 1, };