From f569c62313fb5c7175d7e68ba4895c6eea97de41 Mon Sep 17 00:00:00 2001 From: ChenX Date: Thu, 7 Mar 2019 16:52:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=AE=80=E5=8D=95=E9=98=B4?= =?UTF-8?q?=E6=9A=97=E9=9D=A2=E7=9D=80=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GLSL/GoochShader.ts | 14 ++++++++++---- src/GLSL/GoodchSimple.fs | 8 ++++++++ src/GLSL/GoodchSimple.vs | 9 +++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 src/GLSL/GoodchSimple.fs create mode 100644 src/GLSL/GoodchSimple.vs 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 ); +}