aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authortaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-12-21 21:36:52 +0000
committertaw27 <taw27@bf6ca9ba-c028-0410-8290-897cf20841d1>2007-12-21 21:36:52 +0000
commit2660887cf21229a888c5b1c02a6f07e653d1a55b (patch)
tree84868e33064cc9a7c61aaceb898971b66986e9b8 /data
parenta956795a03969c5aec307474400be402388c1430 (diff)
Fun with shaders
git-svn-id: svn://cook.msm.cam.ac.uk:745/diff-tomo/dtr@235 bf6ca9ba-c028-0410-8290-897cf20841d1
Diffstat (limited to 'data')
-rw-r--r--data/Makefile.am2
-rw-r--r--data/light-pp.frag40
-rw-r--r--data/light-pp.vert34
3 files changed, 75 insertions, 1 deletions
diff --git a/data/Makefile.am b/data/Makefile.am
index 717d3e5..2948e73 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,5 +1,5 @@
dtrdir = $(datadir)/dtr
-dtr_DATA = displaywindow.ui
+dtr_DATA = displaywindow.ui light-pp.vert light-pp.frag
iconsdir = $(datadir)/icons/hicolor/scalable/apps
icons_DATA = dtr-tiltaxis.svg dtr-dirax.svg dtr-refine.svg dtr-refineall.svg dtr-quantify.svg
diff --git a/data/light-pp.frag b/data/light-pp.frag
new file mode 100644
index 0000000..c862641
--- /dev/null
+++ b/data/light-pp.frag
@@ -0,0 +1,40 @@
+/*
+ * light-pp.frag
+ *
+ * Lighting per pixel
+ *
+ * (c) 2007 Thomas White <taw27@cam.ac.uk>
+ *
+ * dtr - Diffraction Tomography Reconstruction
+ *
+ */
+
+varying vec4 col_ambi;
+varying vec4 col_diff;
+varying vec4 col_spec;
+varying float shininess;
+
+varying vec3 normal;
+varying vec3 halfvc;
+
+void main() {
+
+ vec4 ambi;
+ vec4 diff;
+ vec4 spec;
+
+ /* Ambient contribution */
+ ambi = col_ambi * gl_LightModel.ambient;
+ ambi += col_ambi * gl_LightSource[0].ambient;
+
+ /* Diffuse contribution */
+ diff = col_diff * clamp(dot( vec3(normalize(gl_LightSource[0].position)), normal ), 0.0, 1.0);
+
+ /* Specular contribution */
+ spec = col_spec * pow(dot( vec3(normal), halfvc ), shininess);
+
+ gl_FragColor = ambi + diff + spec;
+ gl_FragColor.a = 1.0;
+
+}
+
diff --git a/data/light-pp.vert b/data/light-pp.vert
new file mode 100644
index 0000000..02ff444
--- /dev/null
+++ b/data/light-pp.vert
@@ -0,0 +1,34 @@
+/*
+ * light-pp.vert
+ *
+ * Lighting per pixel
+ *
+ * (c) 2007 Thomas White <taw27@cam.ac.uk>
+ *
+ * dtr - Diffraction Tomography Reconstruction
+ *
+ */
+
+varying vec4 col_ambi;
+varying vec4 col_diff;
+varying vec4 col_spec;
+varying float shininess;
+
+varying vec3 normal;
+varying vec3 halfvc;
+
+void main() {
+
+ normal = normalize(gl_NormalMatrix * gl_Normal);
+ halfvc = vec3(gl_LightSource[0].halfVector);
+
+ col_ambi = gl_FrontMaterial.ambient;
+ col_diff = gl_FrontMaterial.diffuse;
+ col_spec = gl_FrontMaterial.specular;
+
+ shininess = gl_FrontMaterial.shininess;
+
+ gl_Position = ftransform();
+
+}
+