Skip to content

Commit

Permalink
modified shader files to fit AMD graphics card
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenyaoKe committed Sep 13, 2016
1 parent f829768 commit 7cf3acc
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 27 deletions.
1 change: 0 additions & 1 deletion shaders/edge_gs.glsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#version 330

layout(lines) in;
layout(line_strip, max_vertices = 2) out;

Expand Down
9 changes: 3 additions & 6 deletions shaders/edge_vs.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#version 330
in layout(location = 0) vec3 vp;
layout(location = 0) in vec3 vp;

uniform mat4 view_matrix, proj_matrix;
//uniform mat4 view_matrix;
uniform float scale = 1.f;
uniform float scale = 1.0f;

void main()
{

vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
gl_Position = proj_matrix * vCam;
//gl_Position.z -= 0.005f;
}
8 changes: 4 additions & 4 deletions shaders/face_fs.glsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#version 330
#version 330 core
in vec3 pos;
in vec3 normal;

flat in uint flag;
flat in vec3 Kd;
//uniform vec3 Kd = vec3(0.6, 0.8, 1);
uniform vec3 La = vec3(0, 0, 0);
uniform vec3 light_pos = vec3(0.f, 1.f, 0.f);
uniform vec3 light_pos = vec3(0.0f, 1.0f, 0.0f);

out vec4 frag_color; // final colour of surface

Expand All @@ -22,10 +22,10 @@ void main()
vec3 dist2eye = light_pos - pos;
vec3 dir = normalize(dist2eye);
float dot_prod = dot(dir, normal);
dot_prod = (dot_prod + 1.f) / 2.0;
dot_prod = (dot_prod + 1.0f) / 2.0f;
vec3 Id = mix(La, Kd, dot_prod); // final diffuse intensity
// final color
frag_color = vec4(Id, 1.f);
frag_color = vec4(Id, 1.0f);
}

}
7 changes: 3 additions & 4 deletions shaders/face_vs.glsl
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#version 330
in layout(location = 0) vec3 vp;
layout(location = 0) in vec3 vp;

uniform mat4 view_matrix;
uniform float scale = 1.f;
uniform float scale = 1.0f;

void main()
{
//gl_Position = proj_matrix * view_matrix * vec4(vp, 1.0);
gl_Position = view_matrix * vec4(scale * vp, 1.0);
gl_Position = view_matrix * vec4(scale * vp, 1.0f);
}
7 changes: 3 additions & 4 deletions shaders/uid_vs.glsl
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#version 330

in layout(location = 0) vec3 vp;
layout(location = 0) in vec3 vp;
uniform int mode = 0;

uniform mat4 view_matrix, proj_matrix;
uniform float scale = 1.f;
uniform float scale = 1.0f;

void main()
{
vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
if (mode > 0)
{
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
}
gl_Position = proj_matrix * vCam;

Expand Down
8 changes: 4 additions & 4 deletions shaders/vtx_vs.glsl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#version 330
in layout(location = 0) vec3 vp;// vertex position
//in layout(location = 1) uint vf;// vertex flag
layout(location = 0) in vec3 vp;// vertex position
//layout(location = 1) in uint vf;// vertex flag
uniform mat4 view_matrix, proj_matrix;
uniform float scale = 1.f;
uniform float scale = 1.0f;

uniform usamplerBuffer flag_tex;
flat out uint flag;

void main()
{
vec4 vCam = view_matrix * vec4(scale * vp, 1.0f);
vCam -= vec4(0.03125 * normalize(vCam.xyz), 0.f);
vCam -= vec4(0.03125f * normalize(vCam.xyz), 0.0f);
gl_Position = proj_matrix * vCam;

flag = texelFetch(flag_tex, gl_VertexID).r;
Expand Down
3 changes: 2 additions & 1 deletion src/MeshViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ MeshViewer::MeshViewer(QWidget *parent)
QSurfaceFormat format;
format.setDepthBufferSize(32);
format.setStencilBufferSize(8);
format.setSamples(9);
// To enable anti-aliasing, set sample to sampleNumber^2
//format.setSamples(9);
format.setVersion(3, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
this->setFormat(format);
Expand Down
6 changes: 3 additions & 3 deletions src/ViewerGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

const char* gridvs =
"#version 330\n"\
"in layout(location = 0) vec2 vp;"\
"layout(location = 0) in vec2 vp;"\
"uniform mat4 view, proj;"\
"uniform float size;"\
"void main() {"\
" gl_Position = proj * view * vec4(vp.x * size, 0.0, vp.y * size, 1.0);"\
" gl_Position = proj * view * vec4(vp.x * size, 0.0f, vp.y * size, 1.0f);"\
"}";

const char* gridfs =
"#version 330\n"\
"out vec4 frag_color;"\
"void main() {"\
" frag_color = vec4(0.5,0.5,0.5, 1.0);"\
" frag_color = vec4(0.5f, 0.5f, 0.5f, 1.0f);"\
"}";


Expand Down

0 comments on commit 7cf3acc

Please sign in to comment.