main
Dominik Madarász 2023-12-02 11:05:15 +01:00
parent fe24c0c5e7
commit bc1ff71f74
6 changed files with 85 additions and 30 deletions

View File

@ -344,7 +344,7 @@ if "%1"=="gwk" (
copy/y ..\fwk-mirror\engine\fwk _fwk\engine\fwk copy/y ..\fwk-mirror\engine\fwk _fwk\engine\fwk
copy/y ..\fwk-mirror\engine\split\*.inl _fwk\engine\split\ copy/y ..\fwk-mirror\engine\split\*.inl _fwk\engine\split\
rem copy/y ..\fwk-mirror\engine\split\3rd_*.c _fwk\engine\split\ rem copy/y ..\fwk-mirror\engine\split\3rd_*.c _fwk\engine\split\
make back call MAKE.bat back
exit /b exit /b
) )

View File

@ -367390,11 +367390,18 @@ texture_t texture_checker() {
pixels[i++] = (rgb>>8) & 255; pixels[i++] = (rgb>>8) & 255;
pixels[i++] = (rgb>>0) & 255; pixels[i++] = (rgb>>0) & 255;
pixels[i++] = 255; pixels[i++] = 255;
#else #elif 0
extern const uint32_t secret_palette[32]; extern const uint32_t secret_palette[32];
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255; uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
uint32_t rgb = rgba(lum,lum,lum,255); uint32_t rgb = rgba(lum,lum,lum,255);
pixels[i++] = rgb; pixels[i++] = rgb;
#else
int j = y, i = x;
unsigned char *p = (unsigned char *)&pixels[x + y * 256];
p[0] = (i / 16) % 2 == (j / 16) % 2 ? 255 : 0; // r
p[1] = ((i - j) / 16) % 2 == 0 ? 255 : 0; // g
p[2] = ((i + j) / 16) % 2 == 0 ? 255 : 0; // b
p[3] = 255; // a
#endif #endif
} }
} }
@ -369547,6 +369554,10 @@ void model_set_state(model_t m) {
glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,color) ); glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,color) );
glEnableVertexAttribArray(11); glEnableVertexAttribArray(11);
// lmap data
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
glEnableVertexAttribArray(12);
// animation // animation
if(numframes > 0) { if(numframes > 0) {
glVertexAttribPointer( 8, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,blendindexes) ); glVertexAttribPointer( 8, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,blendindexes) );
@ -369582,10 +369593,6 @@ void model_set_state(model_t m) {
glVertexAttribDivisor(7, 1); glVertexAttribDivisor(7, 1);
} }
// lmap data
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
glEnableVertexAttribArray(12);
// 7 bitangent? into texcoord.z? // 7 bitangent? into texcoord.z?
glBindVertexArray( 0 ); glBindVertexArray( 0 );
@ -369941,7 +369948,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
// if( shaderprog < 0 ) { // if( shaderprog < 0 ) {
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs,
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor",
va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":""));
// } // }
// ASSERT(shaderprog > 0); // ASSERT(shaderprog > 0);
@ -370350,7 +370357,7 @@ lightmap_t lightmap(int hmsize, float cnear, float cfar, vec3 color, int passes,
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
lm.shader = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, lm.shader = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs,
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor",
va("%s", "LIGHTMAP_BAKING")); va("%s", "LIGHTMAP_BAKING"));
return lm; return lm;

View File

@ -788,11 +788,18 @@ texture_t texture_checker() {
pixels[i++] = (rgb>>8) & 255; pixels[i++] = (rgb>>8) & 255;
pixels[i++] = (rgb>>0) & 255; pixels[i++] = (rgb>>0) & 255;
pixels[i++] = 255; pixels[i++] = 255;
#else #elif 0
extern const uint32_t secret_palette[32]; extern const uint32_t secret_palette[32];
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255; uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
uint32_t rgb = rgba(lum,lum,lum,255); uint32_t rgb = rgba(lum,lum,lum,255);
pixels[i++] = rgb; pixels[i++] = rgb;
#else
int j = y, i = x;
unsigned char *p = (unsigned char *)&pixels[x + y * 256];
p[0] = (i / 16) % 2 == (j / 16) % 2 ? 255 : 0; // r
p[1] = ((i - j) / 16) % 2 == 0 ? 255 : 0; // g
p[2] = ((i + j) / 16) % 2 == 0 ? 255 : 0; // b
p[3] = 255; // a
#endif #endif
} }
} }
@ -2945,6 +2952,10 @@ void model_set_state(model_t m) {
glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,color) ); glVertexAttribPointer(11, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,color) );
glEnableVertexAttribArray(11); glEnableVertexAttribArray(11);
// lmap data
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
glEnableVertexAttribArray(12);
// animation // animation
if(numframes > 0) { if(numframes > 0) {
glVertexAttribPointer( 8, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,blendindexes) ); glVertexAttribPointer( 8, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex,blendindexes) );
@ -2980,10 +2991,6 @@ void model_set_state(model_t m) {
glVertexAttribDivisor(7, 1); glVertexAttribDivisor(7, 1);
} }
// lmap data
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
glEnableVertexAttribArray(12);
// 7 bitangent? into texcoord.z? // 7 bitangent? into texcoord.z?
glBindVertexArray( 0 ); glBindVertexArray( 0 );
@ -3339,7 +3346,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
// if( shaderprog < 0 ) { // if( shaderprog < 0 ) {
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, int shaderprog = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs,
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor",
va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":"")); va("SHADING_PHONG,%s", (flags&MODEL_RIMLIGHT)?"RIM":""));
// } // }
// ASSERT(shaderprog > 0); // ASSERT(shaderprog > 0);
@ -3748,7 +3755,7 @@ lightmap_t lightmap(int hmsize, float cnear, float cfar, vec3 color, int passes,
const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM const char *symbols[] = { "{{include-shadowmap}}", vfs_read("shaders/fs_0_0_shadowmap_lit.glsl") }; // #define RIM
lm.shader = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs, lm.shader = shader(strlerp(1,symbols,vfs_read("shaders/vs_323444143_16_3322_model.glsl")), strlerp(1,symbols,vfs_read("shaders/fs_32_4_model.glsl")), //fs,
"att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_bitangent,att_texcoord2","fragColor", "att_position,att_texcoord,att_normal,att_tangent,att_instanced_matrix,,,,att_indexes,att_weights,att_vertexindex,att_color,att_texcoord2,att_bitangent","fragColor",
va("%s", "LIGHTMAP_BAKING")); va("%s", "LIGHTMAP_BAKING"));
return lm; return lm;

View File

@ -17719,11 +17719,18 @@ texture_t texture_checker() {
pixels[i++] = (rgb>>8) & 255; pixels[i++] = (rgb>>8) & 255;
pixels[i++] = (rgb>>0) & 255; pixels[i++] = (rgb>>0) & 255;
pixels[i++] = 255; pixels[i++] = 255;
#else #elif 0
extern const uint32_t secret_palette[32]; extern const uint32_t secret_palette[32];
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255; uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
uint32_t rgb = rgba(lum,lum,lum,255); uint32_t rgb = rgba(lum,lum,lum,255);
pixels[i++] = rgb; pixels[i++] = rgb;
#else
int j = y, i = x;
unsigned char *p = (unsigned char *)&pixels[x + y * 256];
p[0] = (i / 16) % 2 == (j / 16) % 2 ? 255 : 0; // r
p[1] = ((i - j) / 16) % 2 == 0 ? 255 : 0; // g
p[2] = ((i + j) / 16) % 2 == 0 ? 255 : 0; // b
p[3] = 255; // a
#endif #endif
} }
} }
@ -20726,7 +20733,7 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm
lmSetGeometry(lm->ctx, m->pivot, lmSetGeometry(lm->ctx, m->pivot,
LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, position), sizeof(iqm_vertex), LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, position), sizeof(iqm_vertex),
LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, normal), sizeof(iqm_vertex), LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, normal), sizeof(iqm_vertex),
LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, texcoord2), sizeof(iqm_vertex), LM_FLOAT, (uint8_t*)m->verts + offsetof(iqm_vertex, texcoord), sizeof(iqm_vertex),
m->num_tris*3, LM_UNSIGNED_INT, m->tris); m->num_tris*3, LM_UNSIGNED_INT, m->tris);
glDisable(GL_BLEND); glDisable(GL_BLEND);

View File

@ -1,8 +1,6 @@
// License: BSD unless otherwise stated. // License: BSD unless otherwise stated.
// https://github.com/ccxvii/asstools // https://github.com/ccxvii/asstools
#include "3rd_base64.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -14,6 +12,13 @@
#include <assimp/scene.h> #include <assimp/scene.h>
#include <assimp/postprocess.h> #include <assimp/postprocess.h>
#define BASE64_C
#define FREE free
#define MALLOC malloc
#include "3rd_base64.h"
#define STB_IMAGE_IMPLEMENTATION
#include "3rd_stb_image.h"
int verbose = 0; int verbose = 0;
int need_to_bake_skin = 0; int need_to_bake_skin = 0;
int save_all_bones = 0; int save_all_bones = 0;
@ -1077,15 +1082,42 @@ void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *no
#if 1 // embedded textures #if 1 // embedded textures
char *embedded = 0; char *embedded = 0;
if( strchr(buffer, '*') ) { // look for embedded textures. referenced like *1, *2, *3... where N is texture ID
// look for embedded textures. referenced like *1, *2, *3... where N is texture ID
// note: mHeight can be zero, in this case texture->pcData is not RGB values but
// compressed JPEG/PNG/etc. data. Using stb_image to decode such image in that case.
if( !strchr(buffer, '*') ) {
for( int j = 0; j < scene->mNumTextures; ++j ) {
struct aiTexture *tex = scene->mTextures[j];
if( strstr(tex->mFilename.data, buffer + !isalpha(buffer[0])) ) {
snprintf(buffer, sizeof(buffer-1), "*%d", j);
break;
}
}
}
if( strchr(buffer, '*') ) {
int tex_id = atoi(buffer+1); int tex_id = atoi(buffer+1);
if( tex_id < scene->mNumTextures ) { if( tex_id < scene->mNumTextures ) {
struct aiTexture *tex = scene->mTextures[tex_id]; struct aiTexture *tex = scene->mTextures[tex_id];
struct aiTexel *data = tex->pcData; struct aiTexel *data = tex->pcData;
const char *hint = tex->achFormatHint; // "rgba8888" or "png"
unsigned w = tex->mWidth + !tex->mWidth; unsigned w = tex->mWidth + !tex->mWidth;
unsigned h = tex->mHeight + !tex->mHeight; unsigned h = tex->mHeight + !tex->mHeight;
const char *hint = tex->achFormatHint; // "rgba8888" or "png"
// stbi_uc *decoded = 0;
if( !tex->mHeight )
{
int len = (int)w;
embedded = base64_encode(data, len); // leak
// int x = 0, y = 0, n = 0;
// decoded = stbi_load_from_memory((const stbi_uc *)data, len, &x, &y, &n, 4);
// w = x; h = y; data = (struct aiTexel *)decoded;
}
#if 1 #if 1
if(!embedded)
embedded = base64_encode(data, w * h * sizeof(struct aiTexel)); // leak embedded = base64_encode(data, w * h * sizeof(struct aiTexel)); // leak
#else #else
fprintf(stderr, "%dx%d (%s)\n", w,h,hint); fprintf(stderr, "%dx%d (%s)\n", w,h,hint);
@ -1096,6 +1128,8 @@ void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *no
fwrite(&data[x+y*w].b, 1, 4, out); fwrite(&data[x+y*w].b, 1, 4, out);
fclose(out); fclose(out);
#endif #endif
// if( decoded ) stbi_image_free(decoded);
} }
} }
#endif #endif

Binary file not shown.