diff --git a/src/GLSL/GoochShader.ts b/src/GLSL/GoochShader.ts index add0cf5ab..7846c47d1 100644 --- a/src/GLSL/GoochShader.ts +++ b/src/GLSL/GoochShader.ts @@ -1,12 +1,10 @@ import { Vector3 } from "three"; -// -/* Written by Arefin Mohiuddin - graphics n00b */ -/* with help from Gooch Shader by Randi Rost (c) 3DLabs Inc. Ltd */ +//https://github.com/arefin86/arefin86.github.io/blob/master/js/shaders/GoochShader.js export const GoochShader = { uniforms: { "LightPosition": { type: "v3", value: new Vector3(-200, 0, 200) }, - "SurfaceColor": { type: "v3", value: new Vector3(0.0, 0.0, 0.8) }, + "SurfaceColor": { type: "v3", value: new Vector3(1.0, 1.0, 0.) }, "WarmColor": { type: "v3", value: new Vector3(1.0, 0.5, 0.0) }, "CoolColor": { type: "v3", value: new Vector3(0, 0, 0.7) }, "DiffuseWarm": { type: "f", value: 0.45 }, @@ -16,3 +14,11 @@ export const GoochShader = { vertexShader: require("./Goodch2.vs"), fragmentShader: require("./Goodch2.fs") } + +export const GoochShaderSimple = { + uniforms: { + "SurfaceColor": { type: "v3", value: new Vector3(1.0, 1.0, 1.0) } + }, + vertexShader: require("./GoodchSimple.vs"), + fragmentShader: require("./GoodchSimple.fs") +} diff --git a/src/GLSL/GoodchSimple.fs b/src/GLSL/GoodchSimple.fs new file mode 100644 index 000000000..47e327148 --- /dev/null +++ b/src/GLSL/GoodchSimple.fs @@ -0,0 +1,8 @@ + +uniform vec3 SurfaceColor; +varying float NdotL; + +void main(void) +{ + gl_FragColor = vec4 (SurfaceColor * NdotL, 1.0); +} diff --git a/src/GLSL/GoodchSimple.vs b/src/GLSL/GoodchSimple.vs new file mode 100644 index 000000000..c78da304f --- /dev/null +++ b/src/GLSL/GoodchSimple.vs @@ -0,0 +1,9 @@ +varying float NdotL; + +void main() +{ + vec3 trans_norm = normalize(normalMatrix * normal); + vec3 lightVec = normalize(vec3(-1.0, 1.0, 1.0)); + NdotL = (dot (lightVec, trans_norm) + 1.0) *0.5; + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); +}