diff --git a/res/project/res/shaders/default.frag b/res/project/res/shaders/default.frag index 1322e2c..482980a 100644 --- a/res/project/res/shaders/default.frag +++ b/res/project/res/shaders/default.frag @@ -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); } diff --git a/res/project/res/shaders/default.vert b/res/project/res/shaders/default.vert index c2e8ad2..316f40a 100644 --- a/res/project/res/shaders/default.vert +++ b/res/project/res/shaders/default.vert @@ -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); }