实现简单阴暗面着色

pull/267/MERGE
ChenX 6 years ago
parent fca5c203ef
commit f569c62313

@ -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")
}

@ -0,0 +1,8 @@
uniform vec3 SurfaceColor;
varying float NdotL;
void main(void)
{
gl_FragColor = vec4 (SurfaceColor * NdotL, 1.0);
}

@ -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 );
}
Loading…
Cancel
Save