Skip to content

Commit 7cf3acc

Browse files
committed
modified shader files to fit AMD graphics card
1 parent f829768 commit 7cf3acc

File tree

8 files changed

+22
-27
lines changed

8 files changed

+22
-27
lines changed

shaders/edge_gs.glsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#version 330
2-
32
layout(lines) in;
43
layout(line_strip, max_vertices = 2) out;
54

shaders/edge_vs.glsl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#version 330
2-
in layout(location = 0) vec3 vp;
2+
layout(location = 0) in vec3 vp;
33

44
uniform mat4 view_matrix, proj_matrix;
5-
//uniform mat4 view_matrix;
6-
uniform float scale = 1.f;
5+
uniform float scale = 1.0f;
76

87
void main()
98
{
10-
119
vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
12-
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
10+
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
1311
gl_Position = proj_matrix * vCam;
14-
//gl_Position.z -= 0.005f;
1512
}

shaders/face_fs.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#version 330
1+
#version 330 core
22
in vec3 pos;
33
in vec3 normal;
44

55
flat in uint flag;
66
flat in vec3 Kd;
77
//uniform vec3 Kd = vec3(0.6, 0.8, 1);
88
uniform vec3 La = vec3(0, 0, 0);
9-
uniform vec3 light_pos = vec3(0.f, 1.f, 0.f);
9+
uniform vec3 light_pos = vec3(0.0f, 1.0f, 0.0f);
1010

1111
out vec4 frag_color; // final colour of surface
1212

@@ -22,10 +22,10 @@ void main()
2222
vec3 dist2eye = light_pos - pos;
2323
vec3 dir = normalize(dist2eye);
2424
float dot_prod = dot(dir, normal);
25-
dot_prod = (dot_prod + 1.f) / 2.0;
25+
dot_prod = (dot_prod + 1.0f) / 2.0f;
2626
vec3 Id = mix(La, Kd, dot_prod); // final diffuse intensity
2727
// final color
28-
frag_color = vec4(Id, 1.f);
28+
frag_color = vec4(Id, 1.0f);
2929
}
3030

3131
}

shaders/face_vs.glsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#version 330
2-
in layout(location = 0) vec3 vp;
2+
layout(location = 0) in vec3 vp;
33

44
uniform mat4 view_matrix;
5-
uniform float scale = 1.f;
5+
uniform float scale = 1.0f;
66

77
void main()
88
{
9-
//gl_Position = proj_matrix * view_matrix * vec4(vp, 1.0);
10-
gl_Position = view_matrix * vec4(scale * vp, 1.0);
9+
gl_Position = view_matrix * vec4(scale * vp, 1.0f);
1110
}

shaders/uid_vs.glsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#version 330
2-
3-
in layout(location = 0) vec3 vp;
2+
layout(location = 0) in vec3 vp;
43
uniform int mode = 0;
54

65
uniform mat4 view_matrix, proj_matrix;
7-
uniform float scale = 1.f;
6+
uniform float scale = 1.0f;
87

98
void main()
109
{
1110
vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
1211
if (mode > 0)
1312
{
14-
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
13+
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
1514
}
1615
gl_Position = proj_matrix * vCam;
1716

shaders/vtx_vs.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#version 330
2-
in layout(location = 0) vec3 vp;// vertex position
3-
//in layout(location = 1) uint vf;// vertex flag
2+
layout(location = 0) in vec3 vp;// vertex position
3+
//layout(location = 1) in uint vf;// vertex flag
44
uniform mat4 view_matrix, proj_matrix;
5-
uniform float scale = 1.f;
5+
uniform float scale = 1.0f;
66

77
uniform usamplerBuffer flag_tex;
88
flat out uint flag;
99

1010
void main()
1111
{
1212
vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
13-
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
13+
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
1414
gl_Position = proj_matrix * vCam;
1515

1616
flag = texelFetch(flag_tex, gl_VertexID).r;

src/MeshViewer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ MeshViewer::MeshViewer(QWidget *parent)
2222
QSurfaceFormat format;
2323
format.setDepthBufferSize(32);
2424
format.setStencilBufferSize(8);
25-
format.setSamples(9);
25+
// To enable anti-aliasing, set sample to sampleNumber^2
26+
//format.setSamples(9);
2627
format.setVersion(3, 3);
2728
format.setProfile(QSurfaceFormat::CoreProfile);
2829
this->setFormat(format);

src/ViewerGrid.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
const char* gridvs =
44
"#version 330\n"\
5-
"in layout(location = 0) vec2 vp;"\
5+
"layout(location = 0) in vec2 vp;"\
66
"uniform mat4 view, proj;"\
77
"uniform float size;"\
88
"void main() {"\
9-
" gl_Position = proj * view * vec4(vp.x * size, 0.0, vp.y * size, 1.0);"\
9+
" gl_Position = proj * view * vec4(vp.x * size, 0.0f, vp.y * size, 1.0f);"\
1010
"}";
1111

1212
const char* gridfs =
1313
"#version 330\n"\
1414
"out vec4 frag_color;"\
1515
"void main() {"\
16-
" frag_color = vec4(0.5,0.5,0.5, 1.0);"\
16+
" frag_color = vec4(0.5f, 0.5f, 0.5f, 1.0f);"\
1717
"}";
1818

1919

0 commit comments

Comments
 (0)