untrack generated samples\fluid\src\glsl_shaders.h

This commit is contained in:
martinfouilleul 2023-08-11 11:19:25 +02:00
parent 9da38506ff
commit 39010f5365
2 changed files with 1 additions and 551 deletions

View File

@ -1,3 +1,4 @@
Fluid
profile.dtrace
profile.spall
glsl_shaders.h

View File

@ -1,551 +0,0 @@
/*********************************************************************
*
* file: glsl_shaders.h
* note: string literals auto-generated by embed_text.py
* date: 08/082023
*
**********************************************************************/
#ifndef __GLSL_SHADERS_H__
#define __GLSL_SHADERS_H__
//NOTE: string imported from src/shaders/advect.glsl
const char* glsl_advect =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D src;\n"
"uniform sampler2D velocity;\n"
"uniform float delta;\n"
"uniform float dissipation;\n"
"\n"
"vec2 u(ivec2 coord)\n"
"{\n"
" return(texelFetch(velocity, coord, 0).xy);\n"
"}\n"
"\n"
"vec4 q(ivec2 coord)\n"
"{\n"
" if( coord.x < 0\n"
" || coord.x >= textureSize(src, 0).x\n"
" || coord.y < 0\n"
" || coord.y >= textureSize(src, 0).y)\n"
" {\n"
" return(vec4(0.));\n"
" }\n"
" return(texelFetch(src, coord, 0));\n"
"}\n"
"\n"
"vec4 bilerpSrc(vec2 pos)\n"
"{\n"
" vec2 offset = fract(pos);\n"
"\n"
" ivec2 bl = ivec2(floor(pos));\n"
"\n"
" ivec2 br = bl + ivec2(1, 0);\n"
" ivec2 tl = bl + ivec2(0, 1);\n"
" ivec2 tr = bl + ivec2(1, 1);\n"
"\n"
" vec4 lerpTop = (1.-offset.x)*q(tl) + offset.x*q(tr);\n"
" vec4 lerpBottom = (1.-offset.x)*q(bl) + offset.x*q(br);\n"
" vec4 result = (1.-offset.y)*lerpBottom + offset.y*lerpTop;\n"
"\n"
" return(result);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" float texWidth = float(textureSize(velocity, 0).x);\n"
"\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
"\n"
" vec2 samplePos = vec2(pixelCoord) - texWidth * delta * u(pixelCoord);\n"
" fragColor = bilerpSrc(samplePos) / (1. + dissipation*delta);\n"
"}\n";
//NOTE: string imported from src/shaders/blit_div_fragment.glsl
const char* glsl_blit_div_fragment =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D tex;\n"
"\n"
"vec3 color_map(float v)\n"
"{\n"
" float logv = log(abs(v))/log(10.0);\n"
" float f = floor(logv + 7.0);\n"
" float i = floor(4.0*(logv + 7.0 - f));\n"
"\n"
" if(f < 0.0) return vec3(0.0);\n"
" if(f < 1.0) return mix(vec3(1.0, 0.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 2.0) return mix(vec3(0.0, 1.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 3.0) return mix(vec3(0.0, 0.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 4.0) return mix(vec3(1.0, 1.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 5.0) return mix(vec3(1.0, 0.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 6.0) return mix(vec3(0.0, 1.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 7.0) return mix(vec3(1.0, 0.5, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 8.0) return mix(vec3(1.0, 1.0, 1.0), vec3(1.0), i/4.0);\n"
" return vec3(1.0);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(texCoord.xy * vec2(textureSize(tex, 0).xy)));\n"
" float f = texelFetch(tex, pixelCoord, 0).x;\n"
" fragColor = vec4(color_map(f), 1.0);\n"
"}\n";
//NOTE: string imported from src/shaders/blit_div_vertex.glsl
const char* glsl_blit_div_vertex =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"\n"
"in vec2 pos;\n"
"out vec2 texCoord;\n"
"\n"
"uniform mat4 mvp;\n"
"\n"
"void main()\n"
"{\n"
" texCoord = 0.5*(pos + vec2(1,1));\n"
" gl_Position = mvp * vec4(pos, 0, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/blit_fragment.glsl
const char* glsl_blit_fragment =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D tex;\n"
"\n"
"void main()\n"
"{\n"
" fragColor = texture(tex, texCoord);\n"
" fragColor.a = 1.0;\n"
"}\n";
//NOTE: string imported from src/shaders/blit_residue_fragment.glsl
const char* glsl_blit_residue_fragment =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D xTex;\n"
"uniform sampler2D bTex;\n"
"\n"
"float x(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(xTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(xTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(xTex, coord, 0).x);\n"
"}\n"
"\n"
"float b(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(bTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(bTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(bTex, coord, 0).x);\n"
"}\n"
"\n"
"vec3 color_map(float v)\n"
"{\n"
" float logv = log(abs(v))/log(10.0);\n"
" float f = floor(logv + 7.0);\n"
" float i = floor(4.0*(logv + 7.0 - f));\n"
"\n"
" if(f < 0.0) return vec3(0.0);\n"
" if(f < 1.0) return mix(vec3(1.0, 0.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 2.0) return mix(vec3(0.0, 1.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 3.0) return mix(vec3(0.0, 0.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 4.0) return mix(vec3(1.0, 1.0, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 5.0) return mix(vec3(1.0, 0.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 6.0) return mix(vec3(0.0, 1.0, 1.0), vec3(1.0), i/4.0);\n"
" if(f < 7.0) return mix(vec3(1.0, 0.5, 0.0), vec3(1.0), i/4.0);\n"
" if(f < 8.0) return mix(vec3(1.0, 1.0, 1.0), vec3(1.0), i/4.0);\n"
" return vec3(1.0);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(texCoord.xy * vec2(textureSize(xTex, 0).xy)));\n"
"\n"
" float tl = x(pixelCoord + ivec2(-1, 1));\n"
" float tr = x(pixelCoord + ivec2(1, 1));\n"
" float bl = x(pixelCoord + ivec2(-1, -1));\n"
" float br = x(pixelCoord + ivec2(1, -1));\n"
"\n"
" float residue = b(pixelCoord) - (-tl - tr - bl - br + 4.*x(pixelCoord));\n"
" fragColor = vec4(color_map(residue), 1);\n"
"}\n";
//NOTE: string imported from src/shaders/blit_vertex.glsl
const char* glsl_blit_vertex =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"\n"
"in vec2 pos;\n"
"out vec2 texCoord;\n"
"\n"
"uniform mat4 mvp;\n"
"uniform ivec2 gridSize;\n"
"\n"
"void main()\n"
"{\n"
" float margin = 32.;\n"
" float ratio = 1. - 2.*margin/float(gridSize.x);\n"
"\n"
" texCoord = margin/float(gridSize.x) + ratio*(0.5*(pos + vec2(1,1)));\n"
" gl_Position = mvp * vec4(pos, 0, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/common_vertex.glsl
const char* glsl_common_vertex =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"\n"
"in vec2 pos;\n"
"out vec2 texCoord;\n"
"\n"
"void main()\n"
"{\n"
" texCoord = 0.5*(pos + vec2(1,1));\n"
" gl_Position = vec4(pos, 0, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/divergence.glsl
const char* glsl_divergence =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D src;\n"
"\n"
"vec2 u(ivec2 coord)\n"
"{\n"
" return(texelFetch(src, coord, 0).xy);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
"\n"
" if( pixelCoord.x <= 0\n"
" || pixelCoord.x >= textureSize(src, 0).x\n"
" || pixelCoord.y <= 0\n"
" || pixelCoord.y >= textureSize(src, 0).y)\n"
" {\n"
" fragColor = vec4(0, 0, 0, 1);\n"
" }\n"
" else\n"
" {\n"
" vec2 tl = u(pixelCoord + ivec2(-1, 0));\n"
" vec2 tr = u(pixelCoord);\n"
" vec2 bl = u(pixelCoord + ivec2(-1, -1));\n"
" vec2 br = u(pixelCoord + ivec2(0, -1));\n"
"\n"
" float r = (tr.x + br.x)/2.;\n"
" float l = (tl.x + bl.x)/2.;\n"
" float t = (tl.y + tr.y)/2.;\n"
" float b = (bl.y + br.y)/2.;\n"
"\n"
" fragColor = vec4(-2.*(r - l + t - b), 0, 0, 1);\n"
" }\n"
"}\n";
//NOTE: string imported from src/shaders/jacobi_step.glsl
const char* glsl_jacobi_step =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D xTex;\n"
"uniform sampler2D bTex;\n"
"\n"
"float x(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(xTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(xTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(xTex, coord, 0).x);\n"
"}\n"
"\n"
"float b(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(bTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(bTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(bTex, coord, 0).x);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
"\n"
" if( pixelCoord.x <= 0\n"
" || pixelCoord.y <= 0)\n"
" {\n"
" fragColor = vec4(0, 0, 0, 1);\n"
" }\n"
" else\n"
" {\n"
" float tl = x(pixelCoord + ivec2(-1, 1));\n"
" float tr = x(pixelCoord + ivec2(1, 1));\n"
" float bl = x(pixelCoord + ivec2(-1, -1));\n"
" float br = x(pixelCoord + ivec2(1, -1));\n"
"\n"
" float jacobi = (tl + tr + bl + br + b(pixelCoord))/4.;\n"
" fragColor = vec4(jacobi, 0, 0, 1);\n"
" }\n"
"}\n";
//NOTE: string imported from src/shaders/multigrid_correct.glsl
const char* glsl_multigrid_correct =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D src;\n"
"uniform sampler2D error;\n"
"uniform float invGridSize;\n"
"\n"
"float e(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(error, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(error, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(error, coord, 0).x);\n"
"}\n"
"\n"
"float p(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(src, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(src, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(src, coord, 0).x);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
" vec2 coarseCoord = vec2(pixelCoord)/2.;\n"
" vec2 offset = fract(coarseCoord);\n"
"\n"
" ivec2 bl = ivec2(floor(coarseCoord));\n"
" ivec2 br = bl + ivec2(1, 0);\n"
" ivec2 tl = bl + ivec2(0, 1);\n"
" ivec2 tr = bl + ivec2(1, 1);\n"
"\n"
" float topLerp = (1.-offset.x)*e(tl)+ offset.x*e(tr);\n"
" float bottomLerp = (1.-offset.x)*e(bl) + offset.x*e(br);\n"
" float bilerpError = (1.-offset.y)*bottomLerp + offset.y*topLerp;\n"
"\n"
" fragColor = vec4(p(pixelCoord) + bilerpError, 0, 0, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/multigrid_restrict_residual.glsl
const char* glsl_multigrid_restrict_residual =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D xTex;\n"
"uniform sampler2D bTex;\n"
"\n"
"float x(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(xTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(xTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(xTex, coord, 0).x);\n"
"}\n"
"\n"
"float b(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(bTex, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(bTex, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(bTex, coord, 0).x);\n"
"}\n"
"\n"
"float residual(ivec2 coord)\n"
"{\n"
" ivec2 vr = coord + ivec2(1, 0);\n"
" ivec2 vl = coord - ivec2(1, 0);\n"
" ivec2 vt = coord + ivec2(0, 1);\n"
" ivec2 vb = coord - ivec2(0, 1);\n"
"\n"
" return((x(vl) + x(vr) + x(vt) + x(vb) + b(coord) - 4.*x(coord))*4.);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
"\n"
" float restricted = residual(2*pixelCoord + ivec2(-1, -1))\n"
" + residual(2*pixelCoord + ivec2(1, -1))\n"
" + residual(2*pixelCoord + ivec2(1, 1))\n"
" + residual(2*pixelCoord + ivec2(-1, 1))\n"
" + 2.*residual(2*pixelCoord + ivec2(-1, 0))\n"
" + 2.*residual(2*pixelCoord + ivec2(1, 0))\n"
" + 2.*residual(2*pixelCoord + ivec2(0, -1))\n"
" + 2.*residual(2*pixelCoord + ivec2(0, 1))\n"
" + 4.*residual(2*pixelCoord);\n"
" restricted /= 16.;\n"
" fragColor = vec4(restricted, 0, 0, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/splat.glsl
const char* glsl_splat =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D src;\n"
"uniform vec2 splatPos;\n"
"uniform vec3 splatColor;\n"
"uniform float radius;\n"
"uniform float additive;\n"
"uniform float blending;\n"
"\n"
"uniform float randomize;\n"
"\n"
"void main()\n"
"{\n"
" float d2 = dot(texCoord - splatPos, texCoord - splatPos);\n"
" float intensity = exp(-10.*d2/radius);\n"
" vec2 force = splatColor.xy;\n"
"\n"
" vec3 u = texture(src, texCoord).xyz;\n"
" vec3 uAdd = u + intensity*splatColor.xyz;\n"
" vec3 uBlend = u*(1.-intensity) + intensity * splatColor;\n"
"\n"
" fragColor = vec4(uAdd*additive + uBlend*blending, 1);\n"
"}\n";
//NOTE: string imported from src/shaders/subtract_pressure.glsl
const char* glsl_subtract_pressure =
"#version 300 es\n"
"\n"
"precision highp float;\n"
"precision highp sampler2D;\n"
"\n"
"in vec2 texCoord;\n"
"out vec4 fragColor;\n"
"\n"
"uniform sampler2D src;\n"
"uniform sampler2D pressure;\n"
"uniform float invGridSize;\n"
"\n"
"vec2 u(ivec2 coord)\n"
"{\n"
" return(texelFetch(src, coord, 0).xy);\n"
"}\n"
"\n"
"float p(ivec2 coord)\n"
"{\n"
" if( coord.x <= 0\n"
" || coord.x >= textureSize(pressure, 0).x\n"
" || coord.y <= 0\n"
" || coord.y >= textureSize(pressure, 0).y)\n"
" {\n"
" return(0.);\n"
" }\n"
" return(texelFetch(pressure, coord, 0).x);\n"
"}\n"
"\n"
"void main()\n"
"{\n"
" ivec2 pixelCoord = ivec2(floor(gl_FragCoord.xy));\n"
"\n"
" float tl = p(pixelCoord + ivec2(0, 1));\n"
" float tr = p(pixelCoord + ivec2(1, 1));\n"
" float bl = p(pixelCoord);\n"
" float br = p(pixelCoord + ivec2(1, 0));\n"
"\n"
" float r = (tr + br)/2.;\n"
" float l = (tl + bl)/2.;\n"
" float t = (tl + tr)/2.;\n"
" float b = (bl + br)/2.;\n"
"\n"
" vec2 gradP = vec2(r - l, t - b);\n"
"\n"
" fragColor = vec4(u(pixelCoord) - gradP, 0, 1);\n"
"}\n";
#endif // __GLSL_SHADERS_H__