Added VS and FS shaders to tile singular textures #258
|
@ -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;
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: TestCube_Tile_FS
|
||||||
|
ID: 39265233
|
||||||
|
Type: 2
|
|
@ -0,0 +1,74 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_KHR_vulkan_glsl : enable
|
||||||
|
|
||||||
|
//#include "ShaderDescriptorDefinitions.glsl"
|
||||||
|
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 aVertexPos;
|
||||||
|
layout(location = 1) in vec2 aUV;
|
||||||
|
layout(location = 2) in vec3 aNormal;
|
||||||
|
layout(location = 3) in vec3 aTangent;
|
||||||
|
layout(location = 4) in mat4 worldTransform;
|
||||||
|
layout(location = 8) in uvec2 integerData;
|
||||||
|
|
||||||
|
struct MatPropData
|
||||||
|
{
|
||||||
|
vec2 tileMult;
|
||||||
|
uint textureIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(location = 0) out struct
|
||||||
|
{
|
||||||
|
vec4 vertPos; // location 0
|
||||||
|
vec2 uv; // location = 1
|
||||||
|
vec4 normal; // location = 2
|
||||||
|
|
||||||
|
} Out;
|
||||||
|
|
||||||
|
// material stuff
|
||||||
|
layout(location = 3) out struct
|
||||||
|
{
|
||||||
|
int materialIndex;
|
||||||
|
uint eid;
|
||||||
|
uint lightLayerIndex;
|
||||||
|
|
||||||
|
} Out2;
|
||||||
|
|
||||||
|
layout(set = 2, binding = 0) uniform CameraData
|
||||||
|
{
|
||||||
|
vec4 position;
|
||||||
|
mat4 vpMat;
|
||||||
|
mat4 viewMat;
|
||||||
|
mat4 perspectiveMat;
|
||||||
|
mat4 orthoMat;
|
||||||
|
} cameraData;
|
||||||
|
|
||||||
|
layout (std430, set = 3, binding = 0) buffer MaterialProperties // For materials
|
||||||
|
{
|
||||||
|
MatPropData data[];
|
||||||
|
} MatProp;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Out2.materialIndex = gl_InstanceIndex;
|
||||||
|
Out2.eid = integerData[0];
|
||||||
|
Out2.lightLayerIndex = integerData[1];
|
||||||
|
|
||||||
|
// for transforming gBuffer position and normal data
|
||||||
|
mat4 modelViewMat = cameraData.viewMat * worldTransform;
|
||||||
|
|
||||||
|
// gBuffer position will be in view space
|
||||||
|
Out.vertPos = modelViewMat * vec4(aVertexPos, 1.0f);
|
||||||
|
|
||||||
|
// uvs for texturing in fragment shader
|
||||||
|
Out.uv = aUV * MatProp.data[gl_InstanceIndex].tileMult;
|
||||||
|
|
||||||
|
mat3 transposeInv = mat3 (transpose(inverse(modelViewMat)));
|
||||||
|
|
||||||
|
// normals are also in view space
|
||||||
|
Out.normal.rgb = transposeInv * aNormal.rgb;
|
||||||
|
Out.normal.rgb = normalize (Out.normal.rgb);
|
||||||
|
|
||||||
|
// clip space for rendering
|
||||||
|
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||||
|
}
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
Name: TestCube_Tile_VS
|
||||||
|
ID: 44231040
|
||||||
|
Type: 2
|
|
@ -90,7 +90,7 @@ namespace SHADE
|
||||||
SHVkDescriptorSetLayout::Binding materialDataBinding
|
SHVkDescriptorSetLayout::Binding materialDataBinding
|
||||||
{
|
{
|
||||||
.Type = vk::DescriptorType::eStorageBufferDynamic,
|
.Type = vk::DescriptorType::eStorageBufferDynamic,
|
||||||
.Stage = vk::ShaderStageFlagBits::eFragment,
|
.Stage = vk::ShaderStageFlagBits::eFragment | vk::ShaderStageFlagBits::eVertex,
|
||||||
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
|
.BindPoint = SHGraphicsConstants::DescriptorSetBindings::BATCHED_PER_INST_DATA,
|
||||||
.DescriptorCount = 1,
|
.DescriptorCount = 1,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue