diff options
Diffstat (limited to 'glsl')
-rw-r--r-- | glsl/shader_2d.vert.glsl | 6 | ||||
-rw-r--r-- | glsl/shader_3d.frag.glsl | 15 | ||||
-rw-r--r-- | glsl/shader_3d.vert.glsl | 18 |
3 files changed, 22 insertions, 17 deletions
diff --git a/glsl/shader_2d.vert.glsl b/glsl/shader_2d.vert.glsl index b053fec..5c5a243 100644 --- a/glsl/shader_2d.vert.glsl +++ b/glsl/shader_2d.vert.glsl @@ -21,10 +21,10 @@ layout(location = 0) in vec2 in_texture_coord; layout(location = 0) out vec2 out_texture_coord; -layout(set = 0, binding = 0) uniform UBOProjection +layout(set = 0, binding = 0) uniform UBOView2D { mat4 proj; -} ubo_projection; +} ubo_view; layout(set = 1, binding = 0) uniform UBOSpritePositions { @@ -54,5 +54,5 @@ main() coordinate = vec2(position.z, position.w); break; } - gl_Position = ubo_projection.proj * vec4(coordinate, 0.0, 1.0); + gl_Position = ubo_view.proj * vec4(coordinate, 0.0, 1.0); } diff --git a/glsl/shader_3d.frag.glsl b/glsl/shader_3d.frag.glsl index 5c4b857..302f7d4 100644 --- a/glsl/shader_3d.frag.glsl +++ b/glsl/shader_3d.frag.glsl @@ -28,24 +28,25 @@ layout(location = 0) in DataTransferObject in_dto; layout(location = 0) out vec4 out_color; -layout(set = 0, binding = 1) uniform UBODirectionalLight +layout(set = 0, binding = 1) uniform UBOWorld { - vec3 direction; - vec4 color; -} ubo_directional_light; + vec3 directional_light_direction; + vec4 directional_light_color; +} ubo_world; -layout(set = 1, binding = 1) uniform sampler2D texture_sampler; +layout(set = 2, binding = 1) uniform sampler2D texture_sampler; void main() { float diffuse_factor = - max(dot(in_dto.normal, -ubo_directional_light.direction), 0.0); + max(dot(in_dto.normal, -ubo_world.directional_light_direction), 0.0); vec4 diff_samp = texture(texture_sampler, in_dto.frag_texture_coord); vec4 ambient = vec4(vec3(in_dto.frag_color), diff_samp.a); vec4 diffuse = - vec4(vec3(ubo_directional_light.color * diffuse_factor), diff_samp.a); + vec4(vec3(ubo_world.directional_light_color * diffuse_factor), + diff_samp.a); diffuse *= diff_samp; ambient *= diff_samp; diff --git a/glsl/shader_3d.vert.glsl b/glsl/shader_3d.vert.glsl index 387ad00..29beea9 100644 --- a/glsl/shader_3d.vert.glsl +++ b/glsl/shader_3d.vert.glsl @@ -29,14 +29,18 @@ layout(location = 0) out DataTransferObject vec3 normal; } out_dto; -layout(set = 0, binding = 0) uniform UBOViewProjection +layout(set = 0, binding = 0) uniform UBOWorld +{ + vec4 ambient_light_color; +} ubo_world; + +layout(set = 1, binding = 0) uniform UBOView { mat4 view; mat4 proj; - vec4 ambient_color; -} ubo_view_projection; +} ubo_view; -layout(set = 1, binding = 0) uniform UBOModelInstance +layout(set = 2, binding = 0) uniform UBOModelInstance { mat4 instances[128]; } ubo_model_instance; @@ -45,9 +49,9 @@ void main() { gl_Position = - ubo_view_projection.proj * ubo_view_projection.view * - ubo_model_instance.instances[gl_InstanceIndex] * vec4(in_position, 1.0); - out_dto.frag_color = ubo_view_projection.ambient_color; + ubo_view.proj * ubo_view.view * + ubo_model_instance.instances[gl_InstanceIndex] * vec4(in_position, 1.0); + out_dto.frag_color = ubo_world.ambient_light_color; out_dto.frag_texture_coord = in_texture_coord; out_dto.normal = mat3(ubo_model_instance.instances[gl_InstanceIndex]) * in_normal; |