0005: thoughtform alt for debug
This commit is contained in:
parent
86f1634b5f
commit
ed93a41e71
4 changed files with 56 additions and 12 deletions
|
@ -3,16 +3,12 @@ import { WebGLApp } from "../renderer/webgl";
|
|||
import { Renderable } from "../renderer/renderable";
|
||||
import { Transform, etoq, v3 } from "../renderer/transform";
|
||||
import plane from "../meshes/plane";
|
||||
import texture0 from "../meshes/trianglething/textures/texture0.png";
|
||||
import { Texture } from "../renderer/texture";
|
||||
import { outer } from "./shaders/outer";
|
||||
import uvsphere from "../meshes/uvsphere";
|
||||
import { basic } from "../common-shaders/basic";
|
||||
import { noe } from "./shaders/noe";
|
||||
import uvsphereInverted from "../meshes/uvsphere-inverted";
|
||||
|
||||
const useDebug = location.search.includes("alt1");
|
||||
|
||||
const app = new WebGLApp({ fov: 45 });
|
||||
const light = new Transform(v3(-5));
|
||||
|
||||
const camera = new Transform([0, 0, 2], etoq([0, 0, 0]));
|
||||
const transformPlane = new Transform(v3(0), etoq([0, 180, 0]), v3(1.8));
|
||||
|
@ -32,7 +28,7 @@ new Renderable(
|
|||
new Renderable(
|
||||
app,
|
||||
transformSphere,
|
||||
new MeshRenderer(app, plane, noe(app), camera).configure({})
|
||||
new MeshRenderer(app, plane, noe(app, useDebug), camera).configure({})
|
||||
);
|
||||
|
||||
// createGizmo(app, camera, light);
|
||||
|
|
43
src/005-thoughtform-hidenoe/shaders/noe-debug.frag
Normal file
43
src/005-thoughtform-hidenoe/shaders/noe-debug.frag
Normal file
|
@ -0,0 +1,43 @@
|
|||
#version 300 es
|
||||
precision highp float;
|
||||
|
||||
// uniform mat4 u_view;
|
||||
// uniform mat4 u_projection;
|
||||
// uniform mat4 u_object_to_world;
|
||||
// uniform mat4 u_object_to_world_inv;
|
||||
// uniform vec3 u_light_0;
|
||||
// uniform vec4 u_light_0_color;
|
||||
uniform float u_time;
|
||||
// uniform vec4 u_albedo;
|
||||
|
||||
in vec2 uv0;
|
||||
in vec3 light_pos;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
const float margin = 0.5;
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
void main() {
|
||||
// 0..1 to -1..1
|
||||
vec2 cUV = uv0 * 2.0 - 1.0;
|
||||
float circleDistance = length(cUV);
|
||||
if (circleDistance > margin) {
|
||||
discard;
|
||||
}
|
||||
|
||||
float theta = atan(cUV.y, cUV.x) ;
|
||||
float spiral = sin(100.0 * (sqrt(circleDistance*20.0) - 10.0 * theta - 0.01 * u_time * 0.001));
|
||||
|
||||
float edgeLightZone = pow(clamp(abs(dot(cUV.xyx, light_pos)), 0.0, 1.0) * 2.0, 4.0);
|
||||
|
||||
float colorSpiral = sin(100.0 * (sqrt(circleDistance * 10.0) - 0.001 * theta - 0.3 * u_time * 0.00005));
|
||||
vec3 hueRotation = hsv2rgb(vec3(colorSpiral, 1.0, 0.5));
|
||||
|
||||
fragColor = vec4(colorSpiral, spiral, 1.0, 1.0);
|
||||
}
|
|
@ -2,6 +2,7 @@ import { Shader, ShaderConfig } from "../../renderer/shader";
|
|||
import { WebGLApp } from "../../renderer/webgl";
|
||||
import vert from "../../common-shaders/basic.vert";
|
||||
import frag from "./noe.frag";
|
||||
import fragDebug from "./noe-debug.frag";
|
||||
|
||||
export const basicShaderConfig: ShaderConfig = {
|
||||
attributes: {
|
||||
|
@ -26,5 +27,8 @@ export const basicShaderConfig: ShaderConfig = {
|
|||
},
|
||||
};
|
||||
|
||||
export const noe = (app: WebGLApp) =>
|
||||
new Shader(basicShaderConfig).vertex(vert).fragment(frag).app(app);
|
||||
export const noe = (app: WebGLApp, debug: boolean = false) =>
|
||||
new Shader(basicShaderConfig)
|
||||
.vertex(vert)
|
||||
.fragment(debug ? fragDebug : frag)
|
||||
.app(app);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue