forked from patriciogonzalezvivo/lygia_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
655adcb
commit f2862f1
Showing
7 changed files
with
195 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
|
||
uniform vec2 u_resolution; | ||
uniform vec2 u_mouse; | ||
uniform float u_time; | ||
|
||
varying vec2 v_texcoord; | ||
|
||
#include "lygia/math/const.glsl" | ||
#include "lygia/color/space.glsl" | ||
#include "lygia/lighting/iridescence.glsl" | ||
|
||
void main(void) { | ||
vec4 color = vec4(vec3(0.0), 1.0); | ||
vec2 pixel = 1.0/u_resolution.xy; | ||
vec2 st = gl_FragCoord.xy * pixel; | ||
vec2 uv = v_texcoord; | ||
|
||
color.rgb = iridescence( cos(uv.x*HALF_PI) ,1.0-uv.y); | ||
color = linear2gamma(color); | ||
|
||
gl_FragColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// Copyright Patricio Gonzalez Vivo, 2021 - http://patriciogonzalezvivo.com/ | ||
|
||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
|
||
uniform sampler2D u_scene; | ||
uniform sampler2D u_sceneDepth; | ||
|
||
uniform mat4 u_projectionMatrix; | ||
|
||
uniform vec3 u_camera; | ||
uniform float u_cameraNearClip; | ||
uniform float u_cameraFarClip; | ||
|
||
uniform vec3 u_light; | ||
uniform vec3 u_lightColor; | ||
uniform float u_lightFalloff; | ||
uniform float u_lightIntensity; | ||
|
||
uniform float u_iblLuminance; | ||
|
||
uniform samplerCube u_cubeMap; | ||
uniform vec3 u_SH[9]; | ||
|
||
#ifdef LIGHT_SHADOWMAP | ||
uniform sampler2D u_lightShadowMap; | ||
uniform mat4 u_lightMatrix; | ||
varying vec4 v_lightCoord; | ||
#endif | ||
|
||
uniform vec2 u_resolution; | ||
uniform float u_time; | ||
|
||
varying vec4 v_position; | ||
varying vec4 v_color; | ||
varying vec3 v_normal; | ||
|
||
#ifdef MODEL_VERTEX_TEXCOORD | ||
varying vec2 v_texcoord; | ||
#endif | ||
|
||
#ifdef MODEL_VERTEX_TANGENT | ||
varying vec4 v_tangent; | ||
varying mat3 v_tangentToWorld; | ||
#endif | ||
|
||
#define SURFACE_POSITION v_position | ||
#define CAMERA_POSITION u_camera | ||
#define IBL_LUMINANCE u_iblLuminance | ||
|
||
// #define LIGHT_POSITION u_light | ||
#define LIGHT_DIRECTION u_light | ||
#define LIGHT_COLOR u_lightColor | ||
#define LIGHT_FALLOFF u_lightFalloff | ||
#define LIGHT_INTENSITY u_lightIntensity | ||
#define LIGHT_COORD v_lightCoord | ||
|
||
// #include "lygia/lighting/atmosphere.glsl" | ||
// #ifndef SCENE_CUBEMAP | ||
// #define ENVMAP_FNC(NORM, ROUGHNESS, METALLIC) atmosphere(NORM, normalize(u_light)) | ||
// #endif | ||
#include "lygia/math/bump.glsl" | ||
#include "lygia/color/space/linear2gamma.glsl" | ||
#include "lygia/color/space/gamma2linear.glsl" | ||
|
||
#include "lygia/color/palette/hue.glsl" | ||
#include "lygia/color/palette/chroma.glsl" | ||
#include "lygia/color/palette/spectrum.glsl" | ||
|
||
#include "lygia/lighting/pbrClearCoat.glsl" | ||
#include "lygia/lighting/pbr.glsl" | ||
#include "lygia/lighting/pbrGlass.glsl" | ||
#include "lygia/lighting/wavelength.glsl" | ||
#include "lygia/lighting/iridescence.glsl" | ||
#include "lygia/lighting/material/new.glsl" | ||
|
||
float checkBoard(vec2 uv, vec2 _scale) { | ||
uv = floor(fract(uv * _scale) * 2.0); | ||
return min(1.0, uv.x + uv.y) - (uv.x * uv.y); | ||
} | ||
|
||
void main(void) { | ||
vec4 color = vec4(0.0, 0.0, 0.0, 1.0); | ||
vec2 pixel = 1.0/u_resolution; | ||
vec2 st = gl_FragCoord.xy * pixel; | ||
vec2 uv = st; | ||
#if defined(MODEL_VERTEX_TEXCOORD) | ||
uv = v_texcoord; | ||
#endif | ||
|
||
Material mat = materialNew(); | ||
#if defined(FLOOR) && defined(MODEL_VERTEX_TEXCOORD) | ||
mat.albedo.rgb = vec3(0.5) + checkBoard(uv, vec2(8.0)) * 0.5; | ||
#endif | ||
|
||
#if defined(MODEL_NAME_SUZANNE1) | ||
mat.clearCoat = 2.0; | ||
color = pbrClearCoat(mat); | ||
#elif defined(MODEL_NAME_SUZANNE3) | ||
// mat.roughness = 0.1; | ||
color = pbrGlass(mat); | ||
#else | ||
color = pbr(mat); | ||
#endif | ||
|
||
vec3 L = normalize(LIGHT_DIRECTION); | ||
vec3 V = normalize(CAMERA_POSITION - (SURFACE_POSITION).xyz); | ||
vec3 N = normalize(mat.normal); | ||
color.rgb += iridescence( abs(dot(N, V)), 1.0); | ||
color.rgb += iridescence(V, N, L, 270.0); | ||
|
||
color = linear2gamma(color); | ||
|
||
gl_FragColor = color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule lygia
updated
19 files
+3 −2 | color/palette/hue.glsl | |
+3 −2 | color/palette/hue.hlsl | |
+66 −0 | color/space/k2rgb.glsl | |
+64 −0 | color/space/k2rgb.hlsl | |
+22 −0 | color/space/w2rgb.glsl | |
+21 −0 | color/space/w2rgb.hlsl | |
+12 −0 | lighting/blackbody.glsl | |
+4 −0 | lighting/common/ggx.glsl | |
+10 −2 | lighting/envMap.glsl | |
+9 −3 | lighting/iridescence.glsl | |
+5 −7 | lighting/light/directional.glsl | |
+7 −2 | lighting/pbr.glsl | |
+0 −1 | lighting/pbrGlass.glsl | |
+13 −10 | lighting/specular/cookTorrance.glsl | |
+1 −0 | lighting/specular/ggx.glsl | |
+12 −0 | lighting/wavelength.glsl | |
+13 −0 | math/bump.glsl | |
+11 −0 | math/bump.hlsl | |
+2 −2 | math/gain.glsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
|
||
uniform vec2 u_resolution; | ||
uniform vec2 u_mouse; | ||
uniform float u_time; | ||
|
||
varying vec2 v_texcoord; | ||
|
||
#include "lygia/draw/stroke.glsl" | ||
|
||
#include "lygia/math/gain.glsl" | ||
#include "lygia/math/bump.glsl" | ||
#include "lygia/math/saturate.glsl" | ||
#include "lygia/math/parabola.glsl" | ||
#include "lygia/math/gaussian.glsl" | ||
|
||
void main(void) { | ||
vec4 color = vec4(vec3(0.0), 1.0); | ||
vec2 pixel = 1.0/u_resolution.xy; | ||
vec2 st = gl_FragCoord.xy * pixel; | ||
vec2 uv = v_texcoord; | ||
|
||
float f = st.x; | ||
f = bump( (f - 0.5) * 2.0, 0.0); | ||
// f = gain(f, 0.7); | ||
// f = parabola(f, 0.99); | ||
// f = gaussian(f, 0.9); | ||
color += stroke(st.y, f, pixel.y * 2.0); | ||
|
||
gl_FragColor = color; | ||
} |