sync fwk
parent
fe24c0c5e7
commit
bc1ff71f74
2
MAKE.bat
2
MAKE.bat
|
@ -344,7 +344,7 @@ if "%1"=="gwk" (
|
|||
copy/y ..\fwk-mirror\engine\fwk _fwk\engine\fwk
|
||||
copy/y ..\fwk-mirror\engine\split\*.inl _fwk\engine\split\
|
||||
rem copy/y ..\fwk-mirror\engine\split\3rd_*.c _fwk\engine\split\
|
||||
make back
|
||||
call MAKE.bat back
|
||||
|
||||
exit /b
|
||||
)
|
||||
|
|
|
@ -367390,11 +367390,18 @@ texture_t texture_checker() {
|
|||
pixels[i++] = (rgb>>8) & 255;
|
||||
pixels[i++] = (rgb>>0) & 255;
|
||||
pixels[i++] = 255;
|
||||
#else
|
||||
#elif 0
|
||||
extern const uint32_t secret_palette[32];
|
||||
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
|
||||
uint32_t rgb = rgba(lum,lum,lum,255);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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) );
|
||||
glEnableVertexAttribArray(11);
|
||||
|
||||
// lmap data
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
|
||||
glEnableVertexAttribArray(12);
|
||||
|
||||
// animation
|
||||
if(numframes > 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
// lmap data
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
|
||||
glEnableVertexAttribArray(12);
|
||||
|
||||
// 7 bitangent? into texcoord.z?
|
||||
|
||||
glBindVertexArray( 0 );
|
||||
|
@ -369941,7 +369948,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
|
|||
// if( shaderprog < 0 ) {
|
||||
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,
|
||||
"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":""));
|
||||
// }
|
||||
// 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
|
||||
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"));
|
||||
|
||||
return lm;
|
||||
|
|
|
@ -788,11 +788,18 @@ texture_t texture_checker() {
|
|||
pixels[i++] = (rgb>>8) & 255;
|
||||
pixels[i++] = (rgb>>0) & 255;
|
||||
pixels[i++] = 255;
|
||||
#else
|
||||
#elif 0
|
||||
extern const uint32_t secret_palette[32];
|
||||
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
|
||||
uint32_t rgb = rgba(lum,lum,lum,255);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -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) );
|
||||
glEnableVertexAttribArray(11);
|
||||
|
||||
// lmap data
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
|
||||
glEnableVertexAttribArray(12);
|
||||
|
||||
// animation
|
||||
if(numframes > 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
// lmap data
|
||||
glVertexAttribPointer(12, 2, GL_FLOAT, GL_FALSE, sizeof(iqm_vertex), (GLvoid*)offsetof(iqm_vertex, texcoord2) );
|
||||
glEnableVertexAttribArray(12);
|
||||
|
||||
// 7 bitangent? into texcoord.z?
|
||||
|
||||
glBindVertexArray( 0 );
|
||||
|
@ -3339,7 +3346,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
|
|||
// if( shaderprog < 0 ) {
|
||||
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,
|
||||
"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":""));
|
||||
// }
|
||||
// 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
|
||||
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"));
|
||||
|
||||
return lm;
|
||||
|
|
11
engine/v4k.c
11
engine/v4k.c
|
@ -17719,11 +17719,18 @@ texture_t texture_checker() {
|
|||
pixels[i++] = (rgb>>8) & 255;
|
||||
pixels[i++] = (rgb>>0) & 255;
|
||||
pixels[i++] = 255;
|
||||
#else
|
||||
#elif 0
|
||||
extern const uint32_t secret_palette[32];
|
||||
uint32_t lum = (x^y) & 8 ? 128 : (x^y) & 128 ? 192 : 255;
|
||||
uint32_t rgb = rgba(lum,lum,lum,255);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -20726,7 +20733,7 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm
|
|||
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, 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);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
// License: BSD unless otherwise stated.
|
||||
// https://github.com/ccxvii/asstools
|
||||
|
||||
#include "3rd_base64.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -14,6 +12,13 @@
|
|||
#include <assimp/scene.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 need_to_bake_skin = 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
|
||||
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);
|
||||
if( tex_id < scene->mNumTextures ) {
|
||||
struct aiTexture *tex = scene->mTextures[tex_id];
|
||||
struct aiTexel *data = tex->pcData;
|
||||
const char *hint = tex->achFormatHint; // "rgba8888" or "png"
|
||||
unsigned w = tex->mWidth + !tex->mWidth;
|
||||
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(!embedded)
|
||||
embedded = base64_encode(data, w * h * sizeof(struct aiTexel)); // leak
|
||||
#else
|
||||
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);
|
||||
fclose(out);
|
||||
#endif
|
||||
|
||||
// if( decoded ) stbi_image_free(decoded);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue