Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
Created February 7, 2026 11:59
Show Gist options
  • Select an option

  • Save patriciogonzalezvivo/429131da32ef6ba1cc44027dce147f28 to your computer and use it in GitHub Desktop.

Select an option

Save patriciogonzalezvivo/429131da32ef6ba1cc44027dce147f28 to your computer and use it in GitHub Desktop.
glslViewer Shader: devlook
This file has been truncated, but you can view the full file.
{
"frag": "#version 100\n\n#ifdef GL_ES\nprecision mediump float;\n#endif\n\n// IBL\nuniform samplerCube u_cubeMap;\nuniform vec3 u_SH[9];\n\nuniform mat4 u_viewMatrix;\n\nuniform vec3 u_camera;\nuniform float u_cameraDistance;\nuniform float u_cameraNearClip;\nuniform float u_cameraFarClip;\n\nuniform vec2 u_resolution;\n#define RESOLUTION u_resolution\nuniform vec2 u_mouse;\nuniform float u_time;\n\n\n// Shadow\nuniform sampler2D u_lightShadowMap;\nuniform mat4 u_lightMatrix;\nuniform vec3 u_light;\nuniform vec3 u_lightColor;\nuniform float u_lightIntensity;\nvarying vec4 v_lightCoord;\n#define LIGHT_DIRECTION u_light\n#define LIGHT_COORD v_lightCoord\n#define LIGHT_COLOR u_lightColor\n#define LIGHT_INTENSITY u_lightIntensity\n\n// Surface position (from vertex shader - common)\nvarying vec4 v_position;\n#define SURFACE_POSITION v_position\n\n// More model data (from vertex shader - common)\n#define MODEL_VERTEX_TANGENT v_tangent\nvarying vec4 v_color;\nvarying vec3 v_normal;\n#define MODEL_VERTEX_NORMAL v_normal\nvarying vec2 v_texcoord;\n#define MODEL_VERTEX_TEXCOORD v_texcoord\n\n\n#if defined(DEVLOOK_SPHERE_0) || defined(DEVLOOK_SPHERE_1)\n// The 2 spheres (dialectic/metallic) have camera at a constant distance\n#define CAMERA_POSITION (normalize(u_camera) * 3.0)\n#elif defined(DEVLOOK_BILLBOARD_0)\n// The color check billboard has a fixed camera\n#define CAMERA_POSITION vec3(0.0, 0.0, 3.0) \n#else\n#define CAMERA_POSITION u_camera\n#endif\n\n\n#include \"lygia/space/ratio.glsl\"\n#include \"lygia/color/space/rgb2srgb.glsl\"\n#include \"lygia/color/space/srgb2rgb.glsl\"\n\n// Filter\n#include \"lygia/sample/clamp2edge.glsl\"\n#include \"lygia/space/linearizeDepth.glsl\"\n\n\n// 2D Components \n#include \"lygia/draw/colorChecker.glsl\"\n\n\n// PBR pipeline\n#include \"lygia/lighting/material/new.glsl\"\n#include \"lygia/lighting/pbr.glsl\"\n\nvoid main() {\n vec4 color = vec4(0.0);\n vec2 pixel = 1.0 / u_resolution;\n vec2 st = gl_FragCoord.xy * pixel;\n\n\n\n // 3D PBR Scene \n Material material = materialNew();\n material.albedo.rgb = vec3(.0);\n // material.roughness = 0.5;\n // material.metallic = 0.2;\n\n #if defined(FLOOR)\n // Floor\n material.albedo.rgb = vec3(0.25);\n material.roughness = 1.0;\n material.metallic = 0.001;\n\n #elif defined(DEVLOOK_SPHERE_0)\n // Dialectic Sphere\n material.metallic = 0.0;\n material.roughness = 1.0;\n\n #elif defined(DEVLOOK_SPHERE_1)\n // Metallic Sphere\n material.metallic = 1.0;\n material.roughness = 0.0;\n\n #elif defined(DEVLOOK_BILLBOARD_0)\n // Color Checker Billboard\n material.roughness = 1.0;\n material.metallic = 0.0;\n material.albedo = srgb2rgb(colorChecker(v_texcoord));\n #endif\n\n color = pbr(material);\n color = rgb2srgb(color);\n\n gl_FragColor = color;\n}",
"vert": "#version 100\n\n#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform mat4 u_lightMatrix;\nvarying vec4 v_lightCoord;\n\nuniform mat4 u_modelViewProjectionMatrix;\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_modelMatrix;\nuniform mat4 u_viewMatrix;\nuniform mat3 u_normalMatrix;\n\nuniform vec3 u_camera;\nuniform vec2 u_resolution;\nuniform float u_time;\n\nvarying vec4 v_position;\nvarying vec4 v_tangent;\nvarying vec4 v_color;\nvarying vec3 v_normal;\nvarying vec2 v_texcoord;\n\n// GlslViewer\n#define POSITION_ATTRIBUTE a_position\nattribute vec4 POSITION_ATTRIBUTE;\n\n#ifdef MODEL_VERTEX_TANGENT\n#define TANGENT_ATTRIBUTE a_tangent\nattribute vec4 TANGENT_ATTRIBUTE;\n#endif\n\n#ifdef MODEL_VERTEX_COLOR\n#define COLOR_ATTRIBUTE a_color\nattribute vec4 COLOR_ATTRIBUTE;\n#endif\n\n#ifdef MODEL_VERTEX_NORMAL\n#define NORMAL_ATTRIBUTE a_normal\nattribute vec3 NORMAL_ATTRIBUTE;\n#endif\n\n#ifdef MODEL_VERTEX_TEXCOORD\nattribute vec2 a_texcoord;\n#endif\n\n#if defined(DEVLOOK_SPHERE_0) || defined(DEVLOOK_SPHERE_1)\n// The 2 spheres (dialectic/metallic) have camera at a constant distance\n#define CAMERA_POSITION (normalize(u_camera) * 3.0)\n#elif defined(DEVLOOK_BILLBOARD_0)\n// The color check billboard has a fixed camera\n#define CAMERA_POSITION vec3(0.0, 0.0, 3.0) \n#else\n#define CAMERA_POSITION u_camera\n#endif\n\n#define CAMERA_UP vec3(0.0, 1.0, 0.0)\n#define MODEL_MATRIX u_modelMatrix\n#define VIEW_MATRIX u_viewMatrix\n#define PROJECTION_MATRIX u_projectionMatrix\n\n#include \"lygia/math/const.glsl\"\n#include \"lygia/math/toMat4.glsl\"\n#include \"lygia/math/inverse.glsl\"\n#include \"lygia/space/lookAt.glsl\"\n#include \"lygia/space/orthographic.glsl\"\n\nvoid main(void) {\n v_position = POSITION_ATTRIBUTE;\n v_color = vec4(1.0);\n v_normal = NORMAL_ATTRIBUTE;\n \n #if defined(MODEL_VERTEX_TEXCOORD)\n v_texcoord = a_texcoord;\n #else\n v_texcoord = v_position.xy;\n #endif\n\n #if defined(USE_TANGENT) || defined(MODEL_VERTEX_TANGENT)\n v_tangent = TANGENT_ATTRIBUTE;\n #endif\n\n #if defined(USE_COLOR) || defined(MODEL_VERTEX_COLOR) \n v_color = COLOR_ATTRIBUTE;\n #endif\n\n #if defined(FLOOR)\n v_position.xz *= vec2(2.0, 2.0);\n\n #endif\n\n#if defined(DEVLOOK_SPHERE_0) || defined(DEVLOOK_SPHERE_1) || defined(DEVLOOK_BILLBOARD_0)\n\n // This is for the 2 spheres (dialectic/metallic) and the color checker billboard\n //\n #ifdef LIGHT_SHADOWMAP\n v_lightCoord = vec4(0.0);\n #endif\n\n const float area = 2.0;\n mat4 P = orthographic( area, -area, area, -area, -1.0, 5.0);\n\n #if defined(DEVLOOK_BILLBOARD_0)\n // The billboards have an orthogonal projection\n mat4 V = mat4(1.0);\n float S = 0.65;\n #else\n mat4 V = inverse( toMat4( lookAt(CAMERA_POSITION, vec3(0.0), CAMERA_UP) ) );\n float S = 0.25;\n #endif\n\n gl_Position = P * V * POSITION_ATTRIBUTE;\n gl_Position.xy *= vec2(u_resolution.y / u_resolution.x, 1.0) * S;\n gl_Position.x -= 0.8;\n\n #if defined(DEVLOOK_SPHERE_0)\n gl_Position.y += 0.8; \n #elif defined(DEVLOOK_SPHERE_1)\n gl_Position.y += 0.5;\n #elif defined(DEVLOOK_BILLBOARD_0)\n gl_Position.y += 0.2;\n #endif\n\n#else\n\n // This is for the main model\n //\n v_position = MODEL_MATRIX * v_position;\n #if defined(LIGHT_SHADOWMAP)\n v_lightCoord = u_lightMatrix * v_position;\n #endif\n \n gl_Position = PROJECTION_MATRIX * VIEW_MATRIX * MODEL_MATRIX * v_position;\n\n#endif\n}",
"commands": [
"fullscreen,off",
"sky,on",
"cubemap,on",
"camera_position,1.74897,-0.952875,-1.68013",
"camera_look_at,0,0,0",
"grid,off",
"bboxes,off",
"plot,plot,off"
],
"assets": {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment