diff --git a/mpfw/MPFW_Quake.cpp b/mpfw/MPFW_Quake.cpp index 0b71494..ae803ba 100644 --- a/mpfw/MPFW_Quake.cpp +++ b/mpfw/MPFW_Quake.cpp @@ -490,16 +490,18 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path) throw; } - Image lightmap = GenImageColor(lmw, lmh, WHITE); + Image lightmap = GenImageColor(lmw, lmh, BLANK); cface.hasLightMap = true; for (int y = 0; y < lmh; y++) { for (int x = 0; x < lmw; x++) { unsigned char lightValue = data.lightmap[y*lmw+x + lmbase]; + unsigned char invertedLightValue = 255 - lightValue; + // std::cout << "light value : " << (int)invertedLightValue << "\n"; ImageDrawPixel(&lightmap, x, y, { - lightValue, - lightValue, - lightValue, - 255 + 0, + 0, + 0, + invertedLightValue }); } } @@ -514,7 +516,7 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path) data.lightMaps.push_back(lightmapRLMipTex); cface.glLightmapTextureId = lightmapTexture.id; - + SetTextureFilter(lightmapTexture, TEXTURE_FILTER_BILINEAR); UnloadImage(lightmap); } diff --git a/mpfw/main.cpp b/mpfw/main.cpp index b896d5b..26ce394 100644 --- a/mpfw/main.cpp +++ b/mpfw/main.cpp @@ -188,7 +188,7 @@ int main() { SetConfigFlags(FLAG_WINDOW_RESIZABLE); InitWindow(1280, 720, TextFormat("mpfw")); - // SetTargetFPS(60); + SetTargetFPS(60); SetExitKey(0); DisableCursor(); @@ -332,16 +332,9 @@ int main() { 255,// - (unsigned char)map.data.renderFaces[i].baselight, 255); - if (map.data.renderFaces[i].hasLightMap) rlSetTexture(map.data.renderFaces[i].glLightmapTextureId); - else rlSetTexture(map.data.renderFaces[i].glTextureId); + rlSetTexture(map.data.renderFaces[i].glTextureId); - - - - - - for (int j = 1; j < map.data.renderFaces[i].vertices.size(); j++) { rlBegin(RL_QUADS); // for texturing reasons because rlgl Vector3 a = map.data.renderFaces[i].vertices[0], @@ -365,6 +358,34 @@ int main() { rlEnd(); } + + if (map.data.renderFaces[i].hasLightMap) { + rlColor4f(1, 1, 1, 0.5); + rlSetTexture(map.data.renderFaces[i].glLightmapTextureId); + for (int j = 1; j < map.data.renderFaces[i].vertices.size(); j++) { + rlBegin(RL_QUADS); // for texturing reasons because rlgl + Vector3 a = map.data.renderFaces[i].vertices[0], + b = map.data.renderFaces[i].vertices[j], + c = map.data.renderFaces[i].vertices[j - 1]; + + Vector2 at = map.data.renderFaces[i].texCoords[0], + bt = map.data.renderFaces[i].texCoords[j], + ct = map.data.renderFaces[i].texCoords[j - 1]; + + + + rlTexCoord2f(at.x, at.y); + rlVertex3f(a.x, a.y, a.z); + rlTexCoord2f(bt.x, bt.y); + rlVertex3f(b.x, b.y, b.z); + rlTexCoord2f(ct.x, ct.y); + rlVertex3f(c.x, c.y, c.z); + rlVertex3f(c.x, c.y, c.z); // why does RLGL fuck up triangles? is there something i'm missing? + + + rlEnd(); + } + } }