lmap updates

main
Dominik Madarász 2023-12-01 22:19:41 +01:00
parent 7bcfb3e00c
commit 4af34422f2
5 changed files with 14 additions and 25 deletions

View File

@ -2,11 +2,12 @@
skybox_t sky;
model_t litm;
lightmap_t baker;
void bakedrawmodel(lightmap_t *lm, model_t *m, float *view, float *proj, void *userdata) {
shader_bind(lm->shader);
model_render(*m, proj, view, m->pivot, lm->shader);
shader_float("u_litboost", 4.0);
shader_float("u_litboost", 8.0);
model_render(litm, proj, view, litm.pivot, lm->shader);
}
@ -27,9 +28,11 @@ int main()
camera_t cam = camera();
sky = skybox(0, 0); skybox_mie_calc_sh(&sky, 2.0f);
model_t mdl = model("gazebo.obj", 0);
litm = model("cube.obj", MODEL_MATCAPS);
litm = model("kgirls01.fbx", 0);
{
mat44 lp; scaling44(lp, 0.3, 0.3, 0.3); translate44(lp, 8,4,0);
mat44 lp; id44(lp);
// scaling44(lp, 10, 10, 10);
translate44(lp, 0,2,0);
copy44(litm.pivot, lp);
}
rotate44(mdl.pivot, -90, 1, 0, 0);
@ -38,11 +41,11 @@ int main()
shader_vec3v("u_coefficients_sh", 9, sky.cubemap.sh);
// shader_bool("u_texmod", 0);
unsigned char emissive[] = { 255, 180, 0, 255 };
texture_t emission = texture_create(1,1,4,emissive,TEXTURE_LINEAR);
model_set_texture(litm, emission);
// unsigned char emissive[] = { 255, 180, 0, 255 };
// texture_t emission = texture_create(1,1,4,emissive,TEXTURE_LINEAR);
// model_set_texture(litm, emission);
lightmap_t baker = lightmap(64, 0.01, 100, vec3(0,0,0), 2, 0.01, 0.0);
baker = lightmap(64, 0.01, 100, vec3(0,0,0), 2, 0.01, -1.0);
lightmap_setup(&baker, 512, 512);
array_push(baker.models, &mdl);

View File

@ -9,7 +9,7 @@ uniform vec4 u_diffuse = vec4(1.0,1.0,1.0,1.0);
// lightmapping
uniform sampler2D u_lightmap;
uniform bool u_texlit;
uniform bool u_texmod = true;
uniform bool u_texmod = false;
uniform float u_litboost = 1.0;
in vec3 v_position;
@ -157,7 +157,7 @@ void main() {
vec4 lit = vec4(1.0, 1.0, 1.0, 1.0);
// SH lighting
if (!u_texlit) {
/* if (!u_texlit) */ {
vec3 result = sh_lighting(n);
if( (result.x*result.x+result.y*result.y+result.z*result.z) > 0.0 ) lit = vec4(result, 1.0);
}
@ -181,12 +181,10 @@ void main() {
vec4 litsample = texture(u_lightmap, v_texcoord);
if (u_texmod) {
diffuse *= litsample;
diffuse.rgb *= litsample.rgb;
} else {
diffuse += litsample;
diffuse.rgb += litsample.rgb;
}
diffuse.rgb += sh_lighting(n);
}
// lighting mix

View File

@ -370362,10 +370362,6 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm
texture_destroy(&m->lightmap);
}
m->lightmap = texture_create(w, h, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT);
glBindTexture(GL_TEXTURE_2D, m->lightmap.id);
unsigned char emissive[] = { 0, 0, 0, 255 };
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, emissive);
glBindTexture(GL_TEXTURE_2D, 0);
}
for (int b = 0; b < bounces; b++) {

View File

@ -3782,10 +3782,6 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm
texture_destroy(&m->lightmap);
}
m->lightmap = texture_create(w, h, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT);
glBindTexture(GL_TEXTURE_2D, m->lightmap.id);
unsigned char emissive[] = { 0, 0, 0, 255 };
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, emissive);
glBindTexture(GL_TEXTURE_2D, 0);
}
for (int b = 0; b < bounces; b++) {

View File

@ -20698,10 +20698,6 @@ void lightmap_bake(lightmap_t *lm, int bounces, void (*drawscene)(lightmap_t *lm
texture_destroy(&m->lightmap);
}
m->lightmap = texture_create(w, h, 4, 0, TEXTURE_LINEAR|TEXTURE_FLOAT);
glBindTexture(GL_TEXTURE_2D, m->lightmap.id);
unsigned char emissive[] = { 0, 0, 0, 255 };
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, emissive);
glBindTexture(GL_TEXTURE_2D, 0);
}
for (int b = 0; b < bounces; b++) {