From: Terri00 Date: Tue, 25 Jun 2019 20:19:35 +0000 (+0100) Subject: Fixes #12 [prop_statics with blank model reference] X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=87f5d6e20acc34c50ab1c03646965972b58d1923;p=tar-legacy.git Fixes #12 [prop_statics with blank model reference] --- diff --git a/MCDV/dds.hpp b/MCDV/dds.hpp index b5d6383..1997a76 100644 --- a/MCDV/dds.hpp +++ b/MCDV/dds.hpp @@ -43,7 +43,8 @@ enum IMG { MODE_RGB888, MODE_RGBA8888, MODE_DXT1, - MODE_DXT5 + MODE_DXT5, + MODE_DXT1_1BA }; UINT32 SwapEndian(UINT32 val) @@ -90,8 +91,9 @@ compressedSize: Pointer to final data size w: image width h: image height mode: compression mode to use +useAlpha: Use 1 bit alpha. */ -uint8_t* compressImageDXT1(uint8_t* buf_RGB, uint32_t w, uint32_t h, uint32_t* cSize) { +uint8_t* compressImageDXT1(uint8_t* buf_RGB, uint32_t w, uint32_t h, uint32_t* cSize, bool useAlpha = false) { *cSize = ((w / 4) * (h / 4)) * BLOCK_SIZE_DXT1; //Create output buffer @@ -113,14 +115,23 @@ uint8_t* compressImageDXT1(uint8_t* buf_RGB, uint32_t w, uint32_t h, uint32_t* c uint8_t* src = new uint8_t[64]; //Create source RGBA buffer for (int _y = 0; _y < 4; _y++) { for (int _x = 0; _x < 4; _x++) { - src[(_x + (_y * 4)) * 4 + 0] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 0]; - src[(_x + (_y * 4)) * 4 + 1] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 1]; - src[(_x + (_y * 4)) * 4 + 2] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 2]; - src[(_x + (_y * 4)) * 4 + 3] = 0xFF; + src[(_x + (_y * 4)) * 4 + 0] = buf_RGB[(globalX + _x + ((h - (globalY + _y) - 1) * w)) * 4 + 0]; + src[(_x + (_y * 4)) * 4 + 1] = buf_RGB[(globalX + _x + ((h - (globalY + _y) - 1) * w)) * 4 + 1]; + src[(_x + (_y * 4)) * 4 + 2] = buf_RGB[(globalX + _x + ((h - (globalY + _y) - 1) * w)) * 4 + 2]; + src[(_x + (_y * 4)) * 4 + 3] = buf_RGB[(globalX + _x + ((h - (globalY + _y) - 1) * w)) * 4 + 3]; } } stb_compress_dxt_block((unsigned char*)outBuffer + (blockindex * BLOCK_SIZE_DXT1), src, 0, STB_DXT_HIGHQUAL); + + // We need to do 1ba manually weeee + if (useAlpha) { + for (int i = 0; i < 16; i++) { + if (src[(i * 4) + 3] < 0xFFFFFFF) { + *((unsigned char*)outBuffer + (blockindex * BLOCK_SIZE_DXT1) + (i / 4) + 4) |= (0x3 << (i % 4)); + } + } + } free(src); } @@ -158,10 +169,10 @@ uint8_t* compressImageDXT5(uint8_t* buf_RGB, uint32_t w, uint32_t h, uint32_t* c uint8_t* src = new uint8_t[64]; //Create source RGBA buffer for (int _y = 0; _y < 4; _y++) { for (int _x = 0; _x < 4; _x++) { - src[(_x + (_y * 4)) * 4 + 0] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 0]; - src[(_x + (_y * 4)) * 4 + 1] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 1]; - src[(_x + (_y * 4)) * 4 + 2] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 3 + 2]; - src[(_x + (_y * 4)) * 4 + 3] = 0xFF; + src[(_x + (_y * 4)) * 4 + 0] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 4 + 0]; + src[(_x + (_y * 4)) * 4 + 1] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 4 + 1]; + src[(_x + (_y * 4)) * 4 + 2] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 4 + 2]; + src[(_x + (_y * 4)) * 4 + 3] = buf_RGB[(globalX + _x + ((h - (globalY + _y)) * w)) * 4 + 3]; } } @@ -186,12 +197,14 @@ bool dds_write(uint8_t* imageData, const char* filename, uint32_t w, uint32_t h, int final_image_size = 0; switch (mode) { + case IMG::MODE_DXT1_1BA: + header.ddspf.dwFlags |= DDPF_ALPHA; case IMG::MODE_DXT1: header.dwPitchOrLinearSize = SwapEndian(__max(1, ((w + 3) / 4)) * BLOCK_SIZE_DXT1); header.ddspf.dwFlags |= DDPF_FOURCC; header.ddspf.dwFourCC = SwapEndian((uint32_t)'DXT1'); header.dwFlags |= DDSD_LINEARSIZE; - + break; case IMG::MODE_DXT5: header.dwPitchOrLinearSize = SwapEndian(__max(1, ((w + 3) / 4)) * BLOCK_SIZE_DXT5); @@ -247,6 +260,11 @@ bool dds_write(uint8_t* imageData, const char* filename, uint32_t w, uint32_t h, uint8_t* outputBuffer = compressImageDXT1(imageData, w, h, &size); output.write((char*)outputBuffer, size); } + else if (mode == IMG::MODE_DXT1_1BA) { + uint32_t size; + uint8_t* outputBuffer = compressImageDXT1(imageData, w, h, &size, true); + output.write((char*)outputBuffer, size); + } else if (mode == IMG::MODE_DXT5) { uint32_t size; uint8_t* outputBuffer = compressImageDXT5(imageData, w, h, &size); diff --git a/MCDV/layer0.png b/MCDV/layer0.png index 0bb5b28..42af8fe 100644 Binary files a/MCDV/layer0.png and b/MCDV/layer0.png differ diff --git a/MCDV/layer1.png b/MCDV/layer1.png index a76b4d3..e435f64 100644 Binary files a/MCDV/layer1.png and b/MCDV/layer1.png differ diff --git a/MCDV/layerx.png b/MCDV/layerx.png index 33eaa87..3767dd2 100644 Binary files a/MCDV/layerx.png and b/MCDV/layerx.png differ diff --git a/MCDV/main2.cpp b/MCDV/main2.cpp index 231e4e5..ce2718b 100644 --- a/MCDV/main2.cpp +++ b/MCDV/main2.cpp @@ -78,7 +78,7 @@ uint32_t g_msaa_mul = 1; void render_to_png(int x, int y, const char* filepath); void save_to_dds(int x, int y, const char* filepath, IMG imgmode = IMG::MODE_DXT1); -#define _DEBUG +//#define _DEBUG int app(int argc, const char** argv) { #ifndef _DEBUG @@ -261,6 +261,8 @@ int app(int argc, const char** argv) { _flayers[l]->BindHeightToTexSlot(0); g_shader_multilayer_blend->setFloat("layer_target", !above? l->layer_min: l->layer_max); + g_shader_multilayer_blend->setFloat("layer_min", l->layer_min); + g_shader_multilayer_blend->setFloat("layer_max", l->layer_max); g_mesh_screen_quad->Draw(); } @@ -268,6 +270,8 @@ int app(int argc, const char** argv) { //g_shader_multilayer_blend->setFloat("saturation", 1.0f); //g_shader_multilayer_blend->setFloat("value", 1.0f); g_shader_multilayer_blend->setFloat("active", 1.0f); + g_shader_multilayer_blend->setFloat("layer_min", megalayer.layer_min); + g_shader_multilayer_blend->setFloat("layer_max", megalayer.layer_max); _flayers[&megalayer]->BindRTToTexSlot(1); _flayers[&megalayer]->BindHeightToTexSlot(0); @@ -316,73 +320,87 @@ int app(int argc, const char** argv) { // final composite //render_to_png(1024, 1024, ("comp" + std::to_string(i++) + ".png").c_str()); + if (i == 0) { - save_to_dds(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name +"_radar.dds", true).c_str(), g_tar_config->m_dds_img_mode); + if(g_tar_config->m_write_dds) + save_to_dds(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name +"_radar.dds", true).c_str(), g_tar_config->m_dds_img_mode); + + if(g_tar_config->m_write_png) + render_to_png(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + "_radar.png", true).c_str()); + i++; } else { - save_to_dds(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + "_layer" + std::to_string(i++) + "_radar.dds", true).c_str(), g_tar_config->m_dds_img_mode); + if (g_tar_config->m_write_dds) + save_to_dds(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + "_layer" + std::to_string(i) + "_radar.dds", true).c_str(), g_tar_config->m_dds_img_mode); + + if (g_tar_config->m_write_png) + render_to_png(g_renderWidth, g_renderHeight, filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + "_layer" + std::to_string(i) + "_radar.png", true).c_str()); + + i++; } FBuffer::Unbind(); } #pragma endregion - - std::cout << "Generating radar .TXT... "; - - kv::DataBlock node_radar = kv::DataBlock(); - node_radar.name = "\"" + g_mapfile_name + "\""; - node_radar.Values.insert({ "material", "overviews/" + g_mapfile_name }); - - node_radar.Values.insert({ "pos_x", std::to_string(g_tar_config->m_view_origin.x) }); - node_radar.Values.insert({ "pos_y", std::to_string(g_tar_config->m_view_origin.y) }); - node_radar.Values.insert({ "scale", std::to_string(g_tar_config->m_render_ortho_scale / g_renderWidth) }); - - if (g_tar_config->layers.size() > 1) { - kv::DataBlock node_vsections = kv::DataBlock(); - node_vsections.name = "\"verticalsections\""; - - int ln = 0; - for (auto && layer : g_tar_config->layers) { - kv::DataBlock node_layer = kv::DataBlock(); - if (ln == 0) { - node_layer.name = "\"default\""; ln++; + if (g_tar_config->m_write_txt) + { + std::cout << "Generating radar .TXT... "; + + kv::DataBlock node_radar = kv::DataBlock(); + node_radar.name = "\"" + g_mapfile_name + "\""; + node_radar.Values.insert({ "material", "overviews/" + g_mapfile_name }); + + node_radar.Values.insert({ "pos_x", std::to_string(g_tar_config->m_view_origin.x) }); + node_radar.Values.insert({ "pos_y", std::to_string(g_tar_config->m_view_origin.y) }); + node_radar.Values.insert({ "scale", std::to_string(g_tar_config->m_render_ortho_scale / g_renderWidth) }); + + if (g_tar_config->layers.size() > 1) { + kv::DataBlock node_vsections = kv::DataBlock(); + node_vsections.name = "\"verticalsections\""; + + int ln = 0; + for (auto && layer : g_tar_config->layers) { + kv::DataBlock node_layer = kv::DataBlock(); + if (ln == 0) { + node_layer.name = "\"default\""; ln++; + } + else node_layer.name = "\"layer" + std::to_string(ln++) + "\""; + + node_layer.Values.insert({ "AltitudeMin", std::to_string(layer.layer_max) }); + node_layer.Values.insert({ "AltitudeMax", std::to_string(layer.layer_min) }); + + node_vsections.SubBlocks.push_back(node_layer); } - else node_layer.name = "\"layer" + std::to_string(ln++) + "\""; - node_layer.Values.insert({ "AltitudeMin", std::to_string(layer.layer_max) }); - node_layer.Values.insert({ "AltitudeMax", std::to_string(layer.layer_min) }); - - node_vsections.SubBlocks.push_back(node_layer); + node_radar.SubBlocks.push_back(node_vsections); } - node_radar.SubBlocks.push_back(node_vsections); - } + // Try resolve spawn positions + glm::vec3* loc_spawnCT = g_vmf_file->calculateSpawnAVG_PMIN("info_player_counterterrorist"); + glm::vec3* loc_spawnT = g_vmf_file->calculateSpawnAVG_PMIN("info_player_terrorist"); - // Try resolve spawn positions - glm::vec3* loc_spawnCT = g_vmf_file->calculateSpawnAVG_PMIN("info_player_counterterrorist"); - glm::vec3* loc_spawnT = g_vmf_file->calculateSpawnAVG_PMIN("info_player_terrorist"); + if (loc_spawnCT != NULL) { + node_radar.Values.insert({ "CTSpawn_x", std::to_string(util::roundf(remap(loc_spawnCT->x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + node_radar.Values.insert({ "CTSpawn_y", std::to_string(util::roundf(remap(loc_spawnCT->z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + } + if (loc_spawnT != NULL) { + node_radar.Values.insert({ "TSpawn_x", std::to_string(util::roundf(remap(loc_spawnT->x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + node_radar.Values.insert({ "TSpawn_y", std::to_string(util::roundf(remap(loc_spawnT->z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + } - if (loc_spawnCT != NULL) { - node_radar.Values.insert({ "CTSpawn_x", std::to_string(util::roundf(remap(loc_spawnCT->x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); - node_radar.Values.insert({ "CTSpawn_y", std::to_string(util::roundf(remap(loc_spawnCT->z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); - } - if (loc_spawnT != NULL) { - node_radar.Values.insert({ "TSpawn_x", std::to_string(util::roundf(remap(loc_spawnT->x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); - node_radar.Values.insert({ "TSpawn_y", std::to_string(util::roundf(remap(loc_spawnT->z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); - } + int hostn = 1; + for (auto && hostage : g_vmf_file->get_entities_by_classname("info_hostage_spawn")) { + node_radar.Values.insert({ "Hostage" + std::to_string(hostn) + "_x", std::to_string(util::roundf(remap(hostage->m_origin.x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + node_radar.Values.insert({ "Hostage" + std::to_string(hostn++) + "_y", std::to_string(util::roundf(remap(hostage->m_origin.z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + } - int hostn = 1; - for (auto && hostage : g_vmf_file->get_entities_by_classname("info_hostage_spawn")) { - node_radar.Values.insert({ "Hostage" + std::to_string(hostn) + "_x", std::to_string(util::roundf(remap(hostage->m_origin.x, g_tar_config->m_view_origin.x, g_tar_config->m_view_origin.x + g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); - node_radar.Values.insert({ "Hostage" + std::to_string(hostn++) + "_y", std::to_string(util::roundf(remap(hostage->m_origin.z, g_tar_config->m_view_origin.y, g_tar_config->m_view_origin.y - g_tar_config->m_render_ortho_scale, 0.0f, 1.0f), 0.01f)) }); + std::ofstream out(filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + ".txt", true).c_str()); + out << "// TAVR - AUTO RADAR. v 2.5.0a\n"; + node_radar.Serialize(out); + out.close(); } - std::ofstream out(filesys->create_output_filepath("resource/overviews/" + g_mapfile_name + ".txt", true).c_str()); - out << "// TAVR - AUTO RADAR. v 2.5.0a\n"; - node_radar.Serialize(out); - out.close(); - IL_EXIT: glfwTerminate(); #ifdef _DEBUG @@ -462,14 +480,10 @@ void render_config(tar_config_layer layer, const std::string& layerName, FBuffer g_vmf_file->DrawWorld(g_shader_gBuffer); g_vmf_file->DrawEntities(g_shader_gBuffer); - g_vmf_file->SetFilters({ g_tar_config->m_visgroup_overlap }, { "func_detail", "prop_static" }); - g_vmf_file->DrawWorld(g_shader_gBuffer, {}, TAR_MIBUFFER_OVERLAP); - g_vmf_file->DrawEntities(g_shader_gBuffer, {}, TAR_MIBUFFER_OVERLAP); - - // Draw cover with cover flag set - g_vmf_file->SetFilters({ g_tar_config->m_visgroup_cover }, { "func_detail", "prop_static" }); - g_vmf_file->DrawWorld(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); - g_vmf_file->DrawEntities(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); + //// Draw cover with cover flag set + //g_vmf_file->SetFilters({ g_tar_config->m_visgroup_cover }, { "func_detail", "prop_static" }); + //g_vmf_file->DrawWorld(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); + //g_vmf_file->DrawEntities(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); GBuffer::Unbind(); @@ -477,10 +491,19 @@ void render_config(tar_config_layer layer, const std::string& layerName, FBuffer glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + g_vmf_file->SetFilters({ g_tar_config->m_visgroup_layout, g_tar_config->m_visgroup_mask }, { "func_detail", "prop_static" }); g_vmf_file->DrawWorld(g_shader_gBuffer); g_vmf_file->DrawEntities(g_shader_gBuffer); + g_vmf_file->SetFilters({ g_tar_config->m_visgroup_cover }, { "func_detail", "prop_static" }); + g_vmf_file->DrawWorld(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); + g_vmf_file->DrawEntities(g_shader_gBuffer, {}, TAR_MIBUFFER_COVER0); + + g_vmf_file->SetFilters({ g_tar_config->m_visgroup_overlap }, { "func_detail", "prop_static" }); + g_vmf_file->DrawWorld(g_shader_gBuffer, {}, TAR_MIBUFFER_OVERLAP); + g_vmf_file->DrawEntities(g_shader_gBuffer, {}, TAR_MIBUFFER_OVERLAP); + GBuffer::Unbind(); #pragma endregion @@ -556,7 +579,7 @@ void render_config(tar_config_layer layer, const std::string& layerName, FBuffer g_gbuffer->BindNormalBufferToTexSlot ( 3 ); g_shader_comp->setInt("gbuffer_normal", 3 ); - g_gbuffer->BindInfoBufferToTexSlot ( 4 ); + g_gbuffer_clean->BindInfoBufferToTexSlot ( 4 ); g_shader_comp->setInt("gbuffer_info", 4 ); g_mask_playspace->BindMaskBufferToTexSlot ( 5 ); @@ -571,7 +594,10 @@ void render_config(tar_config_layer layer, const std::string& layerName, FBuffer g_gbuffer_clean->BindPositionBufferToTexSlot(8); g_shader_comp->setInt("gbuffer_clean_position", 8); - g_gbuffer->BindOriginBufferToTexSlot(11); + g_gbuffer_clean->BindNormalBufferToTexSlot(12); + g_shader_comp->setInt("gbuffer_clean_normal", 12); + + g_gbuffer_clean->BindOriginBufferToTexSlot(11); g_shader_comp->setInt("gbuffer_origin", 11); g_texture_modulate->bindOnSlot(10); @@ -602,7 +628,7 @@ void render_config(tar_config_layer layer, const std::string& layerName, FBuffer g_mesh_screen_quad->Draw(); - render_to_png(g_renderWidth, g_renderHeight, layerName.c_str()); + //render_to_png(g_renderWidth, g_renderHeight, layerName.c_str()); #pragma endregion } @@ -631,9 +657,9 @@ void render_to_png(int x, int y, const char* filepath){ void save_to_dds(int x, int y, const char* filepath, IMG imgmode) { - void* data = malloc(4 * x * y); + void* data = malloc(6 * x * y); - glReadPixels(0, 0, x, y, GL_RGB, GL_UNSIGNED_BYTE, data); + glReadPixels(0, 0, x, y, GL_RGBA, GL_UNSIGNED_BYTE, data); dds_write((uint8_t*)data, filepath, x, y, imgmode); diff --git a/MCDV/sample_stuff/de_tavr_test.vmx b/MCDV/sample_stuff/de_tavr_test.vmx index 787a3cd..5409b5c 100644 --- a/MCDV/sample_stuff/de_tavr_test.vmx +++ b/MCDV/sample_stuff/de_tavr_test.vmx @@ -2,7 +2,7 @@ versioninfo { "editorversion" "400" "editorbuild" "8075" - "mapversion" "379" + "mapversion" "421" "formatversion" "100" "prefab" "0" } @@ -44,13 +44,244 @@ viewsettings world { "id" "1" - "mapversion" "379" + "mapversion" "421" "classname" "worldspawn" "detailmaterial" "detail/detailsprites" "detailvbsp" "detail.vbsp" "maxpropscreenwidth" "-1" "skyname" "sky_dust" solid + { + "id" "3288" + side + { + "id" "1219" + "plane" "(-768 0 128) (-768 128 128) (-384 128 128)" + "material" "TERRI/DEV/BSP" + "uaxis" "[1 0 0 128] 0.25" + "vaxis" "[0 -1 0 64] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1218" + "plane" "(-768 128 112) (-768 0 112) (-384 0 112)" + "material" "TERRI/DEV/BSP" + "uaxis" "[1 0 0 128] 0.25" + "vaxis" "[0 -1 0 64] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1217" + "plane" "(-768 0 112) (-768 128 112) (-768 128 128)" + "material" "TERRI/DEV/BSP" + "uaxis" "[0 1 0 -64] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1216" + "plane" "(-384 128 112) (-384 0 112) (-384 0 128)" + "material" "TERRI/DEV/BSP" + "uaxis" "[0 1 0 -64] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1215" + "plane" "(-768 128 112) (-384 128 112) (-384 128 128)" + "material" "TERRI/DEV/BSP" + "uaxis" "[1 0 0 128] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1214" + "plane" "(-384 0 112) (-768 0 112) (-768 0 128)" + "material" "TERRI/DEV/BSP" + "uaxis" "[1 0 0 128] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + editor + { + "color" "0 175 108" + "visgroupid" "15" + "visgroupshown" "1" + "visgroupautoshown" "1" + } + } + solid + { + "id" "3314" + side + { + "id" "1231" + "plane" "(-144 0 83.2) (-240 0 83.2) (-240 80 83.2)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 0.0146484] 0.25" + "vaxis" "[1 0 0 63.9829] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1230" + "plane" "(-144 80 16) (-240 80 16) (-240 0 16)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 0.0146484] 0.25" + "vaxis" "[1 0 0 63.9829] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1229" + "plane" "(-144 0 16) (-240 0 16) (-240 0 83.2012)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[-1 0 0 -63.9829] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1228" + "plane" "(-240 80 16) (-144 80 16) (-144 80 83.1992)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[-1 0 0 -63.9829] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1227" + "plane" "(-240 0 16) (-240 80 16) (-240 80 83.1992)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 0.0146484] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1226" + "plane" "(-144 80 16) (-144 0 16) (-144 0 83.1992)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 0.0146484] 0.25" + "vaxis" "[0 0 -1 0] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + editor + { + "color" "0 175 108" + "visgroupid" "13" + "visgroupshown" "1" + "visgroupautoshown" "1" + } + } + solid + { + "id" "3315" + side + { + "id" "1243" + "plane" "(128 32 191.999) (32 32 191.999) (32 112 191.999)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 -127.985] 0.25" + "vaxis" "[1 0 0 -0.0170898] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1242" + "plane" "(128 112 124.799) (32 112 124.799) (32 32 124.799)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 -127.985] 0.25" + "vaxis" "[1 0 0 -0.0170898] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1241" + "plane" "(128 32 124.799) (32 32 124.799) (32 32 192)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[-1 0 0 0.0170898] 0.25" + "vaxis" "[0 0 -1 51.1953] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1240" + "plane" "(32 112 124.799) (128 112 124.799) (128 112 191.998)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[-1 0 0 0.0170898] 0.25" + "vaxis" "[0 0 -1 51.1953] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1239" + "plane" "(32 32 124.799) (32 112 124.799) (32 112 191.998)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 -127.985] 0.25" + "vaxis" "[0 0 -1 51.1953] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + side + { + "id" "1238" + "plane" "(128 112 124.799) (128 32 124.799) (128 32 191.998)" + "material" "RYAN_DEV/PURE_ORANGE2" + "uaxis" "[0 1 0 -127.985] 0.25" + "vaxis" "[0 0 -1 51.1953] 0.25" + "rotation" "0" + "lightmapscale" "16" + "smoothing_groups" "0" + } + editor + { + "color" "0 175 108" + "visgroupid" "13" + "visgroupshown" "1" + "visgroupautoshown" "1" + } + } + solid { "id" "2856" side @@ -1574,7 +1805,7 @@ world side { "id" "745" - "plane" "(0 640 16) (0 896 16) (0 896 128)" + "plane" "(0 640 16) (0 896 16) (0 896 224)" "material" "TERRI/DEV/BSP" "uaxis" "[0 1 0 128] 0.25" "vaxis" "[0 0 -1 -384] 0.25" @@ -1585,7 +1816,7 @@ world side { "id" "744" - "plane" "(128 896 16) (128 640 16) (128 896 128)" + "plane" "(128 896 224) (128 896 16) (128 640 16)" "material" "TOOLS/TOOLSNODRAW" "uaxis" "[0 1 0 0] 0.25" "vaxis" "[0 0 -1 0] 0.25" @@ -1596,7 +1827,7 @@ world side { "id" "743" - "plane" "(0 896 16) (128 896 16) (128 896 128)" + "plane" "(0 896 224) (0 896 16) (128 896 16)" "material" "TOOLS/TOOLSNODRAW" "uaxis" "[1 0 0 0] 0.25" "vaxis" "[0 0 -1 0] 0.25" @@ -1607,7 +1838,7 @@ world side { "id" "742" - "plane" "(128 640 16) (0 640 16) (0 896 128)" + "plane" "(128 640 16) (0 640 16) (0 896 224)" "material" "TERRI/DEV/BSP" "uaxis" "[1 0 0 128] 0.25" "vaxis" "[0 -1 0 -384] 0.25" @@ -1629,10 +1860,10 @@ world side { "id" "621" - "plane" "(64 592 64) (-64 592 64) (-64 720 64)" + "plane" "(112 666.51 64) (21.4904 576 64) (-69.0193 666.51 64)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[0 1 0 64.015] 0.25" - "vaxis" "[1 0 0 -127.972] 0.25" + "uaxis" "[-0.707107 0.707107 0 95.6249] 0.25" + "vaxis" "[0.707107 0.707107 0 -25.93] 0.25" "rotation" "0" "lightmapscale" "16" "smoothing_groups" "0" @@ -1640,10 +1871,10 @@ world side { "id" "620" - "plane" "(64 720 16) (-64 720 16) (-64 592 16)" + "plane" "(21.4903 757.019 16) (-69.0193 666.51 16) (21.4904 576 16)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[0 1 0 64.015] 0.25" - "vaxis" "[1 0 0 -127.972] 0.25" + "uaxis" "[-0.707107 0.707107 0 95.6249] 0.25" + "vaxis" "[0.707107 0.707107 0 -25.93] 0.25" "rotation" "0" "lightmapscale" "16" "smoothing_groups" "0" @@ -1651,9 +1882,9 @@ world side { "id" "619" - "plane" "(64 592 16) (-64 592 16) (-64 592 64)" + "plane" "(112 666.51 16) (21.4904 576 16) (21.4904 576 64)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[-1 0 0 127.972] 0.25" + "uaxis" "[-0.707107 -0.707107 0 25.93] 0.25" "vaxis" "[0 0 -1 0] 0.25" "rotation" "0" "lightmapscale" "16" @@ -1662,9 +1893,9 @@ world side { "id" "618" - "plane" "(-64 720 16) (64 720 16) (64 720 64)" + "plane" "(-69.0193 666.51 16) (21.4903 757.019 16) (21.4903 757.019 64)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[-1 0 0 127.972] 0.25" + "uaxis" "[-0.707107 -0.707107 0 25.93] 0.25" "vaxis" "[0 0 -1 0] 0.25" "rotation" "0" "lightmapscale" "16" @@ -1673,9 +1904,9 @@ world side { "id" "617" - "plane" "(-64 592 16) (-64 720 16) (-64 720 64)" + "plane" "(21.4904 576 16) (-69.0193 666.51 16) (-69.0193 666.51 64)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[0 1 0 64.015] 0.25" + "uaxis" "[-0.707107 0.707107 0 95.6249] 0.25" "vaxis" "[0 0 -1 0] 0.25" "rotation" "0" "lightmapscale" "16" @@ -1684,9 +1915,9 @@ world side { "id" "616" - "plane" "(64 720 16) (64 592 16) (64 592 64)" + "plane" "(21.4903 757.019 16) (112 666.51 16) (112 666.51 64)" "material" "RYAN_DEV/PURE_ORANGE2" - "uaxis" "[0 1 0 64.015] 0.25" + "uaxis" "[-0.707107 0.707107 0 95.6249] 0.25" "vaxis" "[0 0 -1 0] 0.25" "rotation" "0" "lightmapscale" "16" @@ -2639,36 +2870,8 @@ entity { "id" "3061" "classname" "tar_color" - "_light" "0 255 0 255" - "origin" "-393 -64 48" - editor - { - "color" "220 30 220" - "visgroupshown" "1" - "visgroupautoshown" "1" - "logicalpos" "[0 0]" - } -} -entity -{ - "id" "3159" - "classname" "tar_color" - "_light" "255 255 0 255" - "origin" "-393 -64 208" - editor - { - "color" "220 30 220" - "visgroupshown" "1" - "visgroupautoshown" "1" - "logicalpos" "[0 0]" - } -} -entity -{ - "id" "3165" - "classname" "tar_color" - "_light" "198 57 149 255" - "origin" "-393 -64 224" + "_light" "77 88 128 255" + "origin" "-384 48 128" editor { "color" "220 30 220" @@ -2679,10 +2882,10 @@ entity } entity { - "id" "3004" + "id" "3191" "classname" "tar_color" - "_light" "255 0 0 255" - "origin" "-393 -64 80" + "_light" "122 80 80 255" + "origin" "-384 -144 16" editor { "color" "220 30 220" @@ -2693,10 +2896,10 @@ entity } entity { - "id" "3026" + "id" "3201" "classname" "tar_color" - "_light" "0 0 255 255" - "origin" "-393 -64 104.5" + "_light" "75 43 79 255" + "origin" "-384 640 -192" editor { "color" "220 30 220" @@ -2735,18 +2938,19 @@ entity { "id" "2809" "classname" "tar_config" - "aoSize" "1000" + "aoSize" "500" "background" "grid.png" "colorScheme" "-2" "customCol0" "104 15 15" "customCol1" "64 166 38" "customCol2" "44 199 199" - "ddsMode" "2" + "ddsMode" "1" "enableAO" "1" "enableOutline" "0" "ObjectiveUseStripes" "1" "outlineWidth" "2" - "ssaam" "1" + "outputMode" "1" + "ssaam" "3" "vgroup_cover" "tar_cover" "vgroup_layout" "tar_layout" "vgroup_negative" "tar_mask" @@ -2754,7 +2958,7 @@ entity "zColAO" "0 0 0 255" "zColBuyzone" "46 211 57 255" "zColCover" "179 179 179 255" - "zColCover2" "85 85 85 170" + "zColCover2" "51 51 51 255" "zColObjective" "0 128 255 255" "zColOutline" "204 204 204 255" "origin" "-352 -144 33" diff --git a/MCDV/shaders/fullscreenbase.fs b/MCDV/shaders/fullscreenbase.fs index dbd0d1e..623d64e 100644 --- a/MCDV/shaders/fullscreenbase.fs +++ b/MCDV/shaders/fullscreenbase.fs @@ -22,6 +22,7 @@ uniform sampler2D gbuffer_position; uniform sampler2D gbuffer_origin; uniform sampler2D gbuffer_clean_position; uniform sampler2D gbuffer_normal; +uniform sampler2D gbuffer_clean_normal; uniform usampler2D gbuffer_info; uniform usampler2D umask_playspace; uniform usampler2D umask_objectives; @@ -231,7 +232,7 @@ void main() final = blend_normal(final, sample_gradient( - lerp(s_position_clean.y, s_position.y, clamp((1 - s_modulate.r) + (float((s_info >> 1) & 0x1U) - m_playspace_clean), 0, 1)) + lerp(s_position_clean.y, s_position.y, clamp((1 - s_modulate.r), 0, 1)) ), m_playspace); vec2 sloc = texture(gbuffer_origin, TexCoords).xy; @@ -244,39 +245,90 @@ void main() //FragColor = vec4(sh, sh, sh, 1); + + //vec4 backColorC = sample_gradient( + // lerp(texture(gbuffer_clean_position, originSample.xy).y, texture(gbuffer_position, originSample.xy).y, clamp((1 - s_modulate.r) + (float((s_info >> 1) & 0x1U) - m_playspace_clean), 0, 1)) + //); + + vec4 backColorC = sample_gradient(texture(gbuffer_position, originSample.xy).y); + + //final = blend_normal( + // final, + // lerp( + // color_cover, + // vec4(lerp(color_cover2.rgb, backColorC.rgb, 1 - color_cover2.a), 1), + // (1 - ((s_position_clean.y - texture(gbuffer_position, originSample.xy).y) / 130))), + // + //float((s_info >> 7) & 0x1U) * m_playspace); + + float htt = clamp((s_position_clean.y - texture(gbuffer_position, originSample.xy).y) / 130, 0, 1); + + //final = vec4(htt, htt, htt, 1); + + final = blend_normal( - final, - lerp(color_cover, color_cover2, - float((s_info >> 7) & 0x1U) * m_playspace * (1 - ((s_position.y - texture(gbuffer_clean_position, originSample.xy).y) / 196))), - float((s_info >> 7) & 0x1U) * m_playspace); + final, + lerp(backColorC, color_cover, htt), + float( (s_info >> 7) & 0x1U ) * m_playspace + ); + + vec4 s_normal = + lerp( + lerp + ( + texture(gbuffer_normal, TexCoords), + texture(gbuffer_clean_normal, TexCoords), + clamp((1 - s_modulate.r) + (1 - float((s_info >> 1) & 0x1U)), 0, 1) + ), + texture(gbuffer_clean_normal, TexCoords), + float((s_info >> 7) & 0x1U) + ); - vec4 s_normal = texture(gbuffer_normal, TexCoords); vec3 randVec = texture(ssaoRotations, TexCoords * noiseScale).rgb; vec3 tangent = normalize(randVec - s_normal.rgb * dot(randVec, s_normal.rgb)); vec3 bitangent = cross(s_normal.rgb, tangent); mat3 TBN = mat3(tangent, bitangent, s_normal.rgb); - hData = s_position.y; + hData = lerp(lerp(s_position_clean.y, s_position.y, clamp((1 - s_modulate.r), 0, 1)), texture(gbuffer_clean_position, TexCoords).y, float( (s_info >> 7) & 0x1U )); float occlusion = 0.0; for(int i = 0; i < 256; i++) { vec3 sample = TBN * samples[i]; - sample = s_position.xyz + sample * ssaoScale; + sample = + lerp + ( + lerp + ( + s_position_clean.xyz, + s_position.xyz, + clamp((1 - s_modulate.r) + (1 - float((s_info >> 1) & 0x1U)), 0, 1) + ), + + s_position_clean.xyz, + + float((s_info >> 7) & 0x1U) + ) + + (sample * ssaoScale); vec4 offset = vec4(sample, 1.0); offset = projection * view * offset; offset.xyz /= offset.w; offset.xyz = offset.xyz * 0.5 + 0.5; - float sDepth = texture(gbuffer_position, offset.xy).y; + float sDepth = lerp + ( + texture(gbuffer_position, offset.xy).y, + texture(gbuffer_clean_position, offset.xy).y, + float((texture(gbuffer_info, offset.xy).r >> 7) & 0x1U) + ); - occlusion += (sDepth >= sample.y + 6 ? 1.0 : 0.0); + occlusion += (sDepth >= sample.y + 3 ? 1.0 : 0.0); } final = blend_normal(final, color_ao, (occlusion / 200) * m_playspace * blend_ao); - + //FragColor = vec4(texture(gbuffer_clean_position, TexCoords).rgb * 0.01, 1); //aoBuffer = occlusion / 200; final = blend_normal(final, color_objective, // Objectives diff --git a/MCDV/shaders/ss_comp_multilayer_blend.fs b/MCDV/shaders/ss_comp_multilayer_blend.fs index d93ce05..852c317 100644 --- a/MCDV/shaders/ss_comp_multilayer_blend.fs +++ b/MCDV/shaders/ss_comp_multilayer_blend.fs @@ -15,7 +15,7 @@ uniform sampler2D gbuffer_height; uniform float layer_target; float saturation = 0.1; -float value = 0.666; +float value = 0.333; float dist = 100; uniform float active; @@ -82,7 +82,7 @@ void main() vec4 s_layer = texture(tex_layer, TexCoords); float s_height = texture(gbuffer_height, TexCoords).r; - float dist_from_target = remap(abs(layer_target - s_height), 0, 200, 0, 1); + float dist_from_target = remap(abs(layer_target - s_height), 0, 160, 0, 1); float dist_blend = 1 - active;//1 - clamp((active) + dist_from_target, 0, 1);//clamp(clamp(dist_from_max + dist_from_min, 0, 1) + ( 1 - active ), 0, 1); @@ -90,6 +90,8 @@ void main() dist_blend -= (1 - dist_from_target); dist_blend = clamp(dist_blend, 0, 1); + + dist_blend = 1 - active; vec3 colHSV = rgb2hsv(s_layer.rgb); colHSV.g *= saturation; diff --git a/MCDV/tar_config.hpp b/MCDV/tar_config.hpp index b7af349..58a95a6 100644 --- a/MCDV/tar_config.hpp +++ b/MCDV/tar_config.hpp @@ -61,6 +61,10 @@ public: int m_outline_width; bool m_outline_stripes_enable; + bool m_write_dds = true; + bool m_write_txt = true; + bool m_write_png = false; + // Color settings glm::vec4 m_color_cover; glm::vec4 m_color_cover2; @@ -128,7 +132,8 @@ public: switch (hash(kv::tryGetStringValue(kvs, "ddsMode", "0").c_str())) { case hash("1"): this->m_dds_img_mode = IMG::MODE_DXT5; break; - case hash("2"): this->m_dds_img_mode = IMG::MODE_RGB888; break; + case hash("3"): case hash("2"): this->m_dds_img_mode = IMG::MODE_RGB888; break; + case hash("4"): this->m_dds_img_mode = IMG::MODE_DXT1_1BA; break; } this->m_sampling_mode = sampling_mode::FXAA; @@ -137,6 +142,33 @@ public: case hash("2"): this->m_sampling_mode = sampling_mode::MSAA16x; break; } + switch (hash(kv::tryGetStringValue(kvs, "outputMode", "0").c_str())) { + case hash("1"): + this->m_write_png = true; + case hash("0"): + this->m_write_dds = true; + this->m_write_txt = true; + break; + + case hash("2"): + this->m_write_png = true; + this->m_write_txt = true; + this->m_write_dds = false; + break; + + case hash("3"): + this->m_write_txt = false; + this->m_write_png = false; + this->m_write_dds = true; + break; + + case hash("4"): + this->m_write_dds = false; + this->m_write_txt = false; + this->m_write_png = true; + break; + } + // Configure camera setup this->m_map_bounds = v->getVisgroupBounds(this->m_visgroup_layout); diff --git a/MCDV/vmf_new.hpp b/MCDV/vmf_new.hpp index bd43e7b..9dd9c26 100644 --- a/MCDV/vmf_new.hpp +++ b/MCDV/vmf_new.hpp @@ -871,7 +871,8 @@ public: shader->setUnsigned("Info", infoFlags); shader->setVec2("origin", glm::vec2(ent.m_origin.x, ent.m_origin.z)); - vmf::s_model_dict[kv::tryGetStringValue(ent.m_keyvalues, "model", "error.mdl")]->Draw(); + if(vmf::s_model_dict.count(kv::tryGetStringValue(ent.m_keyvalues, "model", "error.mdl"))) + vmf::s_model_dict[kv::tryGetStringValue(ent.m_keyvalues, "model", "error.mdl")]->Draw(); } else { model = glm::mat4(); diff --git a/tar_entities/tar_color.png b/tar_entities/tar_color.png new file mode 100644 index 0000000..7f2f49f Binary files /dev/null and b/tar_entities/tar_color.png differ diff --git a/tar_entities/tar_color.psd b/tar_entities/tar_color.psd new file mode 100644 index 0000000..bdb35d3 Binary files /dev/null and b/tar_entities/tar_color.psd differ diff --git a/tar_entities/tar_color.vtf b/tar_entities/tar_color.vtf new file mode 100644 index 0000000..6fca8f1 Binary files /dev/null and b/tar_entities/tar_color.vtf differ