diff --git a/docs/license.txt b/docs/license.txt new file mode 100644 index 000000000..9bf50b7b3 --- /dev/null +++ b/docs/license.txt @@ -0,0 +1 @@ +GPL license and some notes... diff --git a/src/meshlab/shaders/polkadot3d.frag b/src/meshlab/shaders/polkadot3d.frag new file mode 100644 index 000000000..cbe2059a4 --- /dev/null +++ b/src/meshlab/shaders/polkadot3d.frag @@ -0,0 +1,44 @@ +// +// 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; + +//Create colors as uniform variables so they can be easily changed +uniform vec3 ModelColor, PolkaDotColor; + +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/meshlab/shaders/polkadot3d.gdp b/src/meshlab/shaders/polkadot3d.gdp new file mode 100644 index 000000000..fc46efc4b --- /dev/null +++ b/src/meshlab/shaders/polkadot3d.gdp @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/meshlab/shaders/polkadot3d.vert b/src/meshlab/shaders/polkadot3d.vert new file mode 100644 index 000000000..e2a3a8e1d --- /dev/null +++ b/src/meshlab/shaders/polkadot3d.vert @@ -0,0 +1,55 @@ +// 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; + +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/sample/texturedknot.ply b/src/sample/texturedknot.ply new file mode 100644 index 000000000..95dd76e21 Binary files /dev/null and b/src/sample/texturedknot.ply differ