Changeset fba08f2 in opengl-game for shaders


Ignore:
Timestamp:
Aug 2, 2019, 4:15:02 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
4f63fa8
Parents:
621664a
git-author:
Dmitry Portnoy <dmp1488@…> (08/02/19 04:01:00)
git-committer:
Dmitry Portnoy <dmp1488@…> (08/02/19 04:15:02)
Message:

Update vulkan-game.cpp to support texturing in the shader

Location:
shaders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • shaders/shader.frag

    r621664a rfba08f2  
    22#extension GL_ARB_separate_shader_objects : enable
    33
     4layout(binding = 1) uniform sampler2D texSampler;
     5
    46layout(location = 0) in vec3 fragColor;
     7layout(location = 1) in vec2 fragTexCoord;
    58
    69layout(location = 0) out vec4 outColor;
    710
    811void main() {
    9     outColor = vec4(fragColor, 1.0);
     12   // outColor = vec4(fragColor, 1.0);
     13   // outColor = texture(texSampler, fragTexCoord);
     14   outColor = vec4(fragColor * texture(texSampler, fragTexCoord).rgb, 1.0);
    1015}
  • shaders/shader.vert

    r621664a rfba08f2  
    11#version 450
    22#extension GL_ARB_separate_shader_objects : enable
     3
     4vec2 positions[3] = vec2[](
     5    vec2( 0.0,  0.5),
     6    vec2(-0.5, -0.5),
     7    vec2( 0.5, -0.5)
     8);
    39
    410layout (binding = 0) uniform UniformBufferObject {
     
    1016layout(location = 0) in vec2 inPosition;
    1117layout(location = 1) in vec3 inColor;
     18layout(location = 2) in vec2 inTexCoord;
    1219
    1320layout(location = 0) out vec3 fragColor;
     21layout(location = 1) out vec2 fragTexCoord;
    1422
    1523void main() {
    16    gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
     24   // gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
     25   gl_Position = ubo.proj * ubo.view * ubo.model * vec4(positions[gl_VertexIndex], -5.0, 1.0);
    1726   fragColor = inColor;
     27   fragTexCoord = inTexCoord;
    1828}
Note: See TracChangeset for help on using the changeset viewer.