From 3e757dbc71682972899a48651710c5d8280c3cee Mon Sep 17 00:00:00 2001 From: Kiet Tran Date: Mon, 29 Nov 2021 13:36:54 -0600 Subject: Publish A6 --- dev/a6-harold/shaders/artsy.frag | 29 +++++++++++++++++++++++++++++ dev/a6-harold/shaders/artsy.vert | 17 +++++++++++++++++ dev/a6-harold/shaders/outline.frag | 7 +++++++ dev/a6-harold/shaders/outline.vert | 23 +++++++++++++++++++++++ dev/a6-harold/shaders/stroke2d.frag | 9 +++++++++ dev/a6-harold/shaders/stroke2d.vert | 7 +++++++ dev/a6-harold/shaders/stroke3d.frag | 9 +++++++++ dev/a6-harold/shaders/stroke3d.vert | 10 ++++++++++ 8 files changed, 111 insertions(+) create mode 100644 dev/a6-harold/shaders/artsy.frag create mode 100644 dev/a6-harold/shaders/artsy.vert create mode 100644 dev/a6-harold/shaders/outline.frag create mode 100644 dev/a6-harold/shaders/outline.vert create mode 100644 dev/a6-harold/shaders/stroke2d.frag create mode 100644 dev/a6-harold/shaders/stroke2d.vert create mode 100644 dev/a6-harold/shaders/stroke3d.frag create mode 100644 dev/a6-harold/shaders/stroke3d.vert (limited to 'dev/a6-harold/shaders') diff --git a/dev/a6-harold/shaders/artsy.frag b/dev/a6-harold/shaders/artsy.frag new file mode 100644 index 0000000..403009d --- /dev/null +++ b/dev/a6-harold/shaders/artsy.frag @@ -0,0 +1,29 @@ +#version 330 + +in vec3 Position; +in vec3 Normal; + +out vec4 color; + +uniform vec3 lightPosition; +uniform vec4 Ia, Id, Is; + +uniform vec4 ka, kd, ks; +uniform float s; + +uniform sampler2D diffuseRamp; +uniform sampler2D specularRamp; + + +void main() { + vec3 l = normalize(lightPosition.xyz - Position); + vec3 n = normalize(Normal); + vec3 e = normalize(-Position); + vec3 h = normalize(e + l); + float diffuse = (dot(l,n) + 1)/2; + float specular = pow(max(dot(n,h),0), s); + color = ka*Ia + + kd*Id*texture(diffuseRamp, vec2(diffuse,0)) + + ks*Is*texture(specularRamp, vec2(specular,0)); + color.a = 1; +} diff --git a/dev/a6-harold/shaders/artsy.vert b/dev/a6-harold/shaders/artsy.vert new file mode 100644 index 0000000..cd9b998 --- /dev/null +++ b/dev/a6-harold/shaders/artsy.vert @@ -0,0 +1,17 @@ +#version 330 + +uniform mat4 modelViewMatrix; +uniform mat4 normalMatrix; +uniform mat4 projectionMatrix; + +layout(location = 0) in vec3 vertex; +layout(location = 1) in vec3 normal; + +out vec3 Position; +out vec3 Normal; + +void main() { + Position = (modelViewMatrix * vec4(vertex,1)).xyz; + Normal = normalize((normalMatrix * vec4(normal,0)).xyz); + gl_Position = projectionMatrix * modelViewMatrix * vec4(vertex,1); +} diff --git a/dev/a6-harold/shaders/outline.frag b/dev/a6-harold/shaders/outline.frag new file mode 100644 index 0000000..096721d --- /dev/null +++ b/dev/a6-harold/shaders/outline.frag @@ -0,0 +1,7 @@ +#version 330 + +out vec4 color; + +void main() { + color = vec4(0,0,0, 1); +} diff --git a/dev/a6-harold/shaders/outline.vert b/dev/a6-harold/shaders/outline.vert new file mode 100644 index 0000000..a6073e5 --- /dev/null +++ b/dev/a6-harold/shaders/outline.vert @@ -0,0 +1,23 @@ +#version 330 + +uniform mat4 modelViewMatrix; +uniform mat4 normalMatrix; +uniform mat4 projectionMatrix; +uniform float thickness; + +layout(location = 0) in vec3 vertex; +layout(location = 1) in vec3 normal; +layout(location = 2) in vec3 leftNormal; +layout(location = 3) in vec3 rightNormal; + +void main() { + vec3 p = (modelViewMatrix * vec4(vertex,1)).xyz; + vec3 e = -p; + vec3 nl = (normalMatrix * vec4(leftNormal,0)).xyz; + vec3 nr = (normalMatrix * vec4(rightNormal,0)).xyz; + vec3 v = vertex; + if (dot(e,nl) * dot(e,nr) < 0.0) { + v += thickness*normal; + } + gl_Position = projectionMatrix * modelViewMatrix * vec4(v,1); +} diff --git a/dev/a6-harold/shaders/stroke2d.frag b/dev/a6-harold/shaders/stroke2d.frag new file mode 100644 index 0000000..2dd7efa --- /dev/null +++ b/dev/a6-harold/shaders/stroke2d.frag @@ -0,0 +1,9 @@ +#version 330 + +uniform vec4 strokeColor; + +out vec4 color; + +void main() { + color = strokeColor; +} diff --git a/dev/a6-harold/shaders/stroke2d.vert b/dev/a6-harold/shaders/stroke2d.vert new file mode 100644 index 0000000..e40fdec --- /dev/null +++ b/dev/a6-harold/shaders/stroke2d.vert @@ -0,0 +1,7 @@ +#version 330 + +layout(location = 0) in vec3 vertex; + +void main() { + gl_Position = vec4(vertex,1); +} diff --git a/dev/a6-harold/shaders/stroke3d.frag b/dev/a6-harold/shaders/stroke3d.frag new file mode 100644 index 0000000..2dd7efa --- /dev/null +++ b/dev/a6-harold/shaders/stroke3d.frag @@ -0,0 +1,9 @@ +#version 330 + +uniform vec4 strokeColor; + +out vec4 color; + +void main() { + color = strokeColor; +} diff --git a/dev/a6-harold/shaders/stroke3d.vert b/dev/a6-harold/shaders/stroke3d.vert new file mode 100644 index 0000000..d333c4f --- /dev/null +++ b/dev/a6-harold/shaders/stroke3d.vert @@ -0,0 +1,10 @@ +#version 330 + +uniform mat4 modelViewMatrix; +uniform mat4 projectionMatrix; + +layout(location = 0) in vec3 vertex; + +void main() { + gl_Position = projectionMatrix * modelViewMatrix * vec4(vertex,1); +} -- cgit v1.2.3