adjusted shaders

This commit is contained in:
J3oss
2021-06-15 16:50:56 +02:00
parent a68d31f319
commit 561713a9d2
2 changed files with 17 additions and 11 deletions

View File

@@ -5,11 +5,15 @@ struct Material {
vec3 baseColor;
};
vec3 directional_light = vec3(-1.0,-1.0,-1.0);
layout(location = 0) in vec3 normal;
layout(location = 1) in Material material;
layout(location = 0) out vec4 outColor;
void main() {
outColor = vec4(material.baseColor, 1.0);
//float intensity = ((dot(normalize(normal), normalize(directional_light)) +1)/2.0)+0.05;
//outColor = vec4(material.baseColor * intensity, 1.0);
}

View File

@@ -13,15 +13,15 @@ struct Material {
};
struct Mesh {
uint indexBufferIndex;
uint vertexBufferIndex;
uint materialBufferIndex;
uint asd;
};
layout( push_constant ) uniform constants
{
mat4 render_matrix;
uint meshIndex;
uint indexBufferIndex;
uint vertexBufferIndex;
uint materialBufferIndex;
} PushConstants;
layout(set = 0, binding = 0) uniform CameraParam {
@@ -50,13 +50,15 @@ layout(location = 1) out Material material;
void main()
{
Mesh mesh = MeshBuffers[PushConstants.meshIndex].mesh;
material = MaterialBuffers[ mesh.materialBufferIndex ].material;
//Mesh mesh = MeshBuffers[PushConstants.meshIndex].mesh;
//material = MaterialBuffers[ mesh.materialBufferIndex ].material;
material = MaterialBuffers[ PushConstants.materialBufferIndex ].material;
uint index = IndexBuffers[ mesh.indexBufferIndex ].indices[gl_VertexIndex];
Vertex vertex = VertexBuffers[ mesh.vertexBufferIndex ].vertices[ index ];
uint index = IndexBuffers[ PushConstants.indexBufferIndex ].indices[gl_VertexIndex];
//uint index = IndexBuffers[ mesh.indexBufferIndex ].indices[gl_VertexIndex];
//Vertex vertex = VertexBuffers[ mesh.vertexBufferIndex ].vertices[ index ];
Vertex vertex = VertexBuffers[ PushConstants.vertexBufferIndex ].vertices[ index ];
normal = vertex.normal.xyz;
float scale = 0.3;
gl_Position = Camera.projection * Camera.view * PushConstants.render_matrix * vec4(vertex.position.x * scale - 0.1, vertex.position.y * scale - 0.7, (vertex.position.z * scale * -1.0 + 0.9), 1.0);
gl_Position = Camera.projection * Camera.view * PushConstants.render_matrix * vec4(vertex.position.x, vertex.position.y, vertex.position.z, 1.0);
}