summaryrefslogtreecommitdiffstats
path: root/src/GLSLShaderTest
diff options
context:
space:
mode:
Diffstat (limited to 'src/GLSLShaderTest')
-rw-r--r--src/GLSLShaderTest/ObjLoadGLSL.java340
-rw-r--r--src/GLSLShaderTest/PhongShadingGLSL.form138
-rw-r--r--src/GLSLShaderTest/PhongShadingGLSL.java448
-rw-r--r--src/GLSLShaderTest/ShaderTestGLSL.form266
-rw-r--r--src/GLSLShaderTest/ShaderTestGLSL.java666
-rw-r--r--src/GLSLShaderTest/SphereGLSL.java339
-rw-r--r--src/GLSLShaderTest/aabrick.frag55
-rw-r--r--src/GLSLShaderTest/aabrick.vert42
-rw-r--r--src/GLSLShaderTest/build.xml69
-rw-r--r--src/GLSLShaderTest/dimple.frag61
-rw-r--r--src/GLSLShaderTest/dimple.vert42
-rw-r--r--src/GLSLShaderTest/gouraud.frag50
-rw-r--r--src/GLSLShaderTest/gouraud.vert100
-rw-r--r--src/GLSLShaderTest/phong.frag98
-rw-r--r--src/GLSLShaderTest/phong.vert56
-rw-r--r--src/GLSLShaderTest/polkadot3d.frag48
-rw-r--r--src/GLSLShaderTest/polkadot3d.vert58
-rw-r--r--src/GLSLShaderTest/simple.frag62
-rw-r--r--src/GLSLShaderTest/simple.vert129
-rw-r--r--src/GLSLShaderTest/toon.frag34
-rw-r--r--src/GLSLShaderTest/toon.vert19
-rw-r--r--src/GLSLShaderTest/wood.frag66
-rw-r--r--src/GLSLShaderTest/wood.vert25
23 files changed, 0 insertions, 3211 deletions
diff --git a/src/GLSLShaderTest/ObjLoadGLSL.java b/src/GLSLShaderTest/ObjLoadGLSL.java
deleted file mode 100644
index 3c67b98..0000000
--- a/src/GLSLShaderTest/ObjLoadGLSL.java
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-import com.sun.j3d.loaders.objectfile.ObjectFile;
-import com.sun.j3d.loaders.ParsingErrorException;
-import com.sun.j3d.loaders.IncorrectFormatException;
-import com.sun.j3d.loaders.Scene;
-import com.sun.j3d.utils.shader.StringIO;
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import com.sun.j3d.utils.applet.MainFrame;
-import com.sun.j3d.utils.universe.*;
-import javax.media.j3d.*;
-import javax.vecmath.*;
-import java.util.Enumeration;
-import java.io.*;
-import com.sun.j3d.utils.behaviors.vp.*;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-public class ObjLoadGLSL extends Applet {
-
- private String shaderName = "polkadot3d";
- private boolean spin = false;
- private boolean noTriangulate = false;
- private boolean noStripify = false;
- private double creaseAngle = 60.0;
- private URL filename = null;
- private SimpleUniverse u;
- private BoundingSphere bounds;
-
- public BranchGroup createSceneGraph() {
- // Create the root of the branch graph
- BranchGroup objRoot = new BranchGroup();
-
- // Create a Transformgroup to scale all objects so they
- // appear in the scene.
- TransformGroup objScale = new TransformGroup();
- Transform3D t3d = new Transform3D();
- t3d.setScale(0.7);
- objScale.setTransform(t3d);
- objRoot.addChild(objScale);
-
- // Create the transform group node and initialize it to the
- // identity. Enable the TRANSFORM_WRITE capability so that
- // our behavior code can modify it at runtime. Add it to the
- // root of the subgraph.
- TransformGroup objTrans = new TransformGroup();
- objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
- objScale.addChild(objTrans);
-
- int flags = ObjectFile.RESIZE;
- if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
- if (!noStripify) flags |= ObjectFile.STRIPIFY;
- ObjectFile f = new ObjectFile(flags,
- (float)(creaseAngle * Math.PI / 180.0));
- Scene s = null;
- try {
- s = f.load(filename);
- }
- catch (FileNotFoundException e) {
- throw new RuntimeException(e);
- }
- catch (ParsingErrorException e) {
- throw new RuntimeException(e);
- }
- catch (IncorrectFormatException e) {
- throw new RuntimeException(e);
- }
-
- // Set vertex and fragment shader program for all Shape3D nodes in scene
- String vertexProgram = null;
- String fragmentProgram = null;
- try {
- vertexProgram = StringIO.readFully(shaderName + ".vert");
- fragmentProgram = StringIO.readFully(shaderName + ".frag");
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- Shader[] shaders = new Shader[2];
- shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_VERTEX,
- vertexProgram);
- shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_FRAGMENT,
- fragmentProgram);
- ShaderProgram shaderProgram = new GLSLShaderProgram();
- shaderProgram.setShaders(shaders);
- setShaderProgram(s.getSceneGroup(), shaderProgram);
-
- objTrans.addChild(s.getSceneGroup());
-
- bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
-
- if (spin) {
- Transform3D yAxis = new Transform3D();
- Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
- 0, 0,
- 4000, 0, 0,
- 0, 0, 0);
-
- RotationInterpolator rotator =
- new RotationInterpolator(rotationAlpha, objTrans, yAxis,
- 0.0f, (float) Math.PI*2.0f);
- rotator.setSchedulingBounds(bounds);
- objTrans.addChild(rotator);
- }
-
- // Set up the background
- Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
- Background bgNode = new Background(bgColor);
- bgNode.setApplicationBounds(bounds);
- objRoot.addChild(bgNode);
-
- return objRoot;
- }
-
- private void usage()
- {
- System.out.println(
- "Usage: java ObjLoadGLSL [-s] [-S shaderName] [-n] [-t] [-c degrees] <.obj file>");
- System.out.println(" -s Spin (no user interaction)");
- System.out.println(" -S Set shader name (default is 'simple')");
- System.out.println(" -n No triangulation");
- System.out.println(" -t No stripification");
- System.out.println(
- " -c Set crease angle for normal generation (default is 60 without");
- System.out.println(
- " smoothing group info, otherwise 180 within smoothing groups)");
- System.exit(0);
- } // End of usage
-
-
-
- public void init() {
- if (filename == null) {
- // Applet
- try {
- URL path = getCodeBase();
- filename = new URL(path.toString() + "./galleon.obj");
- }
- catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
-
- setLayout(new BorderLayout());
- GraphicsConfiguration config =
- SimpleUniverse.getPreferredConfiguration();
-
- Canvas3D c = new Canvas3D(config);
- add("Center", c);
-
- // Create a simple scene and attach it to the virtual universe
- BranchGroup scene = createSceneGraph();
- u = new SimpleUniverse(c);
-
- // add mouse behaviors to the ViewingPlatform
- ViewingPlatform viewingPlatform = u.getViewingPlatform();
-
- PlatformGeometry pg = new PlatformGeometry();
-
- // Set up the ambient light
- Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
- AmbientLight ambientLightNode = new AmbientLight(ambientColor);
- ambientLightNode.setInfluencingBounds(bounds);
- pg.addChild(ambientLightNode);
-
- // Set up the directional lights
- Color3f light1Color = new Color3f(1.0f, 0.2f, 0.4f);
- Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
- Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f);
- Vector3f light2Direction = new Vector3f(1.0f, 1.0f, 1.0f);
-
- DirectionalLight light1
- = new DirectionalLight(light1Color, light1Direction);
- light1.setInfluencingBounds(bounds);
- pg.addChild(light1);
-
- DirectionalLight light2
- = new DirectionalLight(light2Color, light2Direction);
- light2.setInfluencingBounds(bounds);
- pg.addChild(light2);
-
- viewingPlatform.setPlatformGeometry( pg );
-
- // This will move the ViewPlatform back a bit so the
- // objects in the scene can be viewed.
- viewingPlatform.setNominalViewingTransform();
-
- if (!spin) {
- OrbitBehavior orbit = new OrbitBehavior(c,
- OrbitBehavior.REVERSE_ALL);
- BoundingSphere bounds =
- new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
- orbit.setSchedulingBounds(bounds);
- viewingPlatform.setViewPlatformBehavior(orbit);
- }
-
- /*
- // Limit the frame rate to 100 Hz
- u.getViewer().getView().setMinimumFrameCycleTime(10);
- */
-
- u.addBranchGraph(scene);
- }
-
- // Set shader program for all nodes in specified branch graph
- private void setShaderProgram(BranchGroup g, ShaderProgram shaderProgram) {
- ShaderAppearance myApp = new ShaderAppearance();
- Material mat = new Material();
- myApp.setShaderProgram(shaderProgram);
- myApp.setMaterial(mat);
- setShaderProgram(g, myApp);
- }
-
- // Recursively set shader program for all children of specified group
- private void setShaderProgram(Group g,
- ShaderAppearance myApp) {
-
- Enumeration e = g.getAllChildren();
- while (e.hasMoreElements()) {
- Node n = (Node)(e.nextElement());
- if (n instanceof Group) {
- setShaderProgram((Group)n, myApp);
- }
- else if (n instanceof Shape3D) {
- Shape3D s = (Shape3D)n;
- s.setAppearance(myApp);
- }
- }
- }
-
- // Caled if running as a program
- public ObjLoadGLSL(String[] args) {
- if (args.length != 0) {
- for (int i = 0 ; i < args.length ; i++) {
- if (args[i].startsWith("-")) {
- if (args[i].equals("-s")) {
- spin = true;
- } else if (args[i].equals("-n")) {
- noTriangulate = true;
- } else if (args[i].equals("-t")) {
- noStripify = true;
- } else if (args[i].equals("-c")) {
- if (i < args.length - 1) {
- creaseAngle = (new Double(args[++i])).doubleValue();
- } else usage();
- } else if (args[i].equals("-S")) {
- if (i < args.length - 1) {
- shaderName = args[++i];
- } else usage();
- } else {
- usage();
- }
- } else {
- try {
- if ((args[i].indexOf("file:") == 0) ||
- (args[i].indexOf("http") == 0)) {
- filename = new URL(args[i]);
- }
- else if (args[i].charAt(0) != '/') {
- filename = new URL("file:./" + args[i]);
- }
- else {
- filename = new URL("file:" + args[i]);
- }
- }
- catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
- }
- }
- }
-
-
-
- // Running as an applet
- public ObjLoadGLSL() {
- }
-
- public void destroy() {
- u.cleanup();
- }
-
-
-
- //
- // The following allows ObjLoadGLSL to be run as an application
- // as well as an applet
- //
- public static void main(String[] args) {
- new MainFrame(new ObjLoadGLSL(args), 700, 700);
- }
-}
diff --git a/src/GLSLShaderTest/PhongShadingGLSL.form b/src/GLSLShaderTest/PhongShadingGLSL.form
deleted file mode 100644
index dcccf73..0000000
--- a/src/GLSLShaderTest/PhongShadingGLSL.form
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
- <NonVisualComponents>
- <Component class="javax.swing.ButtonGroup" name="shaderButtonGroup">
- </Component>
- <Menu class="javax.swing.JMenuBar" name="jMenuBar1">
- <SubComponents>
- <Menu class="javax.swing.JMenu" name="fileMenu">
- <Properties>
- <Property name="text" type="java.lang.String" value="File"/>
- </Properties>
- <SubComponents>
- <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
- <Properties>
- <Property name="text" type="java.lang.String" value="Exit"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
- </Events>
- </MenuItem>
- </SubComponents>
- </Menu>
- </SubComponents>
- </Menu>
- </NonVisualComponents>
- <Properties>
- <Property name="defaultCloseOperation" type="int" value="3"/>
- <Property name="title" type="java.lang.String" value="Phong Shading Test"/>
- </Properties>
- <SyntheticProperties>
- <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
- <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
- </SyntheticProperties>
- <AuxValues>
- <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
- </AuxValues>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
- <SubComponents>
- <Container class="javax.swing.JPanel" name="guiPanel">
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="North"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
- <SubComponents>
- <Container class="javax.swing.JPanel" name="jPanel1">
- <Properties>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
- <TitledBorder title="Shader"/>
- </Border>
- </Property>
- </Properties>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="4" insetsLeft="4" insetsBottom="4" insetsRight="4" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
- <SubComponents>
- <Component class="javax.swing.JRadioButton" name="gouraudButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="shaderButtonGroup"/>
- </Property>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="Per-Vertex Lighting (Gouraud)"/>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
- <EmptyBorder bottom="0" left="0" right="0" top="0"/>
- </Border>
- </Property>
- <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
- <Insets value="[0, 0, 0, 0]"/>
- </Property>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="gouraudButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JRadioButton" name="phongButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="shaderButtonGroup"/>
- </Property>
- <Property name="text" type="java.lang.String" value="Per-Pixel Lighting (Phong)"/>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
- <EmptyBorder bottom="0" left="0" right="0" top="0"/>
- </Border>
- </Property>
- <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
- <Insets value="[0, 0, 0, 0]"/>
- </Property>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="phongButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- </SubComponents>
- </Container>
- </SubComponents>
- </Container>
- <Container class="javax.swing.JPanel" name="drawingPanel">
- <Properties>
- <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
- <Dimension value="[500, 500]"/>
- </Property>
- </Properties>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="Center"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
- </Container>
- </SubComponents>
-</Form>
diff --git a/src/GLSLShaderTest/PhongShadingGLSL.java b/src/GLSLShaderTest/PhongShadingGLSL.java
deleted file mode 100644
index 5711ff8..0000000
--- a/src/GLSLShaderTest/PhongShadingGLSL.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-import com.sun.j3d.utils.geometry.Sphere;
-import com.sun.j3d.utils.shader.StringIO;
-import com.sun.j3d.utils.universe.*;
-import javax.media.j3d.*;
-import javax.vecmath.*;
-import java.awt.GraphicsConfiguration;
-import java.io.IOException;
-
-/**
- *
- * @author kcr
- */
-public class PhongShadingGLSL extends javax.swing.JFrame {
-
- // Constants for type of light to use
- private static final int DIRECTIONAL_LIGHT = 0;
- private static final int POINT_LIGHT = 1;
- private static final int SPOT_LIGHT = 2;
-
- // Flag indicates type of lights: directional, point, or spot lights.
- private static int lightType = DIRECTIONAL_LIGHT;
-
- private SimpleUniverse u = null;
-
- private ShaderAppearance sApp = null;
- private ShaderProgram gouraudSP = null;
- private ShaderProgram phongSP = null;
-
- public BranchGroup createSceneGraph() {
- Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
- Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f);
- Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
-// Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f);
-// Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f);
- Color3f lColor1 = new Color3f(1.0f, 1.0f, 0.5f);
- Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
- Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
-
- Transform3D t;
-
- // Create the root of the branch graph
- BranchGroup objRoot = new BranchGroup();
-
- // Create a Transformgroup to scale all objects so they
- // appear in the scene.
- TransformGroup objScale = new TransformGroup();
- Transform3D t3d = new Transform3D();
- t3d.setScale(0.5);
- objScale.setTransform(t3d);
- objRoot.addChild(objScale);
-
- // Create a bounds for the background and lights
- BoundingSphere bounds =
- new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
-
- // Set up the background
- Background bg = new Background(bgColor);
- bg.setApplicationBounds(bounds);
- objRoot.addChild(bg);
-
- // Create the TransformGroup node and initialize it to the
- // identity. Enable the TRANSFORM_WRITE capability so that
- // our behavior code can modify it at run time. Add it to
- // the root of the subgraph.
- TransformGroup objTrans = new TransformGroup();
- objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objScale.addChild(objTrans);
-
- // Create a Sphere object, generate one copy of the sphere,
- // and add it into the scene graph.
- sApp = new ShaderAppearance();
- sApp.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE);
- Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
- sApp.setMaterial(m);
-
- // Create Gouraud and Phong shader programs
- String vertexProgram = null;
- String fragmentProgram = null;
- Shader[] shaders = new Shader[2];
- String[] attrNames = { "numLights" };
-
- try {
- vertexProgram = StringIO.readFully("./gouraud.vert");
- fragmentProgram = StringIO.readFully("./gouraud.frag");
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_VERTEX,
- vertexProgram);
- shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_FRAGMENT,
- fragmentProgram);
- gouraudSP = new GLSLShaderProgram();
- gouraudSP.setShaders(shaders);
-
- try {
- vertexProgram = StringIO.readFully("./phong.vert");
- fragmentProgram = StringIO.readFully("./phong.frag");
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_VERTEX,
- vertexProgram);
- shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_FRAGMENT,
- fragmentProgram);
- phongSP = new GLSLShaderProgram();
- phongSP.setShaders(shaders);
-
- if (gouraudButton.isSelected()) {
- sApp.setShaderProgram(gouraudSP);
- } else if (phongButton.isSelected()) {
- sApp.setShaderProgram(phongSP);
- }
- Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 30, sApp);
- objTrans.addChild(sph);
-
- // Create a new Behavior object that will perform the
- // desired operation on the specified transform and add
- // it into the scene graph.
- Transform3D yAxis = new Transform3D();
- yAxis.rotZ(Math.PI);
- Alpha rotationAlpha = new Alpha(-1, 10000);
-
- RotationInterpolator rotator =
- new RotationInterpolator(rotationAlpha, objTrans, yAxis,
- 0.0f, (float) Math.PI*2.0f);
- rotator.setSchedulingBounds(bounds);
- objRoot.addChild(rotator);
-
- // Create the transform group node for the each light and initialize
- // it to the identity. Enable the TRANSFORM_WRITE capability so that
- // our behavior code can modify it at runtime. Add them to the root
- // of the subgraph.
- TransformGroup l1RotTrans = new TransformGroup();
- l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objScale.addChild(l1RotTrans);
-
- TransformGroup l2RotTrans = new TransformGroup();
- l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objScale.addChild(l2RotTrans);
-
- // Create transformations for the positional lights
- t = new Transform3D();
- Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0);
- t.set(lPos1);
- TransformGroup l1Trans = new TransformGroup(t);
- l1RotTrans.addChild(l1Trans);
-
-// t = new Transform3D();
-// Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0);
-// t.set(lPos2);
-// TransformGroup l2Trans = new TransformGroup(t);
-// l2RotTrans.addChild(l2Trans);
-
- // Create Geometry for point lights
- ColoringAttributes caL1 = new ColoringAttributes();
-// ColoringAttributes caL2 = new ColoringAttributes();
- caL1.setColor(lColor1);
-// caL2.setColor(lColor2);
- Appearance appL1 = new Appearance();
-// Appearance appL2 = new Appearance();
- appL1.setColoringAttributes(caL1);
-// appL2.setColoringAttributes(caL2);
- l1Trans.addChild(new Sphere(0.05f, appL1));
-// l2Trans.addChild(new Sphere(0.05f, appL2));
-
- // Create lights
- AmbientLight aLgt = new AmbientLight(alColor);
-
- Light lgt1 = null;
-// Light lgt2 = null;
-
- Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f);
- Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
- Vector3f lDirect1 = new Vector3f(lPos1);
-// Vector3f lDirect2 = new Vector3f(lPos2);
- lDirect1.negate();
-// lDirect2.negate();
-
- switch (lightType) {
- case DIRECTIONAL_LIGHT:
- lgt1 = new DirectionalLight(lColor1, lDirect1);
-// lgt2 = new DirectionalLight(lColor2, lDirect2);
- break;
- case POINT_LIGHT:
- assert false : "can't get here";
- lgt1 = new PointLight(lColor1, lPoint, atten);
-// lgt2 = new PointLight(lColor2, lPoint, atten);
- break;
- case SPOT_LIGHT:
- assert false : "can't get here";
- lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1,
- 25.0f * (float)Math.PI / 180.0f, 10.0f);
-// lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2,
-// 25.0f * (float)Math.PI / 180.0f, 10.0f);
- break;
- }
-
- // Set the influencing bounds
- aLgt.setInfluencingBounds(bounds);
- lgt1.setInfluencingBounds(bounds);
-// lgt2.setInfluencingBounds(bounds);
-
- // Add the lights into the scene graph
- objScale.addChild(aLgt);
- l1Trans.addChild(lgt1);
-// l2Trans.addChild(lgt2);
-
- // Create a new Behavior object that will perform the desired
- // operation on the specified transform object and add it into the
- // scene graph.
- yAxis = new Transform3D();
- Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
- 0, 0,
- 4000, 0, 0,
- 0, 0, 0);
- RotationInterpolator rotator1 =
- new RotationInterpolator(rotor1Alpha,
- l1RotTrans,
- yAxis,
- 0.0f, (float) Math.PI*2.0f);
- rotator1.setSchedulingBounds(bounds);
- l1RotTrans.addChild(rotator1);
-
- // Create a new Behavior object that will perform the desired
- // operation on the specified transform object and add it into the
- // scene graph.
- Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
- 0, 0,
- 1000, 0, 0,
- 0, 0, 0);
- RotationInterpolator rotator2 =
- new RotationInterpolator(rotor2Alpha,
- l2RotTrans,
- yAxis,
- 0.0f, 0.0f);
- bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
- rotator2.setSchedulingBounds(bounds);
- l2RotTrans.addChild(rotator2);
-
- return objRoot;
- }
-
- private Canvas3D initScene() {
- GraphicsConfiguration config =
- SimpleUniverse.getPreferredConfiguration();
-
- Canvas3D c = new Canvas3D(config);
-
- u = new SimpleUniverse(c);
-
- // This will move the ViewPlatform back a bit so the
- // objects in the scene can be viewed.
- u.getViewingPlatform().setNominalViewingTransform();
-
- BranchGroup scene = createSceneGraph();
- u.addBranchGraph(scene);
-
- return c;
- }
-
- /**
- * Creates new form PhongShadingGLSL
- */
- public PhongShadingGLSL() {
- // Initialize the GUI components
- initComponents();
-
- // Create the scene and add the Canvas3D to the drawing panel
- Canvas3D c = initScene();
- drawingPanel.add(c, java.awt.BorderLayout.CENTER);
- }
-
- // ----------------------------------------------------------------
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
- private void initComponents() {
- java.awt.GridBagConstraints gridBagConstraints;
-
- shaderButtonGroup = new javax.swing.ButtonGroup();
- guiPanel = new javax.swing.JPanel();
- jPanel1 = new javax.swing.JPanel();
- gouraudButton = new javax.swing.JRadioButton();
- phongButton = new javax.swing.JRadioButton();
- drawingPanel = new javax.swing.JPanel();
- jMenuBar1 = new javax.swing.JMenuBar();
- fileMenu = new javax.swing.JMenu();
- exitMenuItem = new javax.swing.JMenuItem();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setTitle("Phong Shading Test");
- guiPanel.setLayout(new java.awt.GridBagLayout());
-
- jPanel1.setLayout(new java.awt.GridBagLayout());
-
- jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Shader"));
- shaderButtonGroup.add(gouraudButton);
- gouraudButton.setSelected(true);
- gouraudButton.setText("Per-Vertex Lighting (Gouraud)");
- gouraudButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
- gouraudButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
- gouraudButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- gouraudButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
- jPanel1.add(gouraudButton, gridBagConstraints);
-
- shaderButtonGroup.add(phongButton);
- phongButton.setText("Per-Pixel Lighting (Phong)");
- phongButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
- phongButton.setMargin(new java.awt.Insets(0, 0, 0, 0));
- phongButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- phongButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
- jPanel1.add(phongButton, gridBagConstraints);
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);
- guiPanel.add(jPanel1, gridBagConstraints);
-
- getContentPane().add(guiPanel, java.awt.BorderLayout.NORTH);
-
- drawingPanel.setLayout(new java.awt.BorderLayout());
-
- drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500));
- getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER);
-
- fileMenu.setText("File");
- exitMenuItem.setText("Exit");
- exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitMenuItemActionPerformed(evt);
- }
- });
-
- fileMenu.add(exitMenuItem);
-
- jMenuBar1.add(fileMenu);
-
- setJMenuBar(jMenuBar1);
-
- pack();
- }// </editor-fold>//GEN-END:initComponents
-
- private void phongButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_phongButtonActionPerformed
- sApp.setShaderProgram(phongSP);
- }//GEN-LAST:event_phongButtonActionPerformed
-
- private void gouraudButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gouraudButtonActionPerformed
- sApp.setShaderProgram(gouraudSP);
- }//GEN-LAST:event_gouraudButtonActionPerformed
-
- private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
- System.exit(0);
- }//GEN-LAST:event_exitMenuItemActionPerformed
-
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new PhongShadingGLSL().setVisible(true);
- }
- });
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel drawingPanel;
- private javax.swing.JMenuItem exitMenuItem;
- private javax.swing.JMenu fileMenu;
- private javax.swing.JRadioButton gouraudButton;
- private javax.swing.JPanel guiPanel;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JRadioButton phongButton;
- private javax.swing.ButtonGroup shaderButtonGroup;
- // End of variables declaration//GEN-END:variables
-
-}
diff --git a/src/GLSLShaderTest/ShaderTestGLSL.form b/src/GLSLShaderTest/ShaderTestGLSL.form
deleted file mode 100644
index 714273d..0000000
--- a/src/GLSLShaderTest/ShaderTestGLSL.form
+++ /dev/null
@@ -1,266 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
- <NonVisualComponents>
- <Component class="javax.swing.ButtonGroup" name="densityButtonGroup">
- </Component>
- <Component class="javax.swing.ButtonGroup" name="colorButtonGroup">
- </Component>
- <Component class="javax.swing.ButtonGroup" name="sceneGraphButtonGroup">
- </Component>
- <Menu class="javax.swing.JMenuBar" name="jMenuBar1">
- <SubComponents>
- <Menu class="javax.swing.JMenu" name="fileMenu">
- <Properties>
- <Property name="text" type="java.lang.String" value="File"/>
- </Properties>
- <SubComponents>
- <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem">
- <Properties>
- <Property name="text" type="java.lang.String" value="Exit"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/>
- </Events>
- </MenuItem>
- </SubComponents>
- </Menu>
- </SubComponents>
- </Menu>
- </NonVisualComponents>
- <Properties>
- <Property name="title" type="java.lang.String" value="Window Title"/>
- </Properties>
- <SyntheticProperties>
- <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
- <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
- </SyntheticProperties>
- <Events>
- <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/>
- </Events>
- <AuxValues>
- <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
- <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
- <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-85,0,0,2,0"/>
- </AuxValues>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
- <SubComponents>
- <Container class="javax.swing.JPanel" name="mainPanel">
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="Center"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
- <SubComponents>
- <Container class="javax.swing.JPanel" name="guiPanel">
- <Properties>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
- <LineBorder/>
- </Border>
- </Property>
- </Properties>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="North"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
- <SubComponents>
- <Container class="javax.swing.JPanel" name="densityPanel">
- <Properties>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
- <TitledBorder title="Density"/>
- </Border>
- </Property>
- </Properties>
- <AccessibilityProperties>
- <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="ShaderAttributeValue &#xa;"/>
- </AccessibilityProperties>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
- <SubComponents>
- <Component class="javax.swing.JRadioButton" name="zeroButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="densityButtonGroup"/>
- </Property>
- <Property name="text" type="java.lang.String" value="Zero"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="zeroButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JRadioButton" name="halfButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="densityButtonGroup"/>
- </Property>
- <Property name="text" type="java.lang.String" value="Half"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="halfButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JRadioButton" name="fullButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="densityButtonGroup"/>
- </Property>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="Full"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fullButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- </SubComponents>
- </Container>
- <Container class="javax.swing.JPanel" name="colorPanel">
- <Properties>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
- <TitledBorder title="Color"/>
- </Border>
- </Property>
- </Properties>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
- <SubComponents>
- <Component class="javax.swing.JRadioButton" name="goldButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="colorButtonGroup"/>
- </Property>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="Gold"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="goldButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JRadioButton" name="silverButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="colorButtonGroup"/>
- </Property>
- <Property name="text" type="java.lang.String" value="Silver"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="silverButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- </SubComponents>
- </Container>
- <Container class="javax.swing.JPanel" name="sceneGraphPanel">
- <Properties>
- <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
- <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
- <TitledBorder title="Scene Graph"/>
- </Border>
- </Property>
- </Properties>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
- <SubComponents>
- <Component class="javax.swing.JToggleButton" name="DetachButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="sceneGraphButtonGroup"/>
- </Property>
- <Property name="selected" type="boolean" value="true"/>
- <Property name="text" type="java.lang.String" value="Detach"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="DetachButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JToggleButton" name="AttachButton">
- <Properties>
- <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
- <ComponentRef name="sceneGraphButtonGroup"/>
- </Property>
- <Property name="text" type="java.lang.String" value="Create"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="AttachButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- <Component class="javax.swing.JButton" name="replaceSPButton">
- <Properties>
- <Property name="text" type="java.lang.String" value="Replace Shader"/>
- <Property name="enabled" type="boolean" value="false"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="replaceSPButtonActionPerformed"/>
- </Events>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
- </Constraint>
- </Constraints>
- </Component>
- </SubComponents>
- </Container>
- </SubComponents>
- </Container>
- <Container class="javax.swing.JPanel" name="drawingPanel">
- <Properties>
- <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
- <Dimension value="[500, 500]"/>
- </Property>
- </Properties>
- <Constraints>
- <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
- <BorderConstraints direction="Center"/>
- </Constraint>
- </Constraints>
-
- <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
- </Container>
- </SubComponents>
- </Container>
- </SubComponents>
-</Form>
diff --git a/src/GLSLShaderTest/ShaderTestGLSL.java b/src/GLSLShaderTest/ShaderTestGLSL.java
deleted file mode 100644
index b96ea42..0000000
--- a/src/GLSLShaderTest/ShaderTestGLSL.java
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-import com.sun.j3d.utils.geometry.Sphere;
-import com.sun.j3d.utils.shader.StringIO;
-import com.sun.j3d.utils.universe.*;
-import javax.media.j3d.*;
-import javax.vecmath.*;
-import java.awt.GraphicsConfiguration;
-import java.io.IOException;
-
-public class ShaderTestGLSL extends javax.swing.JFrame {
-
- static final int GOLD = 1;
- static final int SILVER = 2;
-
- static final int DIMPLE_SHADER = 1;
- static final int BRICK_SHADER = 2;
- static final int WOOD_SHADER = 3;
- static final int POLKADOT3D_SHADER = 4;
-
- static final String[] shaderAttrNames1 = {
- "Density", "Size", "LightPosition", "Color"
- };
-
- static final String[] shaderAttrNames2 = {
- "BrickColor", "LightPosition"
- };
-
- private SimpleUniverse u = null;
- private View view;
- private BranchGroup transpObj;
- private BranchGroup scene = null;
- private int shaderSelected = DIMPLE_SHADER;
- private float density = 16.0f;
- private int color = GOLD;
-
- private Color3f eColor = new Color3f(0.2f, 0.2f, 0.2f);
- private Color3f sColor = new Color3f(0.8f, 0.8f, 0.8f);
- private Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
- private Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
- private Color3f gold = new Color3f(0.7f, 0.6f, 0.18f);
- private Color3f silver = new Color3f(0.75f, 0.75f, 0.75f);
-
- // Handlers for doing update
- private ShaderAppearance sApp1 = null;
- private ShaderAppearance sApp2 = null;
- private ShaderAppearance sApp3 = null;
- private ShaderAppearance sApp4 = null;
- private ShaderProgram sp1 = null;
- private ShaderProgram sp2 = null;
- private ShaderProgram sp3 = null;
- private ShaderProgram sp4 = null;
- private ShaderAttributeSet sas1 = null;
- private ShaderAttributeSet sas2 = null;
- private ShaderAttributeObject sao1 = null;
- private ShaderAttributeObject sao2 = null;
- private Sphere sphere = null;
- private Shape3D s3d = null;
-
- private Material createMaterial() {
- Material m;
- m = new Material(objColor, eColor, objColor, sColor, 100.0f);
- m.setLightingEnable(true);
- return m;
- }
-
- private ShaderProgram createGLSLShaderProgram(int index) {
- String vertexProgram = null;
- String fragmentProgram = null;
- try {
- switch (index) {
- case DIMPLE_SHADER:
- vertexProgram = StringIO.readFully("./dimple.vert");
- fragmentProgram = StringIO.readFully("./dimple.frag");
- break;
- case BRICK_SHADER:
- vertexProgram = StringIO.readFully("./aabrick.vert");
- fragmentProgram = StringIO.readFully("./aabrick.frag");
- break;
- case WOOD_SHADER:
- vertexProgram = StringIO.readFully("./wood.vert");
- fragmentProgram = StringIO.readFully("./wood.frag");
- break;
- case POLKADOT3D_SHADER:
- vertexProgram = StringIO.readFully("./polkadot3d.vert");
- fragmentProgram = StringIO.readFully("./polkadot3d.frag");
- break;
- default:
- }
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- Shader[] shaders = new Shader[2];
- shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_VERTEX,
- vertexProgram);
- shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_FRAGMENT,
- fragmentProgram);
- ShaderProgram shaderProgram = new GLSLShaderProgram();
- shaderProgram.setShaders(shaders);
- return shaderProgram;
- }
-
- private ShaderAttributeSet createShaderAttributeSet(int index) {
- ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet();
- ShaderAttributeObject shaderAttribute = null;
-
- switch (index) {
- case DIMPLE_SHADER:
- // "Density", "Size", "Scale", "Color", "LightPosition"
- shaderAttribute = new ShaderAttributeValue("Size", new Float(0.25));
- shaderAttributeSet.put(shaderAttribute);
- shaderAttribute = new ShaderAttributeValue("LightPosition",
- new Point3f(0.0f, 0.0f, 0.5f));
- shaderAttributeSet.put(shaderAttribute);
-
- sao1 = new ShaderAttributeValue("Density", new Float(density));
- sao1.setCapability(ShaderAttributeObject.ALLOW_VALUE_READ);
- sao1.setCapability(ShaderAttributeObject.ALLOW_VALUE_WRITE);
- shaderAttributeSet.put(sao1);
-
- if(color == GOLD) {
- sao2 = new ShaderAttributeValue("Color", gold);
- }
- else if (color == SILVER) {
- sao2 = new ShaderAttributeValue("Color", silver);
- }
- sao2.setCapability(ShaderAttributeObject.ALLOW_VALUE_READ);
- sao2.setCapability(ShaderAttributeObject.ALLOW_VALUE_WRITE);
- shaderAttributeSet.put(sao2);
- break;
-
- case BRICK_SHADER:
- // "BrickColor", "LightPosition"
- shaderAttribute = new ShaderAttributeValue("BrickColor",
- new Color3f(1.0f, 0.3f, 0.2f));
- shaderAttributeSet.put(shaderAttribute);
- shaderAttribute = new ShaderAttributeValue("LightPosition",
- new Point3f(0.0f, 0.0f, 0.5f));
- shaderAttributeSet.put(shaderAttribute);
- break;
- default:
- assert false;
- }
- return shaderAttributeSet;
- }
-
- private ShaderAppearance createShaderAppearance() {
- ShaderAppearance sApp = new ShaderAppearance();
- sApp.setMaterial(createMaterial());
- return sApp;
- }
-
-
- private BranchGroup createSubSceneGraph() {
- // Create the sub-root of the branch graph
- BranchGroup subRoot = new BranchGroup();
-
- //
- // Create 1 spheres with a GLSLShader and add it into the scene graph.
- //
- sApp1 = createShaderAppearance();
- sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_READ);
- sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE);
- sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_READ);
- sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_WRITE);
-
- sp1 = createGLSLShaderProgram(1);
- sp1.setShaderAttrNames(shaderAttrNames1);
- sas1 = createShaderAttributeSet(1);
- sas1.setCapability(ShaderAttributeSet.ALLOW_ATTRIBUTES_READ);
- sas1.setCapability(ShaderAttributeSet.ALLOW_ATTRIBUTES_WRITE);
- sApp1.setShaderProgram(sp1);
- sApp1.setShaderAttributeSet(sas1);
-
- // Setup Brick shader
- sp2 = createGLSLShaderProgram(2);
- sp2.setShaderAttrNames(shaderAttrNames2);
- sas2 = createShaderAttributeSet(2);
- sApp2 = createShaderAppearance();
- sApp2.setShaderProgram(sp2);
- sApp2.setShaderAttributeSet(sas2);
-
- // Setup Wood shader
- sp3 = createGLSLShaderProgram(3);
- sApp3 = createShaderAppearance();
- sApp3.setShaderProgram(sp3);
-
- // Setup Polkadot3d shader
- sp4 = createGLSLShaderProgram(4);
- sApp4 = createShaderAppearance();
- sApp4.setShaderProgram(sp4);
-
- sphere = new Sphere(1.5f, Sphere.GENERATE_NORMALS, 200, null);
- s3d = (Shape3D)sphere.getShape();
- s3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
- s3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
- s3d.setAppearance(sApp1);
-
- TransformGroup objTG;
- Transform3D t = new Transform3D();
- t.set(new Vector3d(0.0, 0.0, 0.0));
- objTG = new TransformGroup(t);
- objTG.addChild(sphere);
- subRoot.addChild(objTG);
-
- return subRoot;
- }
-
- private BranchGroup createSceneGraph(int selectedScene) {
- // Create the root of the branch graph
- BranchGroup objRoot = new BranchGroup();
- objRoot.setCapability(BranchGroup.ALLOW_DETACH);
-
- // Create a Transformgroup to scale all objects so they
- // appear in the scene.
- TransformGroup objScale = new TransformGroup();
- Transform3D t3d = new Transform3D();
- t3d.setScale(0.4);
- objScale.setTransform(t3d);
- objRoot.addChild(objScale);
-
- // Create a bounds for the background and lights
- BoundingSphere bounds =
- new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
-
- // Set up the background
- Background bg = new Background(bgColor);
- bg.setApplicationBounds(bounds);
- objScale.addChild(bg);
-
- objScale.addChild(createSubSceneGraph());
-
- // Create a position interpolator and attach it to the view
- // platform
- TransformGroup vpTrans =
- u.getViewingPlatform().getViewPlatformTransform();
- Transform3D axisOfTranslation = new Transform3D();
- Alpha transAlpha = new Alpha(-1,
- Alpha.INCREASING_ENABLE |
- Alpha.DECREASING_ENABLE,
- 0, 0,
- 5000, 0, 0,
- 5000, 0, 0);
- axisOfTranslation.rotY(-Math.PI/2.0);
- PositionInterpolator translator =
- new PositionInterpolator(transAlpha,
- vpTrans,
- axisOfTranslation,
- 2.0f, 3.5f);
- translator.setSchedulingBounds(bounds);
- objScale.addChild(translator);
-
- // Let Java 3D perform optimizations on this scene graph.
- objRoot.compile();
-
- return objRoot;
- }
-
- private Canvas3D initScene() {
- GraphicsConfiguration config =
- SimpleUniverse.getPreferredConfiguration();
-
- Canvas3D c = new Canvas3D(config);
-
- u = new SimpleUniverse(c);
-
- ViewingPlatform viewingPlatform = u.getViewingPlatform();
- // This will move the ViewPlatform back a bit so the
- // objects in the scene can be viewed.
- viewingPlatform.setNominalViewingTransform();
-
- view = u.getViewer().getView();
-
- return c;
- }
-
- /**
- * Creates new form ShaderTestGLSL
- */
- public ShaderTestGLSL() {
- // Initialize the GUI components
- initComponents();
-
- // Create the scene and add the Canvas3D to the drawing panel
- Canvas3D c = initScene();
- drawingPanel.add(c, java.awt.BorderLayout.CENTER);
- }
-
-
- // ----------------------------------------------------------------
-
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
- private void initComponents() {
- java.awt.GridBagConstraints gridBagConstraints;
-
- densityButtonGroup = new javax.swing.ButtonGroup();
- colorButtonGroup = new javax.swing.ButtonGroup();
- sceneGraphButtonGroup = new javax.swing.ButtonGroup();
- mainPanel = new javax.swing.JPanel();
- guiPanel = new javax.swing.JPanel();
- densityPanel = new javax.swing.JPanel();
- zeroButton = new javax.swing.JRadioButton();
- halfButton = new javax.swing.JRadioButton();
- fullButton = new javax.swing.JRadioButton();
- colorPanel = new javax.swing.JPanel();
- goldButton = new javax.swing.JRadioButton();
- silverButton = new javax.swing.JRadioButton();
- sceneGraphPanel = new javax.swing.JPanel();
- DetachButton = new javax.swing.JToggleButton();
- AttachButton = new javax.swing.JToggleButton();
- replaceSPButton = new javax.swing.JButton();
- drawingPanel = new javax.swing.JPanel();
- jMenuBar1 = new javax.swing.JMenuBar();
- fileMenu = new javax.swing.JMenu();
- exitMenuItem = new javax.swing.JMenuItem();
-
- setTitle("Window Title");
- addWindowListener(new java.awt.event.WindowAdapter() {
- public void windowClosing(java.awt.event.WindowEvent evt) {
- exitForm(evt);
- }
- });
-
- mainPanel.setLayout(new java.awt.BorderLayout());
-
- guiPanel.setLayout(new javax.swing.BoxLayout(guiPanel, javax.swing.BoxLayout.X_AXIS));
-
- guiPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
- densityPanel.setLayout(new java.awt.GridBagLayout());
-
- densityPanel.setBorder(new javax.swing.border.TitledBorder("Density"));
- densityButtonGroup.add(zeroButton);
- zeroButton.setText("Zero");
- zeroButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- zeroButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- densityPanel.add(zeroButton, gridBagConstraints);
-
- densityButtonGroup.add(halfButton);
- halfButton.setText("Half");
- halfButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- halfButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- densityPanel.add(halfButton, gridBagConstraints);
-
- densityButtonGroup.add(fullButton);
- fullButton.setSelected(true);
- fullButton.setText("Full");
- fullButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- fullButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- densityPanel.add(fullButton, gridBagConstraints);
-
- guiPanel.add(densityPanel);
- densityPanel.getAccessibleContext().setAccessibleName("ShaderAttributeValue \n");
-
- colorPanel.setLayout(new java.awt.GridBagLayout());
-
- colorPanel.setBorder(new javax.swing.border.TitledBorder("Color"));
- colorButtonGroup.add(goldButton);
- goldButton.setSelected(true);
- goldButton.setText("Gold");
- goldButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- goldButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- colorPanel.add(goldButton, gridBagConstraints);
-
- colorButtonGroup.add(silverButton);
- silverButton.setText("Silver");
- silverButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- silverButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- colorPanel.add(silverButton, gridBagConstraints);
-
- guiPanel.add(colorPanel);
-
- sceneGraphPanel.setLayout(new java.awt.GridBagLayout());
-
- sceneGraphPanel.setBorder(new javax.swing.border.TitledBorder("Scene Graph"));
- sceneGraphButtonGroup.add(DetachButton);
- DetachButton.setSelected(true);
- DetachButton.setText("Detach");
- DetachButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- DetachButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- sceneGraphPanel.add(DetachButton, gridBagConstraints);
-
- sceneGraphButtonGroup.add(AttachButton);
- AttachButton.setText("Create");
- AttachButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- AttachButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- sceneGraphPanel.add(AttachButton, gridBagConstraints);
-
- replaceSPButton.setText("Replace Shader");
- replaceSPButton.setEnabled(false);
- replaceSPButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- replaceSPButtonActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- sceneGraphPanel.add(replaceSPButton, gridBagConstraints);
-
- guiPanel.add(sceneGraphPanel);
-
- mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH);
-
- drawingPanel.setLayout(new java.awt.BorderLayout());
-
- drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500));
- mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER);
-
- getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
-
- fileMenu.setText("File");
- exitMenuItem.setText("Exit");
- exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitMenuItemActionPerformed(evt);
- }
- });
-
- fileMenu.add(exitMenuItem);
-
- jMenuBar1.add(fileMenu);
-
- setJMenuBar(jMenuBar1);
-
- pack();
- }
- // </editor-fold>//GEN-END:initComponents
-
- private void silverButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_silverButtonActionPerformed
- color = SILVER;
- if(scene != null) {
- sao2.setValue(silver);
- }
- }//GEN-LAST:event_silverButtonActionPerformed
-
- private void goldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goldButtonActionPerformed
- color = GOLD;
- if(scene != null) {
- sao2.setValue(gold);
- }
- }//GEN-LAST:event_goldButtonActionPerformed
-
- private void replaceSPButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceSPButtonActionPerformed
- if (shaderSelected != DIMPLE_SHADER) {
- goldButton.setEnabled(false);
- silverButton.setEnabled(false);
- zeroButton.setEnabled(false);
- halfButton.setEnabled(false);
- fullButton.setEnabled(false);
- }
-
- switch(shaderSelected) {
- case DIMPLE_SHADER:
- s3d.setAppearance(sApp1);
- goldButton.setEnabled(true);
- silverButton.setEnabled(true);
- zeroButton.setEnabled(true);
- halfButton.setEnabled(true);
- fullButton.setEnabled(true);
- shaderSelected = BRICK_SHADER;
- break;
- case BRICK_SHADER:
- s3d.setAppearance(sApp2);
- shaderSelected = WOOD_SHADER;
- break;
- case WOOD_SHADER:
- s3d.setAppearance(sApp3);
- shaderSelected = POLKADOT3D_SHADER;
- break;
- case POLKADOT3D_SHADER:
- s3d.setAppearance(sApp4);
- shaderSelected = DIMPLE_SHADER;
- break;
- default:
- assert false;
- }
-
- }//GEN-LAST:event_replaceSPButtonActionPerformed
-
- private void fullButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fullButtonActionPerformed
- density = 16.0f;
- if (scene != null) {
- sao1.setValue(new Float(density));
- }
- }//GEN-LAST:event_fullButtonActionPerformed
-
- private void DetachButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DetachButtonActionPerformed
- if (scene != null) {
- scene.detach();
- scene = null;
- replaceSPButton.setEnabled(false);
- goldButton.setEnabled(true);
- silverButton.setEnabled(true);
- zeroButton.setEnabled(true);
- halfButton.setEnabled(true);
- fullButton.setEnabled(true);
- shaderSelected = DIMPLE_SHADER;
- }
- }//GEN-LAST:event_DetachButtonActionPerformed
-
- private void AttachButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AttachButtonActionPerformed
- if (scene == null) {
- scene = createSceneGraph(1);
- u.addBranchGraph(scene);
- replaceSPButton.setEnabled(true);
- shaderSelected = BRICK_SHADER;
- }
- }//GEN-LAST:event_AttachButtonActionPerformed
-
- private void halfButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_halfButtonActionPerformed
- density = 8.0f;
- if(scene != null) {
- sao1.setValue(new Float(density));
- }
- }//GEN-LAST:event_halfButtonActionPerformed
-
- private void zeroButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zeroButtonActionPerformed
- density = 0.0f;
- if(scene != null) {
- sao1.setValue(new Float(density));
- }
-
- }//GEN-LAST:event_zeroButtonActionPerformed
-
- private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
- System.exit(0);
- }//GEN-LAST:event_exitMenuItemActionPerformed
-
- /** Exit the Application */
- private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
- System.exit(0);
- }//GEN-LAST:event_exitForm
-
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- new ShaderTestGLSL().setVisible(true);
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JToggleButton AttachButton;
- private javax.swing.JToggleButton DetachButton;
- private javax.swing.ButtonGroup colorButtonGroup;
- private javax.swing.JPanel colorPanel;
- private javax.swing.ButtonGroup densityButtonGroup;
- private javax.swing.JPanel densityPanel;
- private javax.swing.JPanel drawingPanel;
- private javax.swing.JMenuItem exitMenuItem;
- private javax.swing.JMenu fileMenu;
- private javax.swing.JRadioButton fullButton;
- private javax.swing.JRadioButton goldButton;
- private javax.swing.JPanel guiPanel;
- private javax.swing.JRadioButton halfButton;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JPanel mainPanel;
- private javax.swing.JButton replaceSPButton;
- private javax.swing.ButtonGroup sceneGraphButtonGroup;
- private javax.swing.JPanel sceneGraphPanel;
- private javax.swing.JRadioButton silverButton;
- private javax.swing.JRadioButton zeroButton;
- // End of variables declaration//GEN-END:variables
-
-}
diff --git a/src/GLSLShaderTest/SphereGLSL.java b/src/GLSLShaderTest/SphereGLSL.java
deleted file mode 100644
index a9f6447..0000000
--- a/src/GLSLShaderTest/SphereGLSL.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.io.*;
-import com.sun.j3d.utils.applet.MainFrame;
-import com.sun.j3d.utils.geometry.Sphere;
-import com.sun.j3d.utils.shader.StringIO;
-import com.sun.j3d.utils.universe.*;
-import javax.media.j3d.*;
-import javax.vecmath.*;
-import java.util.Enumeration;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-/**
- * Simple GLSL Shader test program
- */
-public class SphereGLSL extends Applet {
-
- // Constants for type of light to use
- private static final int DIRECTIONAL_LIGHT = 0;
- private static final int POINT_LIGHT = 1;
- private static final int SPOT_LIGHT = 2;
-
- // Flag indicates type of lights: directional, point, or spot
- // lights. This flag is set based on command line argument
- private static int lightType = DIRECTIONAL_LIGHT;
-
- private SimpleUniverse u = null;
-
- public BranchGroup createSceneGraph(SimpleUniverse u) {
- Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
- Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f);
- Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
- Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f);
- Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f);
- Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
- Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
-
- Transform3D t;
-
- // Create the root of the branch graph
- BranchGroup objRoot = new BranchGroup();
-
- // Create a Transformgroup to scale all objects so they
- // appear in the scene.
- TransformGroup objScale = new TransformGroup();
- Transform3D t3d = new Transform3D();
- t3d.setScale(0.4);
- objScale.setTransform(t3d);
- objRoot.addChild(objScale);
-
- // Create a bounds for the background and lights
- BoundingSphere bounds =
- new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
-
- // Set up the background
- Background bg = new Background(bgColor);
- bg.setApplicationBounds(bounds);
- objScale.addChild(bg);
-
- // Create a Sphere object, generate one copy of the sphere,
- // and add it into the scene graph.
- ShaderAppearance a = new ShaderAppearance();
- Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
- m.setLightingEnable(true);
- String vertexProgram = null;
- String fragmentProgram = null;
- try {
- vertexProgram = StringIO.readFully("./simple.vert");
- fragmentProgram = StringIO.readFully("./simple.frag");
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- Shader[] shaders = new Shader[2];
- shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_VERTEX,
- vertexProgram);
- shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
- Shader.SHADER_TYPE_FRAGMENT,
- fragmentProgram);
- ShaderProgram shaderProgram = new GLSLShaderProgram();
- shaderProgram.setShaders(shaders);
-
- a.setShaderProgram(shaderProgram);
- a.setMaterial(m);
- Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 200, a);
- objScale.addChild(sph);
-
- // Create the transform group node for the each light and initialize
- // it to the identity. Enable the TRANSFORM_WRITE capability so that
- // our behavior code can modify it at runtime. Add them to the root
- // of the subgraph.
- TransformGroup l1RotTrans = new TransformGroup();
- l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objScale.addChild(l1RotTrans);
-
- TransformGroup l2RotTrans = new TransformGroup();
- l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
- objScale.addChild(l2RotTrans);
-
- // Create transformations for the positional lights
- t = new Transform3D();
- Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0);
- t.set(lPos1);
- TransformGroup l1Trans = new TransformGroup(t);
- l1RotTrans.addChild(l1Trans);
-
- t = new Transform3D();
- Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0);
- t.set(lPos2);
- TransformGroup l2Trans = new TransformGroup(t);
- l2RotTrans.addChild(l2Trans);
-
- // Create Geometry for point lights
- ColoringAttributes caL1 = new ColoringAttributes();
- ColoringAttributes caL2 = new ColoringAttributes();
- caL1.setColor(lColor1);
- caL2.setColor(lColor2);
- Appearance appL1 = new Appearance();
- Appearance appL2 = new Appearance();
- appL1.setColoringAttributes(caL1);
- appL2.setColoringAttributes(caL2);
- l1Trans.addChild(new Sphere(0.05f, appL1));
- l2Trans.addChild(new Sphere(0.05f, appL2));
-
- // Create lights
- AmbientLight aLgt = new AmbientLight(alColor);
-
- Light lgt1 = null;
- Light lgt2 = null;
-
- Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f);
- Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
- Vector3f lDirect1 = new Vector3f(lPos1);
- Vector3f lDirect2 = new Vector3f(lPos2);
- lDirect1.negate();
- lDirect2.negate();
-
- switch (lightType) {
- case DIRECTIONAL_LIGHT:
- lgt1 = new DirectionalLight(lColor1, lDirect1);
- lgt2 = new DirectionalLight(lColor2, lDirect2);
- break;
- case POINT_LIGHT:
- lgt1 = new PointLight(lColor1, lPoint, atten);
- lgt2 = new PointLight(lColor2, lPoint, atten);
- break;
- case SPOT_LIGHT:
- lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1,
- 25.0f * (float)Math.PI / 180.0f, 10.0f);
- lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2,
- 25.0f * (float)Math.PI / 180.0f, 10.0f);
- break;
- }
-
- // Set the influencing bounds
- aLgt.setInfluencingBounds(bounds);
- lgt1.setInfluencingBounds(bounds);
- lgt2.setInfluencingBounds(bounds);
-
- // Add the lights into the scene graph
- objScale.addChild(aLgt);
- l1Trans.addChild(lgt1);
- l2Trans.addChild(lgt2);
-
- // Create a new Behavior object that will perform the desired
- // operation on the specified transform object and add it into the
- // scene graph.
- Transform3D yAxis = new Transform3D();
- Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
- 0, 0,
- 4000, 0, 0,
- 0, 0, 0);
- RotationInterpolator rotator1 =
- new RotationInterpolator(rotor1Alpha,
- l1RotTrans,
- yAxis,
- 0.0f, (float) Math.PI*2.0f);
- rotator1.setSchedulingBounds(bounds);
- l1RotTrans.addChild(rotator1);
-
- // Create a new Behavior object that will perform the desired
- // operation on the specified transform object and add it into the
- // scene graph.
- Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
- 0, 0,
- 1000, 0, 0,
- 0, 0, 0);
- RotationInterpolator rotator2 =
- new RotationInterpolator(rotor2Alpha,
- l2RotTrans,
- yAxis,
- 0.0f, 0.0f);
- bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
- rotator2.setSchedulingBounds(bounds);
- l2RotTrans.addChild(rotator2);
-
- // Create a position interpolator and attach it to the view
- // platform
- TransformGroup vpTrans =
- u.getViewingPlatform().getViewPlatformTransform();
- Transform3D axisOfTranslation = new Transform3D();
- Alpha transAlpha = new Alpha(-1,
- Alpha.INCREASING_ENABLE |
- Alpha.DECREASING_ENABLE,
- 0, 0,
- 5000, 0, 0,
- 5000, 0, 0);
- axisOfTranslation.rotY(-Math.PI/2.0);
- PositionInterpolator translator =
- new PositionInterpolator(transAlpha,
- vpTrans,
- axisOfTranslation,
- 2.0f, 3.5f);
- translator.setSchedulingBounds(bounds);
- objScale.addChild(translator);
-
- // Let Java 3D perform optimizations on this scene graph.
- objRoot.compile();
-
- return objRoot;
- }
-
- public SphereGLSL() {
- }
-
- public void init() {
- setLayout(new BorderLayout());
- GraphicsConfiguration config =
- SimpleUniverse.getPreferredConfiguration();
-
- Canvas3D c = new Canvas3D(config);
- add("Center", c);
-
- u = new SimpleUniverse(c);
- BranchGroup scene = createSceneGraph(u);
-
- // This will move the ViewPlatform back a bit so the
- // objects in the scene can be viewed.
- u.getViewingPlatform().setNominalViewingTransform();
-
- /*
- // Limit the frame rate to 100 Hz
- u.getViewer().getView().setMinimumFrameCycleTime(10);
- */
-
- u.addBranchGraph(scene);
- }
-
- public void destroy() {
- u.cleanup();
- }
-
- //
- // The following allows SphereGLSL to be run as an application
- // as well as an applet
- //
- public static void main(String[] args) {
- // Parse the Input Arguments
- String usage = "Usage: java SphereGLSL [-point | -spot | -dir]";
- for (int i = 0; i < args.length; i++) {
- if (args[i].startsWith("-")) {
- if (args[i].equals("-point")) {
- /*
- System.out.println("Using point lights");
- lightType = POINT_LIGHT;
- */
- System.out.println("Point lights not yet implemented, option ignored");
- }
- else if (args[i].equals("-spot")) {
- /*
- System.out.println("Using spot lights");
- lightType = SPOT_LIGHT;
- */
- System.out.println("Spot lights not yet implemented, option ignored");
- }
- else if (args[i].equals("-dir")) {
- System.out.println("Using directional lights");
- lightType = DIRECTIONAL_LIGHT;
- }
- else {
- System.out.println(usage);
- System.exit(0);
- }
- }
- else {
- System.out.println(usage);
- System.exit(0);
- }
- }
-
- new MainFrame(new SphereGLSL(), 700, 700);
- }
-}
diff --git a/src/GLSLShaderTest/aabrick.frag b/src/GLSLShaderTest/aabrick.frag
deleted file mode 100644
index 7c9aab8..0000000
--- a/src/GLSLShaderTest/aabrick.frag
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Fragment shader for antialiased procedural bricks
-//
-// Authors: Dave Baldwin, Randi Rost
-// based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 BrickColor;
-//uniform vec3 MortarColor;
-//uniform vec2 BrickSize;
-//uniform vec2 BrickPct;
-//uniform vec2 MortarPct;
-
-//const vec3 BrickColor = vec3 (1, 0.3, 0.2);
-const vec3 MortarColor = vec3 (0.85, 0.86, 0.84);
-const vec2 BrickSize = vec2 (0.3, 0.15);
-const vec2 BrickPct = vec2 (0.9, 0.85);
-const vec2 MortarPct = vec2 (0.1, 0.15);
-
-varying vec2 MCposition;
-varying float LightIntensity;
-
-#define Integral(x, p, notp) ((floor(x)*(p)) + max(fract(x)-(notp), 0.0))
-
-void main(void)
-{
- vec2 position, fw, useBrick;
- vec3 color;
-
- // Determine position within the brick pattern
- position = MCposition / BrickSize;
-
- // Adjust every other row by an offset of half a brick
- if (fract(position.y * 0.5) > 0.5)
- position.x += 0.5;
-
- // Calculate filter size
- //fw = fwidth(position); //fwidth not implemented on WildcatVP
- fw = (abs(dFdx(MCposition)) + abs(dFdy(MCposition))) / BrickSize;
-
- // Perform filtering by integrating the 2D pulse made by the
- // brick pattern over the filter width and height
- useBrick = (Integral(position + fw, BrickPct, MortarPct) -
- Integral(position, BrickPct, MortarPct)) / fw;
-
- // Determine final color
- color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
- color *= LightIntensity;
-
- gl_FragColor = vec4 (color, 1.0);
-}
diff --git a/src/GLSLShaderTest/aabrick.vert b/src/GLSLShaderTest/aabrick.vert
deleted file mode 100644
index 226dbe4..0000000
--- a/src/GLSLShaderTest/aabrick.vert
+++ /dev/null
@@ -1,42 +0,0 @@
-//
-// Vertex shader for antialiased procedural bricks
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-// based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 LightPosition;
-//const vec3 LightPosition = vec3 (0, 4, 4);
-
-const float SpecularContribution = 0.3;
-const float DiffuseContribution = 1.0 - SpecularContribution;
-
-varying float LightIntensity;
-varying vec2 MCposition;
-
-void main(void)
-{
- vec3 ecPosition = vec3 (gl_ModelViewMatrix * gl_Vertex);
- vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
- vec3 lightVec = normalize(LightPosition - ecPosition);
- vec3 reflectVec = reflect(-lightVec, tnorm);
- vec3 viewVec = normalize(-ecPosition);
- float diffuse = max(dot(lightVec, tnorm), 0.0);
- float spec = 0.0;
-
- if (diffuse > 0.0)
- {
- spec = max(dot(reflectVec, viewVec), 0.0);
- spec = pow(spec, 16.0);
- }
-
- LightIntensity = DiffuseContribution * diffuse +
- SpecularContribution * spec;
-
- MCposition = gl_Vertex.xy;
- gl_Position = ftransform();
-}
diff --git a/src/GLSLShaderTest/build.xml b/src/GLSLShaderTest/build.xml
deleted file mode 100644
index 4e57328..0000000
--- a/src/GLSLShaderTest/build.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
- -->
-
-<project basedir="." default="compile">
- <target name="compile">
- <javac
- destdir="." srcdir="."
- source="1.4" target="1.4"
- debug="true" deprecation="true">
- </javac>
- </target>
-
- <target name="all" depends="compile">
- </target>
-
- <target description="Clean all build products." name="clean">
- <delete>
- <fileset dir=".">
- <include name="**/*.class"/>
- </fileset>
- </delete>
- </target>
-
-</project>
diff --git a/src/GLSLShaderTest/dimple.frag b/src/GLSLShaderTest/dimple.frag
deleted file mode 100644
index 282add7..0000000
--- a/src/GLSLShaderTest/dimple.frag
+++ /dev/null
@@ -1,61 +0,0 @@
-
-//
-// dimple.frag: Fragment shader for bump mapping dimples (bumps)
-//
-// author: John Kessenich
-//
-// Copyright (c) 2002: 3Dlabs, Inc.
-//
-//
-varying vec3 LightDir;
-varying vec3 EyeDir;
-varying vec3 Normal;
-
-//const vec3 Color = vec3(0.7, 0.6, 0.18);
-
-//const float Density = 16.0;
-//const float Size = 0.25;
-
-uniform vec3 Color;
-uniform float Density;
-uniform float Size;
-// uniform float SpecularFactor;
-
-//float Density = 27.6;
-//float Size = 0.13025;
-
-
-//uniform float Scale;
-
-const float SpecularFactor = 0.4;
-
-void main (void)
-{
- vec3 litColor;
-
- vec2 c = Density * (gl_TexCoord[0].xy);
- vec2 p = fract(c) - vec2(0.5);
- float d = (p.x * p.x) + (p.y * p.y);
- if (d >= Size)
- p = vec2(0.0);
-
- vec3 normDelta = vec3(-p.x, -p.y, 1.0);
-
- litColor = Color * max(0.0, dot(normDelta, LightDir));
-
- float t = 2.0 * dot(LightDir, normDelta);
- vec3 reflectDir = t * normDelta;
- reflectDir = LightDir - reflectDir;
-
-// vec3 reflectDir = LightDir - 2.0 * dot(LightDir, normDelta) * normDelta;
-
- float spec = max(dot(EyeDir, reflectDir), 0.0);
- spec = spec * spec;
- spec = spec * spec;
- spec *= SpecularFactor;
-
- litColor = min(litColor + spec, vec3(1.0));
- gl_FragColor = vec4(litColor, gl_Color.a);
-// gl_FragColor = vec4(litColor, 1.0);
-// gl_FragColor = vec4(Scale);
-}
diff --git a/src/GLSLShaderTest/dimple.vert b/src/GLSLShaderTest/dimple.vert
deleted file mode 100644
index e45796b..0000000
--- a/src/GLSLShaderTest/dimple.vert
+++ /dev/null
@@ -1,42 +0,0 @@
-
-//
-// dimple.vert: Vertex shader for bump mapping dimples (bumps)
-//
-// author: John Kessenich
-//
-// Copyright (c) 2002: 3Dlabs, Inc.
-//
-
-varying vec3 LightDir;
-varying vec3 EyeDir;
-varying vec3 Normal;
-
-uniform vec3 LightPosition;
-// uniform float Scale;
-// vec3 LightPosition = vec3(0.0, 0.0, 5.0);
-float Scale = 1.0;
-
-void main(void)
-{
- vec4 pos = gl_ModelViewMatrix * gl_Vertex;
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- vec3 eyeDir = vec3(pos);
-// gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_TexCoord[0] = gl_Vertex;
- gl_FrontColor = gl_Color;
-
- vec3 n = normalize(gl_NormalMatrix * gl_Normal);
- vec3 t = normalize(cross(vec3(1.141, 2.78, 3.14), n));
- vec3 b = cross(n, t);
-
- vec3 v;
- v.x = dot(LightPosition, t);
- v.y = dot(LightPosition, b);
- v.z = dot(LightPosition, n);
- LightDir = normalize(v);
-
- v.x = dot(eyeDir, t);
- v.y = dot(eyeDir, b);
- v.z = dot(eyeDir, n);
- EyeDir = normalize(v);
-}
diff --git a/src/GLSLShaderTest/gouraud.frag b/src/GLSLShaderTest/gouraud.frag
deleted file mode 100644
index 951ee8e..0000000
--- a/src/GLSLShaderTest/gouraud.frag
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// Simple GLSL fragment program to add the primary and secondary (specular) colors
-
-void main()
-{
- gl_FragColor = gl_Color + gl_SecondaryColor;
-}
diff --git a/src/GLSLShaderTest/gouraud.vert b/src/GLSLShaderTest/gouraud.vert
deleted file mode 100644
index fd49c18..0000000
--- a/src/GLSLShaderTest/gouraud.vert
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// A GLSL vertex program for handling 1 directional light with specular.
-// This implements per-vertex lighting (Gouraud shading).
-
-void directionalLight0(
- in vec3 normal,
- inout vec4 ambient,
- inout vec4 diffuse,
- inout vec4 specular)
-{
- // Normalized light direction and half vector
- vec3 lightDirection = normalize(vec3(gl_LightSource[0].position));
- vec3 halfVector = normalize(vec3(gl_LightSource[0].halfVector));
-
- float nDotVP; // normal . light_direction
- float nDotHV; // normal . light_half_vector
- float pf; // power factor
-
- nDotVP = max(0.0, dot(normal, lightDirection));
- nDotHV = max(0.0, dot(normal, halfVector));
-
- if (nDotVP == 0.0) {
- pf = 0.0;
- }
- else {
- pf = pow(nDotHV, gl_FrontMaterial.shininess);
- }
-
- ambient += gl_LightSource[0].ambient;
- diffuse += gl_LightSource[0].diffuse * nDotVP;
- specular += gl_LightSource[0].specular * pf;
-}
-
-
-void main()
-{
- vec3 tnorm = normalize(vec3(gl_NormalMatrix * gl_Normal));
- vec4 amb = vec4(0.0);
- vec4 diff = vec4(0.0);
- vec4 spec = vec4(0.0);
- int i;
-
- // Transform the vertex
- vec4 outPosition = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- directionalLight0(tnorm, amb, diff, spec);
-
- // Apply the result of the lighting equation
- vec4 outSecondaryColor = vec4(vec3(spec * gl_FrontMaterial.specular), 1.0);
- vec4 outColor = vec4(vec3(gl_FrontLightModelProduct.sceneColor +
- amb * gl_FrontMaterial.ambient +
- diff * gl_FrontMaterial.diffuse), 1.0);
-
- gl_FrontColor = outColor;
- gl_FrontSecondaryColor = outSecondaryColor;
- gl_Position = outPosition;
-}
diff --git a/src/GLSLShaderTest/phong.frag b/src/GLSLShaderTest/phong.frag
deleted file mode 100644
index 41de179..0000000
--- a/src/GLSLShaderTest/phong.frag
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// A GLSL fragment program for handling 1 directional light with specular.
-// This implements per-pixel lighting (Phong shading)
-
-void directionalLight0(
- in vec3 normal,
- inout vec4 ambient,
- inout vec4 diffuse,
- inout vec4 specular)
-{
- // Normalized light direction and half vector
- vec3 lightDirection = normalize(vec3(gl_LightSource[0].position));
- vec3 halfVector = normalize(vec3(gl_LightSource[0].halfVector));
-
- float nDotVP; // normal . light_direction
- float nDotHV; // normal . light_half_vector
- float pf; // power factor
-
- nDotVP = max(0.0, dot(normal, lightDirection));
- nDotHV = max(0.0, dot(normal, halfVector));
-
- if (nDotVP == 0.0) {
- pf = 0.0;
- }
- else {
- pf = pow(nDotHV, gl_FrontMaterial.shininess);
- }
-
- ambient += gl_LightSource[0].ambient;
- diffuse += gl_LightSource[0].diffuse * nDotVP;
- specular += gl_LightSource[0].specular * pf;
-}
-
-
-// Per-pixel normal (input from vertex shader)
-varying vec3 Normal;
-
-void main()
-{
- vec3 unitNorm = normalize(Normal);
- vec4 amb = vec4(0.0);
- vec4 diff = vec4(0.0);
- vec4 spec = vec4(0.0);
- int i;
-
- directionalLight0(unitNorm, amb, diff, spec);
-
- // Apply the result of the lighting equation
- vec4 secondaryColor = vec4(vec3(spec * gl_FrontMaterial.specular), 1.0);
- vec4 color = vec4(vec3(gl_FrontLightModelProduct.sceneColor +
- amb * gl_FrontMaterial.ambient +
- diff * gl_FrontMaterial.diffuse), 1.0);
-
- gl_FragColor = color + secondaryColor;
-}
diff --git a/src/GLSLShaderTest/phong.vert b/src/GLSLShaderTest/phong.vert
deleted file mode 100644
index 9a67c8b..0000000
--- a/src/GLSLShaderTest/phong.vert
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// A GLSL vertex program for doing Phone shading (per-fragment lighting)
-
-// Per-pixel normal (output to fragment shader)
-varying vec3 Normal;
-
-void main()
-{
- Normal = normalize(vec3(gl_NormalMatrix * gl_Normal));
-
- // Transform the vertex
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}
diff --git a/src/GLSLShaderTest/polkadot3d.frag b/src/GLSLShaderTest/polkadot3d.frag
deleted file mode 100644
index b341454..0000000
--- a/src/GLSLShaderTest/polkadot3d.frag
+++ /dev/null
@@ -1,48 +0,0 @@
-//
-// Fragment shader for 3 dimensional polka dot shader.
-//
-// Author: Joshua Doss
-//
-// Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-varying float LightIntensity;
-varying vec3 MCPosition;
-
-//Create uniform variables so dots can be spaced and scaled by user
-//uniform vec3 Spacing;
-//uniform float DotSize;
-const vec3 Spacing = vec3 (0.314, 0.36, 0.261);
-const float DotSize = 0.123;
-
-//Create colors as uniform variables so they can be easily changed
-//uniform vec3 ModelColor, PolkaDotColor;
-const vec3 ModelColor = vec3 (0.75, 0.2, 0.1);
-const vec3 PolkaDotColor = vec3 (1, 1, 1);
-
-void main(void)
-{
- float insidesphere, sphereradius, scaledpointlength;
- vec3 scaledpoint, finalcolor;
-
- // Scale the coordinate system
- // The following line of code is not yet implemented in current drivers:
- // mcpos = mod(Spacing, MCposition);
- // We will use a workaround found below for now
- scaledpoint = MCPosition - (Spacing * floor(MCPosition/Spacing));
-
- // Bring the scaledpoint vector into the center of the scaled coordinate system
- scaledpoint = scaledpoint - Spacing/2.0;
-
- // Find the length of the scaledpoint vector and compare it to the dotsize
- scaledpointlength = length(scaledpoint);
- insidesphere = step(scaledpointlength,DotSize);
-
- // Determine final output color before lighting
- finalcolor = vec3(mix(ModelColor, PolkaDotColor, insidesphere));
-
- // Output final color and factor in lighting
- gl_FragColor = clamp((vec4( finalcolor, 1.0 ) * LightIntensity), vec4(0.0), vec4(1.0));
-}
-
diff --git a/src/GLSLShaderTest/polkadot3d.vert b/src/GLSLShaderTest/polkadot3d.vert
deleted file mode 100644
index 86f432f..0000000
--- a/src/GLSLShaderTest/polkadot3d.vert
+++ /dev/null
@@ -1,58 +0,0 @@
-// This is the Vertex Shader for three dimensional polka dots.
-//
-// author(s): Joshua Doss
-//
-// Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
-
-//Create uniform variables for lighting to allow user interaction
-//uniform float SpecularContribution;
-//uniform vec3 LightPosition;
-
-const float SpecularContribution = 0.36;
-const vec3 LightPosition = vec3 (0, 4, 5);
-
-varying vec3 MCPosition;
-varying float LightIntensity;
-
-void main(void)
-{
- float diffusecontribution = 1.0 - SpecularContribution;
-
- // compute the vertex position in eye coordinates
- vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
-
- // compute the transformed normal
- vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
-
- // compute a vector from the model to the light position
- vec3 lightVec = normalize(LightPosition - ecPosition);
-
- // compute the reflection vector
- vec3 reflectVec = reflect(-lightVec, tnorm);
-
- // compute a unit vector in direction of viewing position
- vec3 viewVec = normalize(-ecPosition);
-
- // calculate amount of diffuse light based on normal and light angle
- float diffuse = max(dot(lightVec, tnorm), 0.0);
- float spec = 0.0;
-
- // if there is diffuse lighting, calculate specular
- if(diffuse > 0.0)
- {
- spec = max(dot(reflectVec, viewVec), 0.0);
- spec = pow(spec, 16.0);
- }
-
- // add up the light sources, since this is a varying (global) it will pass to frag shader
- LightIntensity = diffusecontribution * diffuse * 1.5 +
- SpecularContribution * spec;
-
- // the varying variable MCPosition will be used by the fragment shader to determine where
- // in model space the current pixel is
- MCPosition = vec3 (gl_Vertex);
-
- // send vertex information
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}
-
diff --git a/src/GLSLShaderTest/simple.frag b/src/GLSLShaderTest/simple.frag
deleted file mode 100644
index 6542b34..0000000
--- a/src/GLSLShaderTest/simple.frag
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// Simple GLSL fragment program to attenuate the input fragment color as a
-// function of the distance of the fragment position from the center
-// of the window
-
-const float windowSize = 700.0; // TODO: this should be a built-in parameter!
-
-void main()
-{
- // Compute distance from center in range [0.0, 1.0]
- vec2 dist = min(abs((gl_FragCoord.xy - (windowSize)/2.0) / windowSize), 1.0);
- vec2 invDist = 1.0 - dist;
-
- // Compute attenuation
- float atten = invDist.x * invDist.y;
- vec4 outcolor = (gl_Color + gl_SecondaryColor) * atten;
-
- gl_FragColor = outcolor;
-}
diff --git a/src/GLSLShaderTest/simple.vert b/src/GLSLShaderTest/simple.vert
deleted file mode 100644
index 7d3e152..0000000
--- a/src/GLSLShaderTest/simple.vert
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * $RCSfile$
- *
- * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistribution of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistribution in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of Sun Microsystems, Inc. or the names of
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * This software is provided "AS IS," without a warranty of any
- * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
- * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
- * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
- * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
- * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
- * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
- * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
- * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
- * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
- * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- *
- * You acknowledge that this software is not designed, licensed or
- * intended for use in the design, construction, operation or
- * maintenance of any nuclear facility.
- *
- * $Revision$
- * $Date$
- * $State$
- */
-
-// A simple GLSL vertex program for handling 2 directional lights with
-// separate specular
-
-void directionalLight(
- in int i,
- in vec3 normal,
- inout vec4 ambient,
- inout vec4 diffuse,
- inout vec4 specular)
-{
- // Normalized light direction and half vector
- // (shouldn't they be pre-normalized?!)
- vec3 lightDirection = normalize(vec3(gl_LightSource[i].position));
- vec3 halfVector = normalize(vec3(gl_LightSource[i].halfVector));
-
- float nDotVP; // normal . light_direction
- float nDotHV; // normal . light_half_vector
- float pf; // power factor
-
- nDotVP = max(0.0, dot(normal, lightDirection));
- nDotHV = max(0.0, dot(normal, halfVector));
-
- if (nDotVP == 0.0) {
- pf = 0.0;
- }
- else {
- pf = pow(nDotHV, gl_FrontMaterial.shininess);
- }
-
- ambient += gl_LightSource[i].ambient;
- diffuse += gl_LightSource[i].diffuse * nDotVP;
- specular += gl_LightSource[i].specular * pf;
-}
-
-
-const int numEnabledLights = 2; // TODO: this should be a built-in parameter!
-
-void main()
-{
- //vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
- //vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;
- vec3 tnorm = normalize(vec3(gl_NormalMatrix * gl_Normal));
- vec4 amb = vec4(0.0);
- vec4 diff = vec4(0.0);
- vec4 spec = vec4(0.0);
- int i;
-
- // Transform the vertex
- vec4 outPosition = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- for (i = 0; i < numEnabledLights; i++) {
- directionalLight(i, tnorm, amb, diff, spec);
- }
-
- // Apply the result of the lighting equation
- vec4 outSecondaryColor = vec4(vec3(spec * gl_FrontMaterial.specular), 1.0);
- vec3 color0 = vec3(gl_FrontLightModelProduct.sceneColor +
- amb * gl_FrontMaterial.ambient +
- diff * gl_FrontMaterial.diffuse);
-
- // Generate a pseudo-random noise pattern
- vec3 xyz = clamp((outPosition.xyz + 1.0) * 0.5, 0.0, 1.0);
-
- xyz = fract(xyz * 262144.0);
- float randSeed = fract(3.0 * xyz.x + 5.0 * xyz.y + 7.0 * xyz.z);
-
- vec3 altColor;
-
- randSeed = fract(37.0 * randSeed);
- altColor.x = randSeed * 0.5 + 0.5;
- randSeed = fract(37.0 * randSeed);
- altColor.y = randSeed * 0.5 + 0.5;
- randSeed = fract(37.0 * randSeed);
- altColor.z = randSeed * 0.5 + 0.5;
- randSeed = fract(37.0 * randSeed);
- float altAlpha = randSeed * 0.5;
-
- // Apply noise and output final vertex color
- vec4 outColor;
- outColor = vec4(mix(color0, altColor, altAlpha), 1.0);
-
- gl_FrontColor = outColor;
- gl_FrontSecondaryColor = outSecondaryColor;
- gl_Position = outPosition;
-}
diff --git a/src/GLSLShaderTest/toon.frag b/src/GLSLShaderTest/toon.frag
deleted file mode 100644
index fa50453..0000000
--- a/src/GLSLShaderTest/toon.frag
+++ /dev/null
@@ -1,34 +0,0 @@
-//
-// Fragment shader for cartoon-style shading
-//
-// Author: Philip Rideout
-//
-// Copyright (c) 2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-//uniform vec3 DiffuseColor;
-//uniform vec3 PhongColor;
-//uniform float Edge;
-//uniform float Phong;
-
-vec3 DiffuseColor = vec3(0.5,0.5,1.0);
-vec3 PhongColor = vec3(0.75,0.75,1.0);
-float Edge = 0.64;
-float Phong = 0.90;
-
-varying vec3 Normal;
-varying vec3 LightDir;
-
-void main (void)
-{
- vec3 color = DiffuseColor;
- float f = max( 0.0, dot(LightDir,Normal));
- if (abs(f) < Edge)
- color = DiffuseColor * 0.2;
- if (f > Phong)
- color = PhongColor;
-
- gl_FragColor = vec4(color, 1);
-}
diff --git a/src/GLSLShaderTest/toon.vert b/src/GLSLShaderTest/toon.vert
deleted file mode 100644
index d044af7..0000000
--- a/src/GLSLShaderTest/toon.vert
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Vertex shader for cartoon-style shading
-//
-// Author: Philip Rideout
-//
-// Copyright (c) 2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 Normal;
-varying vec3 LightDir;
-
-void main(void)
-{
- Normal = normalize(gl_NormalMatrix * gl_Normal);
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- LightDir = vec3(normalize(gl_LightSource[0].position));
-}
diff --git a/src/GLSLShaderTest/wood.frag b/src/GLSLShaderTest/wood.frag
deleted file mode 100644
index eecf91f..0000000
--- a/src/GLSLShaderTest/wood.frag
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Simple fragment shader for wood
-//
-// Author: John Kessenich
-//
-// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-//uniform float GrainSizeRecip;
-//uniform vec3 DarkColor;
-//uniform vec3 spread;
-const float GrainSizeRecip = 1.0;
-const vec3 DarkColor = vec3 (0.6, 0.3, 0.1);
-const vec3 spread = vec3 (0.15, 0.075, 0.0);
-
-varying float lightIntensity;
-varying vec3 Position;
-
-void main (void)
-{
- //
- // cheap noise
- //
- vec3 location = Position;
- vec3 floorvec = vec3(floor(10.0 * Position.x), 0.0, floor(10.0 * Position.z));
- vec3 noise = Position * 10.0 - floorvec - 0.5;
- noise *= noise;
- location += noise * 0.12;
-
- //
- // distance from axis
- //
- float dist = location.x * location.x + location.z * location.z;
- float grain = dist * GrainSizeRecip;
-
- //
- // grain effects as function of distance
- //
- float brightness = fract(grain);
- if (brightness > 0.5)
- brightness = (1.0 - brightness);
- vec3 color = DarkColor + brightness * spread;
-
- brightness = fract(grain * 7.0);
- if (brightness > 0.5)
- brightness = 1.0 - brightness;
- color -= brightness * spread;
-
- //
- // also as a function of lines parallel to the axis
- //
- brightness = fract(grain * 47.0) * 0.60;
- float line = fract(Position.z + Position.x);
- float snap = floor(line * 20.0) * (1.0/20.0);
- if (line < snap + 0.006)
- color -= brightness * spread;
-
- //
- // apply lighting effects from vertex processor
- //
- color = clamp(color * lightIntensity, 0.0, 1.0);
-
- gl_FragColor = vec4(color, 1.0);
-}
diff --git a/src/GLSLShaderTest/wood.vert b/src/GLSLShaderTest/wood.vert
deleted file mode 100644
index 84651aa..0000000
--- a/src/GLSLShaderTest/wood.vert
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Simple vertex shader for wood
-//
-// Author: John Kessenich
-//
-// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying float lightIntensity;
-varying vec3 Position;
-//uniform vec3 LightPosition;
-//uniform float Scale;
-const vec3 LightPosition = vec3 (0.0,0.0,0.4);
-const float Scale = 1.0;
-
-void main(void)
-{
- vec4 pos = gl_ModelViewMatrix * gl_Vertex;
- Position = vec3(gl_Vertex) * Scale;
- vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
- lightIntensity = max(dot(normalize(LightPosition - vec3(pos)), tnorm), 0.0) * 1.5;
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}