improve shaders

main
Dominik Madarász 2023-08-20 19:58:34 +02:00
parent 178320f636
commit 37db0c09fe
11 changed files with 327 additions and 59 deletions

View File

@ -2491,6 +2491,24 @@ int flags;
int fx_find(const char *name);
void* screenshot(int components);
void* screenshot_async(int components);
extern const char *const fs_0_0_shadowmap_lit;
extern const char *const fs_0_0_shadowmap_unlit;
extern const char *const fs_24_4_sprite;
extern const char *const fs_2_4_preamble;
extern const char *const fs_2_4_texel_inv_gamma;
extern const char *const fs_2_4_texel_ycbr_gamma_saturation;
extern const char *const fs_32_4_model;
extern const char *const fs_32_4_model_basic;
extern const char *const fs_3_4_skybox;
extern const char *const fs_3_4_skybox_rayleigh;
extern const char *const fs_main_shadertoy;
extern const char *const vs_0_2_fullscreen_quad_A;
extern const char *const vs_0_2_fullscreen_quad_B;
extern const char *const vs_0_2_fullscreen_quad_B_flipped;
extern const char *const vs_323444143_16_332_model;
extern const char *const vs_324_24_sprite;
extern const char *const vs_332_32;
extern const char *const vs_3_3_skybox;
void ddraw_color(unsigned rgb);
void ddraw_color_push(unsigned rgb);
void ddraw_color_pop();

View File

@ -16673,6 +16673,27 @@ API void* screenshot(int components); // 3 RGB, 4 RGBA, -3 BGR, -4 BGRA
API void* screenshot_async(int components); // 3 RGB, 4 RGBA, -3 BGR, -4 BGRA
#line 0
#line 1 "v4k_shaders.h"
extern const char *const fs_0_0_shadowmap_lit;
extern const char *const fs_0_0_shadowmap_unlit;
extern const char *const fs_24_4_sprite;
extern const char *const fs_2_4_preamble;
extern const char *const fs_2_4_texel_inv_gamma;
extern const char *const fs_2_4_texel_ycbr_gamma_saturation;
extern const char *const fs_32_4_model;
extern const char *const fs_32_4_model_basic;
extern const char *const fs_3_4_skybox;
extern const char *const fs_3_4_skybox_rayleigh;
extern const char *const fs_main_shadertoy;
extern const char *const vs_0_2_fullscreen_quad_A;
extern const char *const vs_0_2_fullscreen_quad_B;
extern const char *const vs_0_2_fullscreen_quad_B_flipped;
extern const char *const vs_323444143_16_332_model;
extern const char *const vs_324_24_sprite;
extern const char *const vs_332_32;
extern const char *const vs_3_3_skybox;
#line 0
#line 1 "v4k_renderdd.h"
// -----------------------------------------------------------------------------
// debugdraw framework
@ -339080,7 +339101,7 @@ void network_rpc_send(unsigned id, const char *cmdline) {
#line 0
#line 1 "v4k_shaders.c"
static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 1.;\n"
@ -339192,7 +339213,7 @@ static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
#endif
" }\n";
static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 0.;\n"
@ -339202,7 +339223,7 @@ static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
" return vec4(1.);\n"
" };\n";
static const char *const fs_24_4_sprite = "//" FILELINE "\n"
const char *const fs_24_4_sprite = "//" FILELINE "\n"
"uniform sampler2D u_texture;\n"
"\n"
"in vec2 vTexCoord;\n"
@ -339256,7 +339277,7 @@ static const char *const fs_24_4_sprite = "//" FILELINE "\n"
" fragColor = vColor * texColor;\n"
"}\n";
static const char *const fs_2_4_preamble = "//" FILELINE "\n"
const char *const fs_2_4_preamble = "//" FILELINE "\n"
"#define texture2D texture\n"
"#define texture2DLod textureLod\n"
"#define FRAGCOLOR fragColor\n"
@ -339274,7 +339295,7 @@ static const char *const fs_2_4_preamble = "//" FILELINE "\n"
"in vec2 texcoord;\n"
"out vec4 fragColor;\n";
static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
"uniform sampler2D texture0; /*unit0*/\n"
"uniform float u_inv_gamma;\n"
"\n"
@ -339287,7 +339308,7 @@ static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
" fragcolor.rgb = pow( fragcolor.rgb, vec3( u_inv_gamma ) ); // defaults: 1.0/2.2 gamma\n"
"}\n";
static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"uniform sampler2D u_texture_y; /*unit0*/\n"
"uniform sampler2D u_texture_cb; /*unit1*/\n"
"uniform sampler2D u_texture_cr; /*unit2*/\n"
@ -339325,7 +339346,7 @@ static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"fragcolor = vec4(texel.rgb, 1.0);\n"
"}\n";
static const char *const fs_32_4_model = "//" FILELINE "\n"
const char *const fs_32_4_model = "//" FILELINE "\n"
"uniform mat4 model, view;\n"
"uniform sampler2D u_texture2d;\n"
"uniform vec3 u_coefficients_sh[9];\n"
@ -339398,7 +339419,7 @@ static const char *const fs_32_4_model = "//" FILELINE "\n"
" \n"
" }\n";
static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
const char *const fs_32_4_model_basic = "//" FILELINE "\n"
"uniform sampler2D fsDiffTex;\n"
"uniform sampler2D fsNormalTex;\n"
"uniform sampler2D fsPositionTex;\n"
@ -339414,7 +339435,7 @@ static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
" fragColor = diff;// * vec4(v_normal.xyz, 1);\n"
"}\n";
static const char *const fs_3_4_skybox = "//" FILELINE "\n"
const char *const fs_3_4_skybox = "//" FILELINE "\n"
"uniform samplerCube u_cubemap;\n"
"\n"
"in vec3 v_direction;\n"
@ -339424,7 +339445,7 @@ static const char *const fs_3_4_skybox = "//" FILELINE "\n"
" fragcolor = vec4(texture(u_cubemap, v_direction).rgb, 1.0);\n"
"}\n";
static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
"uniform vec3 uSunPos = vec3( 0, 0.1, -1 ); // = [0, Math.cos(theta) * 0.3 + 0.2, -1];\n"
"\n"
"in vec3 v_direction;\n"
@ -339564,13 +339585,13 @@ static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
" return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n"
"}\n";
static const char *const fs_main_shadertoy = "//" FILELINE "\n"
const char *const fs_main_shadertoy = "//" FILELINE "\n"
"void mainImage( out vec4 fragColor, in vec2 fragCoord );\n"
"void main() {\n"
" mainImage(fragColor, texcoord.xy * iResolution);\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
"out vec2 texcoord;\n"
"\n"
"void main() {\n"
@ -339578,7 +339599,7 @@ static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
" gl_Position = vec4( texCoord * 2.0 - 1.0, 0.0, 1.0 );\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -339588,7 +339609,7 @@ static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -339598,7 +339619,7 @@ static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
#ifndef MAX_BONES
"#define MAX_BONES 110\n"
#endif
@ -339715,7 +339736,7 @@ static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
"}\n"
"\n";
static const char *const vs_324_24_sprite = "//" FILELINE "\n"
const char *const vs_324_24_sprite = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_Position;\n"
@ -339730,7 +339751,7 @@ static const char *const vs_324_24_sprite = "//" FILELINE "\n"
" gl_Position = u_mvp * vec4(att_Position, 1.0);\n"
"}\n";
static const char *const vs_332_32 = "//" FILELINE "\n"
const char *const vs_332_32 = "//" FILELINE "\n"
"//uniform mat4 u_model, u_view, u_proj;\n"
"uniform mat4 u_mvp;\n"
"\n"
@ -339765,7 +339786,7 @@ static const char *const vs_332_32 = "//" FILELINE "\n"
" do_shadow();\n"
"}\n";
static const char *const vs_3_3_skybox = "//" FILELINE "\n"
const char *const vs_3_3_skybox = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_position;\n"
@ -339776,6 +339797,7 @@ static const char *const vs_3_3_skybox = "//" FILELINE "\n"
" gl_Position = position.xyww;\n"
" v_direction = att_position;\n"
"}\n";
#line 0
#line 1 "v4k_render.c"

View File

@ -133,6 +133,8 @@ extern "C" {
{{FILE:v4k_render.h}}
{{FILE:v4k_shaders.h}}
{{FILE:v4k_renderdd.h}}
{{FILE:v4k_scene.h}}

View File

@ -1,4 +1,4 @@
static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 1.;\n"
@ -110,7 +110,7 @@ static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
#endif
" }\n";
static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 0.;\n"
@ -120,7 +120,7 @@ static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
" return vec4(1.);\n"
" };\n";
static const char *const fs_24_4_sprite = "//" FILELINE "\n"
const char *const fs_24_4_sprite = "//" FILELINE "\n"
"uniform sampler2D u_texture;\n"
"\n"
"in vec2 vTexCoord;\n"
@ -174,7 +174,7 @@ static const char *const fs_24_4_sprite = "//" FILELINE "\n"
" fragColor = vColor * texColor;\n"
"}\n";
static const char *const fs_2_4_preamble = "//" FILELINE "\n"
const char *const fs_2_4_preamble = "//" FILELINE "\n"
"#define texture2D texture\n"
"#define texture2DLod textureLod\n"
"#define FRAGCOLOR fragColor\n"
@ -192,7 +192,7 @@ static const char *const fs_2_4_preamble = "//" FILELINE "\n"
"in vec2 texcoord;\n"
"out vec4 fragColor;\n";
static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
"uniform sampler2D texture0; /*unit0*/\n"
"uniform float u_inv_gamma;\n"
"\n"
@ -205,7 +205,7 @@ static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
" fragcolor.rgb = pow( fragcolor.rgb, vec3( u_inv_gamma ) ); // defaults: 1.0/2.2 gamma\n"
"}\n";
static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"uniform sampler2D u_texture_y; /*unit0*/\n"
"uniform sampler2D u_texture_cb; /*unit1*/\n"
"uniform sampler2D u_texture_cr; /*unit2*/\n"
@ -243,7 +243,7 @@ static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"fragcolor = vec4(texel.rgb, 1.0);\n"
"}\n";
static const char *const fs_32_4_model = "//" FILELINE "\n"
const char *const fs_32_4_model = "//" FILELINE "\n"
"uniform mat4 model, view;\n"
"uniform sampler2D u_texture2d;\n"
"uniform vec3 u_coefficients_sh[9];\n"
@ -316,7 +316,7 @@ static const char *const fs_32_4_model = "//" FILELINE "\n"
" \n"
" }\n";
static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
const char *const fs_32_4_model_basic = "//" FILELINE "\n"
"uniform sampler2D fsDiffTex;\n"
"uniform sampler2D fsNormalTex;\n"
"uniform sampler2D fsPositionTex;\n"
@ -332,7 +332,7 @@ static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
" fragColor = diff;// * vec4(v_normal.xyz, 1);\n"
"}\n";
static const char *const fs_3_4_skybox = "//" FILELINE "\n"
const char *const fs_3_4_skybox = "//" FILELINE "\n"
"uniform samplerCube u_cubemap;\n"
"\n"
"in vec3 v_direction;\n"
@ -342,7 +342,7 @@ static const char *const fs_3_4_skybox = "//" FILELINE "\n"
" fragcolor = vec4(texture(u_cubemap, v_direction).rgb, 1.0);\n"
"}\n";
static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
"uniform vec3 uSunPos = vec3( 0, 0.1, -1 ); // = [0, Math.cos(theta) * 0.3 + 0.2, -1];\n"
"\n"
"in vec3 v_direction;\n"
@ -482,13 +482,13 @@ static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
" return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n"
"}\n";
static const char *const fs_main_shadertoy = "//" FILELINE "\n"
const char *const fs_main_shadertoy = "//" FILELINE "\n"
"void mainImage( out vec4 fragColor, in vec2 fragCoord );\n"
"void main() {\n"
" mainImage(fragColor, texcoord.xy * iResolution);\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
"out vec2 texcoord;\n"
"\n"
"void main() {\n"
@ -496,7 +496,7 @@ static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
" gl_Position = vec4( texCoord * 2.0 - 1.0, 0.0, 1.0 );\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -506,7 +506,7 @@ static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -516,7 +516,7 @@ static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
#ifndef MAX_BONES
"#define MAX_BONES 110\n"
#endif
@ -633,7 +633,7 @@ static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
"}\n"
"\n";
static const char *const vs_324_24_sprite = "//" FILELINE "\n"
const char *const vs_324_24_sprite = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_Position;\n"
@ -648,7 +648,7 @@ static const char *const vs_324_24_sprite = "//" FILELINE "\n"
" gl_Position = u_mvp * vec4(att_Position, 1.0);\n"
"}\n";
static const char *const vs_332_32 = "//" FILELINE "\n"
const char *const vs_332_32 = "//" FILELINE "\n"
"//uniform mat4 u_model, u_view, u_proj;\n"
"uniform mat4 u_mvp;\n"
"\n"
@ -683,7 +683,7 @@ static const char *const vs_332_32 = "//" FILELINE "\n"
" do_shadow();\n"
"}\n";
static const char *const vs_3_3_skybox = "//" FILELINE "\n"
const char *const vs_3_3_skybox = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_position;\n"
@ -694,3 +694,4 @@ static const char *const vs_3_3_skybox = "//" FILELINE "\n"
" gl_Position = position.xyww;\n"
" v_direction = att_position;\n"
"}\n";

View File

@ -0,0 +1,18 @@
extern const char *const fs_0_0_shadowmap_lit;
extern const char *const fs_0_0_shadowmap_unlit;
extern const char *const fs_24_4_sprite;
extern const char *const fs_2_4_preamble;
extern const char *const fs_2_4_texel_inv_gamma;
extern const char *const fs_2_4_texel_ycbr_gamma_saturation;
extern const char *const fs_32_4_model;
extern const char *const fs_32_4_model_basic;
extern const char *const fs_3_4_skybox;
extern const char *const fs_3_4_skybox_rayleigh;
extern const char *const fs_main_shadertoy;
extern const char *const vs_0_2_fullscreen_quad_A;
extern const char *const vs_0_2_fullscreen_quad_B;
extern const char *const vs_0_2_fullscreen_quad_B_flipped;
extern const char *const vs_323444143_16_332_model;
extern const char *const vs_324_24_sprite;
extern const char *const vs_332_32;
extern const char *const vs_3_3_skybox;

View File

@ -10137,7 +10137,7 @@ void network_rpc_send(unsigned id, const char *cmdline) {
#line 0
#line 1 "v4k_shaders.c"
static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 1.;\n"
@ -10249,7 +10249,7 @@ static const char *const fs_0_0_shadowmap_lit = "//" FILELINE "\n"
#endif
" }\n";
static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
"// uniform mat4 view = mat4(1.0);\n"
"uniform vec3 lightPos = vec3(1.0);\n"
"uniform float doTexture = 0.;\n"
@ -10259,7 +10259,7 @@ static const char *const fs_0_0_shadowmap_unlit = "//" FILELINE "\n"
" return vec4(1.);\n"
" };\n";
static const char *const fs_24_4_sprite = "//" FILELINE "\n"
const char *const fs_24_4_sprite = "//" FILELINE "\n"
"uniform sampler2D u_texture;\n"
"\n"
"in vec2 vTexCoord;\n"
@ -10313,7 +10313,7 @@ static const char *const fs_24_4_sprite = "//" FILELINE "\n"
" fragColor = vColor * texColor;\n"
"}\n";
static const char *const fs_2_4_preamble = "//" FILELINE "\n"
const char *const fs_2_4_preamble = "//" FILELINE "\n"
"#define texture2D texture\n"
"#define texture2DLod textureLod\n"
"#define FRAGCOLOR fragColor\n"
@ -10331,7 +10331,7 @@ static const char *const fs_2_4_preamble = "//" FILELINE "\n"
"in vec2 texcoord;\n"
"out vec4 fragColor;\n";
static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
"uniform sampler2D texture0; /*unit0*/\n"
"uniform float u_inv_gamma;\n"
"\n"
@ -10344,7 +10344,7 @@ static const char *const fs_2_4_texel_inv_gamma = "//" FILELINE "\n"
" fragcolor.rgb = pow( fragcolor.rgb, vec3( u_inv_gamma ) ); // defaults: 1.0/2.2 gamma\n"
"}\n";
static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"uniform sampler2D u_texture_y; /*unit0*/\n"
"uniform sampler2D u_texture_cb; /*unit1*/\n"
"uniform sampler2D u_texture_cr; /*unit2*/\n"
@ -10382,7 +10382,7 @@ static const char *const fs_2_4_texel_ycbr_gamma_saturation = "//" FILELINE "\n"
"fragcolor = vec4(texel.rgb, 1.0);\n"
"}\n";
static const char *const fs_32_4_model = "//" FILELINE "\n"
const char *const fs_32_4_model = "//" FILELINE "\n"
"uniform mat4 model, view;\n"
"uniform sampler2D u_texture2d;\n"
"uniform vec3 u_coefficients_sh[9];\n"
@ -10455,7 +10455,7 @@ static const char *const fs_32_4_model = "//" FILELINE "\n"
" \n"
" }\n";
static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
const char *const fs_32_4_model_basic = "//" FILELINE "\n"
"uniform sampler2D fsDiffTex;\n"
"uniform sampler2D fsNormalTex;\n"
"uniform sampler2D fsPositionTex;\n"
@ -10471,7 +10471,7 @@ static const char *const fs_32_4_model_basic = "//" FILELINE "\n"
" fragColor = diff;// * vec4(v_normal.xyz, 1);\n"
"}\n";
static const char *const fs_3_4_skybox = "//" FILELINE "\n"
const char *const fs_3_4_skybox = "//" FILELINE "\n"
"uniform samplerCube u_cubemap;\n"
"\n"
"in vec3 v_direction;\n"
@ -10481,7 +10481,7 @@ static const char *const fs_3_4_skybox = "//" FILELINE "\n"
" fragcolor = vec4(texture(u_cubemap, v_direction).rgb, 1.0);\n"
"}\n";
static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
"uniform vec3 uSunPos = vec3( 0, 0.1, -1 ); // = [0, Math.cos(theta) * 0.3 + 0.2, -1];\n"
"\n"
"in vec3 v_direction;\n"
@ -10621,13 +10621,13 @@ static const char *const fs_3_4_skybox_rayleigh = "//" FILELINE "\n"
" return iSun * (pRlh * kRlh * totalRlh + pMie * kMie * totalMie);\n"
"}\n";
static const char *const fs_main_shadertoy = "//" FILELINE "\n"
const char *const fs_main_shadertoy = "//" FILELINE "\n"
"void mainImage( out vec4 fragColor, in vec2 fragCoord );\n"
"void main() {\n"
" mainImage(fragColor, texcoord.xy * iResolution);\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
"out vec2 texcoord;\n"
"\n"
"void main() {\n"
@ -10635,7 +10635,7 @@ static const char *const vs_0_2_fullscreen_quad_A = "//" FILELINE "\n"
" gl_Position = vec4( texCoord * 2.0 - 1.0, 0.0, 1.0 );\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -10645,7 +10645,7 @@ static const char *const vs_0_2_fullscreen_quad_B = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
"out vec2 uv;\n"
"\n"
"void main() {\n"
@ -10655,7 +10655,7 @@ static const char *const vs_0_2_fullscreen_quad_B_flipped = "//" FILELINE "\n"
" uv = vec2(x, y); // normal(y),flipped(1.0-y)\n"
"}\n";
static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
#ifndef MAX_BONES
"#define MAX_BONES 110\n"
#endif
@ -10772,7 +10772,7 @@ static const char *const vs_323444143_16_332_model = "//" FILELINE "\n"
"}\n"
"\n";
static const char *const vs_324_24_sprite = "//" FILELINE "\n"
const char *const vs_324_24_sprite = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_Position;\n"
@ -10787,7 +10787,7 @@ static const char *const vs_324_24_sprite = "//" FILELINE "\n"
" gl_Position = u_mvp * vec4(att_Position, 1.0);\n"
"}\n";
static const char *const vs_332_32 = "//" FILELINE "\n"
const char *const vs_332_32 = "//" FILELINE "\n"
"//uniform mat4 u_model, u_view, u_proj;\n"
"uniform mat4 u_mvp;\n"
"\n"
@ -10822,7 +10822,7 @@ static const char *const vs_332_32 = "//" FILELINE "\n"
" do_shadow();\n"
"}\n";
static const char *const vs_3_3_skybox = "//" FILELINE "\n"
const char *const vs_3_3_skybox = "//" FILELINE "\n"
"uniform mat4 u_mvp;\n"
"\n"
"in vec3 att_position;\n"
@ -10833,6 +10833,7 @@ static const char *const vs_3_3_skybox = "//" FILELINE "\n"
" gl_Position = position.xyww;\n"
" v_direction = att_position;\n"
"}\n";
#line 0
#line 1 "v4k_render.c"

View File

@ -2756,6 +2756,27 @@ API void* screenshot(int components); // 3 RGB, 4 RGBA, -3 BGR, -4 BGRA
API void* screenshot_async(int components); // 3 RGB, 4 RGBA, -3 BGR, -4 BGRA
#line 0
#line 1 "v4k_shaders.h"
extern const char *const fs_0_0_shadowmap_lit;
extern const char *const fs_0_0_shadowmap_unlit;
extern const char *const fs_24_4_sprite;
extern const char *const fs_2_4_preamble;
extern const char *const fs_2_4_texel_inv_gamma;
extern const char *const fs_2_4_texel_ycbr_gamma_saturation;
extern const char *const fs_32_4_model;
extern const char *const fs_32_4_model_basic;
extern const char *const fs_3_4_skybox;
extern const char *const fs_3_4_skybox_rayleigh;
extern const char *const fs_main_shadertoy;
extern const char *const vs_0_2_fullscreen_quad_A;
extern const char *const vs_0_2_fullscreen_quad_B;
extern const char *const vs_0_2_fullscreen_quad_B_flipped;
extern const char *const vs_323444143_16_332_model;
extern const char *const vs_324_24_sprite;
extern const char *const vs_332_32;
extern const char *const vs_3_3_skybox;
#line 0
#line 1 "v4k_renderdd.h"
// -----------------------------------------------------------------------------
// debugdraw framework

View File

@ -596,7 +596,7 @@ details > summary::-webkit-details-marker {
|Version: | 2023.7 |
|:--------------|:------------|
|Branch: | main |
|Commit: | 46 |
|Commit: | 50 |
<!--| Documentation last modified | { {LAST_MODIFIED} } |-->
# [V·4·K 2023.7 ](https://dev.v4.games/zaklaus/v4k)
@ -8556,6 +8556,170 @@ Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#str
</details>
## shaders
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_0_0_shadowmap_lit;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_0_0_shadowmap_unlit;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_24_4_sprite;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_2_4_preamble;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_2_4_texel_inv_gamma;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_2_4_texel_ycbr_gamma_saturation;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_32_4_model;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_32_4_model_basic;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_3_4_skybox;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_3_4_skybox_rayleigh;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const fs_main_shadertoy;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_0_2_fullscreen_quad_A;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_0_2_fullscreen_quad_B;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_0_2_fullscreen_quad_B_flipped;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_323444143_16_332_model;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_324_24_sprite;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_332_32;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
<a name="_color3(vec3"></a>
<details><summary><code lang=C>🅃 extern const char* const vs_3_3_skybox;</code></summary>
Under construction. Yet to be documented.
Other documentation examples: [dll](#dll), [strsplit](#strsplit), [strjoin](#strjoin), [IMAGE_FLAGS](#IMAGE_FLAGS) or [image_t](#image_t).
</details>
## renderdd
<a name="ddraw_color"></a>

View File

@ -1,3 +1,4 @@
#!/bin/bash 2>nul
python tools/glsl_join.py --output ./engine/split/v4k_shaders.c
python tools/glsl_join.py --output ./engine/split/v4k_shaders.h --header

View File

@ -23,19 +23,39 @@ def glsl_to_c(output_filename: str):
shader_code_escaped += "\n"
variable_name = os.path.splitext(filename)[0] # Remove the .glsl extension
c_shader_code = f'static const char *const {variable_name} = \"//\" FILELINE \"\\n\"\n{shader_code_escaped}'
c_shader_code = f'const char *const {variable_name} = \"//\" FILELINE \"\\n\"\n{shader_code_escaped}'
all_shaders.append(c_shader_code)
# Write all shaders to the C file
with open(output_filename, 'w') as f:
f.write('\n'.join(all_shaders))
f.write('\n'.join(all_shaders)+'\n')
def glsl_to_h(output_filename: str):
glsl_directory = "engine/shaders/"
all_shaders = []
for filename in os.listdir(glsl_directory):
if filename.endswith(".glsl"):
with open(os.path.join(glsl_directory, filename), 'r') as f:
variable_name = os.path.splitext(filename)[0] # Remove the .glsl extension
h_shader_code = f'extern const char *const {variable_name};'
all_shaders.append(h_shader_code)
# Write all shaders to the C file
with open(output_filename, 'w') as f:
f.write('\n'.join(all_shaders)+'\n')
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--output", required=True, help="Output filename for the C file")
parser.add_argument("--header", required=False, help="Is header file output requested", action=argparse.BooleanOptionalAction)
args = parser.parse_args()
glsl_to_c(args.output)
if args.header is True:
glsl_to_h(args.output)
else:
glsl_to_c(args.output)
if __name__ == "__main__":
main()

View File

@ -34,7 +34,7 @@ def c_to_glsl(input_filename: str):
for line in lines:
if not capturing:
match = re.search(r'static const char \*const ([a-zA-Z0-9_]+) =', line)
match = re.search(r'const char \*const ([a-zA-Z0-9_]+) =', line)
if match:
output_filename = f"engine/shaders/{match.group(1)}.glsl"
capturing = True