func_detail, compositor shuffle, better kernal filters
authorTerri00 <thrustmediaproductions@gmail.com>
Thu, 14 Mar 2019 16:48:12 +0000 (16:48 +0000)
committerTerri00 <thrustmediaproductions@gmail.com>
Thu, 14 Mar 2019 16:48:12 +0000 (16:48 +0000)
14 files changed:
MCDV/.txt [new file with mode: 0644]
MCDV/_radar.dds [new file with mode: 0644]
MCDV/buyzone-bombtargets.png
MCDV/main.cpp
MCDV/playable-space.png
MCDV/sample_stuff/de_tavr_test.vmx
MCDV/shaders/depth.fs
MCDV/shaders/ss_comp_main.fs
MCDV/shaders/ss_precomp_objectives.fs
MCDV/shaders/ss_precomp_objectives_old.fs [new file with mode: 0644]
MCDV/shaders/ss_precomp_playspace.fs
MCDV/shaders/ss_precomp_playspace_old.fs [new file with mode: 0644]
MCDV/test.png [new file with mode: 0644]
MCDV/vmf.hpp

diff --git a/MCDV/.txt b/MCDV/.txt
new file mode 100644 (file)
index 0000000..142ea73
--- /dev/null
+++ b/MCDV/.txt
@@ -0,0 +1,12 @@
+// TAVR - AUTO RADAR. v 2.0.0
+
+{
+       "CTSpawn_x" "0.470000"
+       "CTSpawn_y" "0.650000"
+       "TSpawn_x" "0.340000"
+       "TSpawn_y" "0.170000"
+       "material" "overviews/"
+       "pos_x" "-2390.324951"
+       "pos_y" "3072.000000"
+       "scale" "4.860000"
+}
diff --git a/MCDV/_radar.dds b/MCDV/_radar.dds
new file mode 100644 (file)
index 0000000..4fa0b93
Binary files /dev/null and b/MCDV/_radar.dds differ
index 03a4cbe0bce522677eecf5b882f62e403efe9f1c..6c2aa16e88de9b7fd9e97516dd11b38946205b85 100644 (file)
Binary files a/MCDV/buyzone-bombtargets.png and b/MCDV/buyzone-bombtargets.png differ
index 8b70900ab1f28e7ac123ab334ae2cdb6bdcb20e5..4fc9aac60f3a3c0295920bdeafbca2ebb68bd796 100644 (file)
@@ -49,22 +49,29 @@ void save_to_dds(int x, int y, const char* filepath) {
 }
 
 /* Command line variables */
+#ifndef _DEBUG
 std::string m_mapfile_path;
 std::string m_game_path;
+#endif
+#ifdef _DEBUG
+std::string m_mapfile_path = "sample_stuff/de_tavr_test";
+std::string m_game_path = "D:/SteamLibrary/steamapps/common/Counter-Strike Global Offensive/csgo";
+#endif
 
 //derived strings
 std::string m_mapfile_name;
 std::string m_overviews_folder;
 std::string m_resources_folder;
 
-bool m_outputMasks;
+bool m_outputMasks = true;
 bool m_onlyOutputMasks;
 
-uint32_t m_renderWidth;
-uint32_t m_renderHeight;
+uint32_t m_renderWidth = 1024;
+uint32_t m_renderHeight = 1024;
 
 /* Main program */
 int app(int argc, const char** argv) {
+#ifndef _DEBUG
        cxxopts::Options options("AutoRadar", "Auto radar");
        options.add_options()
                ("v,version", "Shows the software version")
@@ -77,6 +84,14 @@ int app(int argc, const char** argv) {
                ("w,width", "Render width in pixels (experimental)", cxxopts::value<uint32_t>()->default_value("1024"))
                ("h,height", "Render height in pixels (experimental)", cxxopts::value<uint32_t>()->default_value("1024"))
 
+               // Experimental
+               ("autoModulate", "Enables automatic height modulation between two levels")
+               ("minHeightDiff", "Minumum height difference(units) to modulate between two levels", cxxopts::value<int>()->default_value("128"))
+               
+               // Future
+               ("useVBSP", "Use VBSP.exe to pre-process brush unions automatically")
+               ("useLightmaps", "Use lightmaps generated by vvis in the VBSP. (If this flag is set, Auto Radar must be ran after vvis.exe)")
+
                ("positional", "Positional parameters", cxxopts::value<std::vector<std::string>>());
 
        options.parse_positional("positional");
@@ -98,11 +113,6 @@ int app(int argc, const char** argv) {
        m_mapfile_path = sutil::ReplaceAll(m_mapfile_path, "\\", "/");
        m_game_path = sutil::ReplaceAll(m_game_path, "\\", "/");
 
-       //Derive the ones
-       m_mapfile_name = split(m_mapfile_path, '/').back();
-       m_overviews_folder = m_game_path + "/resource/overviews/";
-       m_resources_folder = m_overviews_folder + m_mapfile_name + ".resources/";
-
        /* Check the rest of the flags */
        m_onlyOutputMasks = result["onlyMasks"].as<bool>();
        m_outputMasks = result["dumpMasks"].as<bool>() || m_onlyOutputMasks;
@@ -111,6 +121,13 @@ int app(int argc, const char** argv) {
        m_renderWidth = result["width"].as<uint32_t>();
        m_renderHeight = result["height"].as<uint32_t>();
 
+#endif
+
+       //Derive the ones
+       m_mapfile_name = split(m_mapfile_path, '/').back();
+       m_overviews_folder = m_game_path + "/resource/overviews/";
+       m_resources_folder = m_overviews_folder + m_mapfile_name + ".resources/";
+
        std::cout << "Launching with options:\n";
        std::cout << "  Render width:    " << m_renderWidth << "\n";
        std::cout << "  Render height:   " << m_renderHeight << "\n";
@@ -197,6 +214,9 @@ int app(int argc, const char** argv) {
                std::cout << "______________________________________________________________\n";
                std::cout << "Shader compilation step failed.\n";
                glfwTerminate();
+#ifdef _DEBUG
+               system("PAUSE");
+#endif
                return 1;
        }
 
@@ -223,8 +243,12 @@ int app(int argc, const char** argv) {
 
        vmf_main.ComputeGLMeshes();
        vmf_main.ComputeDisplacements();
+       
+       std::cout << "Collecting Objects... \n";
        std::vector<vmf::Solid*> tavr_solids = vmf_main.getAllBrushesInVisGroup("tavr_layout");
-       std::vector<vmf::Solid*> tavr_solids_funcbrush = vmf_main.getAllBrushesByClassName("func_brush");
+       std::vector<vmf::Solid*> tavr_solids_negative = vmf_main.getAllBrushesInVisGroup("tavr_negative");
+       std::vector<vmf::Solid*> tavr_entire_brushlist = vmf_main.getAllRenderBrushes();
+       //std::vector<vmf::Solid*> tavr_solids_funcbrush = vmf_main.getAllBrushesByClassName("func_brush");
        std::vector<vmf::Solid*> tavr_buyzones = vmf_main.getAllBrushesByClassName("func_buyzone");
        std::vector<vmf::Solid*> tavr_bombtargets = vmf_main.getAllBrushesByClassName("func_bomb_target");
 
@@ -268,6 +292,8 @@ int app(int argc, const char** argv) {
 #pragma region render_playable_space
        std::cout << "Rendering playable space... ";
 
+       // ======================================================== REGULAR ORDER ========================================================
+
        fb_comp.Bind(); //Bind framebuffer
 
        glClearColor(0.00f, 0.00f, 0.00f, 1.00f);
@@ -283,7 +309,14 @@ int app(int argc, const char** argv) {
 
        shader_depth.setFloat("HEIGHT_MIN", z_render_min);
        shader_depth.setFloat("HEIGHT_MAX", z_render_max);
+       shader_depth.setFloat("write_playable", 0.0f);
 
+       // Render entire map first
+       for (auto && brush : tavr_entire_brushlist) brush->mesh->Draw();
+       glClear(GL_DEPTH_BUFFER_BIT);
+
+       // Render playable area over it
+       shader_depth.setFloat("write_playable", 1.0f);
        for (auto && s_solid : tavr_solids) {
                if(!s_solid->containsDisplacements)
                        s_solid->mesh->Draw();
@@ -296,6 +329,7 @@ int app(int argc, const char** argv) {
                }
        }
 
+       // ======================================================== REVERSE ORDER ========================================================
 
        fb_comp_1.Bind();
 
@@ -310,6 +344,7 @@ int app(int argc, const char** argv) {
 
        shader_depth.setFloat("HEIGHT_MIN", z_render_min);
        shader_depth.setFloat("HEIGHT_MAX", z_render_max);
+       shader_depth.setFloat("write_playable", 0.0f);
 
        for (auto && s_solid : tavr_solids) {
                if (!s_solid->containsDisplacements)
@@ -328,6 +363,8 @@ int app(int argc, const char** argv) {
        glDepthFunc(GL_LESS);
        glDisable(GL_CULL_FACE);
 
+       // ========================================================== PRE-COMP ===========================================================
+
        // Apply diffusion
        fb_tex_playspace.Bind();
 
@@ -338,8 +375,8 @@ int app(int argc, const char** argv) {
 
        shader_precomp_playspace.use();
 
-       shader_precomp_playspace.setFloat("HEIGHT_MIN", z_render_min);
-       shader_precomp_playspace.setFloat("HEIGHT_MAX", z_render_max);
+       //shader_precomp_playspace.setFloat("HEIGHT_MIN", z_render_min);
+       //shader_precomp_playspace.setFloat("HEIGHT_MAX", z_render_max);
 
        fb_comp.BindRTtoTexSlot(0);
        shader_precomp_playspace.setInt("tex_in", 0);
@@ -347,8 +384,8 @@ int app(int argc, const char** argv) {
        fb_comp_1.BindRTtoTexSlot(1);
        shader_precomp_playspace.setInt("tex_in_1", 1);
 
-       tex_height_modulate.bindOnSlot(2);
-       shader_precomp_playspace.setInt("tex_modulate", 2);
+       //tex_height_modulate.bindOnSlot(2);
+       //shader_precomp_playspace.setInt("tex_modulate", 2);
 
        mesh_screen_quad->Draw();
 
@@ -443,6 +480,9 @@ int app(int argc, const char** argv) {
                save_to_dds(1024, 1024, std::string(m_overviews_folder + m_mapfile_name + "_radar.dds").c_str());
        }
 
+       if (m_outputMasks)
+               render_to_png(1024, 1024, "test.png");
+
 #pragma region generate_radar_txt
 
        std::cout << "Generating radar .TXT... ";
@@ -482,6 +522,10 @@ int app(int argc, const char** argv) {
 
        //Exit safely
        glfwTerminate();
+#ifdef _DEBUG
+       system("PAUSE");
+#endif
+
        return 0;
 }
 
index 1e09fb646914ee3796382d4bef2728ba3841d6d3..90dc5f80532f2010c7b38bb9dcec7b369436f5a4 100644 (file)
Binary files a/MCDV/playable-space.png and b/MCDV/playable-space.png differ
index 33dbf003e07af759c2d812b8e7e1613dbf0677d3..ae498c1ec7ffa9a3765849b5201e9e69e9c1f98e 100644 (file)
@@ -2,7 +2,7 @@ versioninfo
 {
        "editorversion" "400"
        "editorbuild" "8075"
-       "mapversion" "32"
+       "mapversion" "36"
        "formatversion" "100"
        "prefab" "0"
 }
@@ -32,7 +32,7 @@ viewsettings
 world
 {
        "id" "1"
-       "mapversion" "32"
+       "mapversion" "36"
        "classname" "worldspawn"
        "detailmaterial" "detail/detailsprites"
        "detailvbsp" "detail.vbsp"
@@ -1045,83 +1045,6 @@ world
                }
        }
        solid
-       {
-               "id" "78"
-               side
-               {
-                       "id" "165"
-                       "plane" "(-768 1024 16) (256 1024 16) (256 128 16)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[1 0 0 0] 0.25"
-                       "vaxis" "[0 -1 0 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               side
-               {
-                       "id" "164"
-                       "plane" "(-768 128 0) (256 128 0) (256 1024 0)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[1 0 0 0] 0.25"
-                       "vaxis" "[0 -1 0 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               side
-               {
-                       "id" "163"
-                       "plane" "(-768 1024 16) (-768 128 16) (-768 128 0)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[0 1 0 0] 0.25"
-                       "vaxis" "[0 0 -1 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               side
-               {
-                       "id" "162"
-                       "plane" "(256 1024 0) (256 128 0) (256 128 16)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[0 1 0 0] 0.25"
-                       "vaxis" "[0 0 -1 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               side
-               {
-                       "id" "161"
-                       "plane" "(256 1024 16) (-768 1024 16) (-768 1024 0)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[1 0 0 0] 0.25"
-                       "vaxis" "[0 0 -1 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               side
-               {
-                       "id" "160"
-                       "plane" "(256 128 0) (-768 128 0) (-768 128 16)"
-                       "material" "DEV/GRAYGRID"
-                       "uaxis" "[1 0 0 0] 0.25"
-                       "vaxis" "[0 0 -1 0] 0.25"
-                       "rotation" "0"
-                       "lightmapscale" "16"
-                       "smoothing_groups" "0"
-               }
-               editor
-               {
-                       "color" "0 145 202"
-                       "visgroupid" "8"
-                       "visgroupshown" "1"
-                       "visgroupautoshown" "1"
-               }
-       }
-       solid
        {
                "id" "79"
                side
@@ -1660,84 +1583,81 @@ world
                        "visgroupautoshown" "1"
                }
        }
-       hidden
+       solid
        {
-               solid
+               "id" "144"
+               side
                {
-                       "id" "144"
-                       side
-                       {
-                               "id" "291"
-                               "plane" "(-768 640 0) (-2048 640 0) (-2048 -512 0)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[-1 0 0 0] 0.25"
-                               "vaxis" "[0 1 0 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       side
-                       {
-                               "id" "290"
-                               "plane" "(-768 -512 0) (-768 -512 64) (-768 640 64)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[0 -1 0 0] 0.25"
-                               "vaxis" "[0 0 -1 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       side
-                       {
-                               "id" "289"
-                               "plane" "(-2048 640 0) (-2048 640 128) (-2048 -512 128)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[0 -1 0 0] 0.25"
-                               "vaxis" "[0 0 -1 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       side
-                       {
-                               "id" "288"
-                               "plane" "(-2048 -512 0) (-2048 -512 128) (-768 -512 64)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[-1 0 0 0] 0.25"
-                               "vaxis" "[0 0 -1 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       side
-                       {
-                               "id" "287"
-                               "plane" "(-768 640 0) (-768 640 64) (-2048 640 128)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[-1 0 0 0] 0.25"
-                               "vaxis" "[0 0 -1 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       side
-                       {
-                               "id" "286"
-                               "plane" "(-768 -512 64) (-2048 -512 128) (-2048 640 128)"
-                               "material" "DEV/GRAYGRID"
-                               "uaxis" "[-1 0 0 0] 0.25"
-                               "vaxis" "[0 1 0 0] 0.25"
-                               "rotation" "0"
-                               "lightmapscale" "16"
-                               "smoothing_groups" "0"
-                       }
-                       editor
-                       {
-                               "color" "0 145 202"
-                               "visgroupid" "9"
-                               "visgroupshown" "0"
-                               "visgroupautoshown" "1"
-                       }
+                       "id" "291"
+                       "plane" "(-768 640 0) (-2048 640 0) (-2048 -512 0)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[-1 0 0 0] 0.25"
+                       "vaxis" "[0 1 0 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "290"
+                       "plane" "(-768 -512 0) (-768 -512 64) (-768 640 64)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[0 -1 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "289"
+                       "plane" "(-2048 640 0) (-2048 640 128) (-2048 -512 128)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[0 -1 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "288"
+                       "plane" "(-2048 -512 0) (-2048 -512 128) (-768 -512 64)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[-1 0 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "287"
+                       "plane" "(-768 640 0) (-768 640 64) (-2048 640 128)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[-1 0 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "286"
+                       "plane" "(-768 -512 64) (-2048 -512 128) (-2048 640 128)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[-1 0 0 0] 0.25"
+                       "vaxis" "[0 1 0 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               editor
+               {
+                       "color" "0 145 202"
+                       "visgroupid" "8"
+                       "visgroupshown" "1"
+                       "visgroupautoshown" "1"
                }
        }
        group
@@ -1752,6 +1672,96 @@ world
        }
 }
 entity
+{
+       "id" "397"
+       "classname" "func_detail"
+       solid
+       {
+               "id" "78"
+               side
+               {
+                       "id" "465"
+                       "plane" "(-768 1024 16) (256 1024 16) (256 128 16)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[1 0 0 0] 0.25"
+                       "vaxis" "[0 -1 0 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "464"
+                       "plane" "(-768 128 0) (256 128 0) (256 1024 0)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[1 0 0 0] 0.25"
+                       "vaxis" "[0 -1 0 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "463"
+                       "plane" "(-768 1024 16) (-768 128 16) (-768 128 0)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[0 1 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "462"
+                       "plane" "(256 1024 0) (256 128 0) (256 128 16)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[0 1 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "461"
+                       "plane" "(256 1024 16) (-768 1024 16) (-768 1024 0)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[1 0 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               side
+               {
+                       "id" "460"
+                       "plane" "(256 128 0) (-768 128 0) (-768 128 16)"
+                       "material" "DEV/GRAYGRID"
+                       "uaxis" "[1 0 0 0] 0.25"
+                       "vaxis" "[0 0 -1 0] 0.25"
+                       "rotation" "0"
+                       "lightmapscale" "16"
+                       "smoothing_groups" "0"
+               }
+               editor
+               {
+                       "color" "0 180 0"
+                       "visgroupshown" "1"
+                       "visgroupautoshown" "1"
+               }
+       }
+       editor
+       {
+               "color" "0 180 0"
+               "visgroupid" "8"
+               "visgroupid" "9"
+               "visgroupshown" "1"
+               "visgroupautoshown" "1"
+               "logicalpos" "[0 0]"
+       }
+}
+entity
 {
        "id" "367"
        "classname" "info_player_terrorist"
index 9d8c20ff7bb1495a4a74b472dff2401beb4ff18c..4ed431024cb0ec7da3d820046877298938300964 100644 (file)
@@ -2,14 +2,13 @@
 out vec4 FragColor;
 
 uniform vec3 color;
-uniform float test;
 
 uniform float HEIGHT_MIN;
 uniform float HEIGHT_MAX;
+uniform float write_playable;
 
 in vec3 FragPos;
 in float Depth;
-in float Alpha;
 
 // Simple remap from-to range.
 float remap(float value, float low1, float high1, float low2, float high2)
@@ -21,5 +20,5 @@ void main()
 {
        float height = pow(remap(FragPos.y, HEIGHT_MIN, HEIGHT_MAX, 0, 1), 2.2);
 
-       FragColor = vec4(1, height, 0, 1);
+       FragColor = vec4(write_playable, height, 0, 1);
 }
\ No newline at end of file
index 75b5348dadc43c10a5ebd9541fde3c4d95f4c9f3..eb29e1f8cd824d53d33c9b3ad763bfb098626ab7 100644 (file)
@@ -24,25 +24,25 @@ uniform vec2 bombsite_b;    // Location of bombsite B       (0-1)
 //    ( Standard generated maps from the engine )
 uniform sampler2D tex_background;      // Background texture
 uniform sampler2D tex_playspace;       // Playspace 
-       // R: Playable space (0 or 1), 
-       // G: Height (0-1 normalized)
-       // B: AO map (mask 0-1)
-       // A: Outline (mask 0-1) (need to subtract the playable space from this)
+       // R: Height (Regular)
+       // G: Height (Reverse rendering order)
+       // **B: Baked Lighting
+       // A: Playable Space (0 or 1)
 
 uniform sampler2D tex_objectives;      // Objectives
        // R: Buzones (0 or 1)
-       // G: Bombsites (0 or 1)
-       // **B: Glow map (mask 0-1)
-       // **A: Outline (mask 0-1)
+       // G: none
+       // B: none
+       // A: Buyzones & Bombsites (mask 0-1)
 
 uniform sampler2D tex_props;           // Props
-       // **R: Props (0 or 1)
-       // **G: Height (0-1 normalized)
-       // **B: Glow map (mask 0-1)
-       // **A: Outline (mask 0-1)
+       // **R: Height (0-1 normalized)
+       // **G: none
+       // **B: none
+       // **A: Props (0 or 1)
 
 uniform sampler2D tex_gradient;                // Gradient input
-       // **RGBA: 256x1 image defining a gradient
+       // RGBA: 256x1 image defining a gradient
 
 uniform sampler2D texture0; // Custom Image input 3 (**RGBA)
 uniform sampler2D texture1; // Custom Image input 4 (**RGBA)
@@ -59,7 +59,7 @@ vec3 lerp(vec3 a, vec3 b, float w)
 
 vec4 blend_normal(vec4 a, vec4 b, float s)
 {
-       return vec4(lerp(a.rgb, b.rgb, b.a * s), b.a + (a.a * s));
+       return vec4(lerp(a.rgb, b.rgb, b.a * s), a.a + (b.a * s));
 }
 
 vec4 blend_add(vec4 a, vec4 b, float s)
@@ -67,11 +67,61 @@ vec4 blend_add(vec4 a, vec4 b, float s)
        return vec4(a.rgb + (b.rgb * s), a.a);
 }
 
+// -------------------------------------- sample helpers --------------------------------------
+
 vec4 sample_gradient(float height)
 {
        return vec4(texture(tex_gradient, vec2(height, 0)));
 }
 
+float get_playspace(vec4 sample_playspace) { return sample_playspace.a; }
+float get_playspace_height(vec4 sample_playspace) { return sample_playspace.a * sample_playspace.r; }
+float get_playspace_inverse_height(vec4 sample_playspace) { return sample_playspace.a * sample_playspace.g; }
+
+float get_height(vec4 sample_playspace) { return sample_playspace.g; }
+float get_baked_light(vec4 sample_playspace) { return sample_playspace.r; }
+
+// -------------------------------------- kernel filters --------------------------------------
+// Given an 0-1 mask, return a 'glow value'
+float kernel_filter_glow(sampler2D sampler, int channelID = 0, int sample_size = 16)
+{
+       vec2 pixel_size = 1.0 / vec2(textureSize(sampler, 0));
+
+       float sT = 0;
+       int sample_double = sample_size * 2;
+
+       // Process kernel
+       for(int x = 0; x <= sample_double; x++){
+               for(int y = 0; y <= sample_double; y++){
+                       sT += texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
+               }
+       }
+
+       sT /= (sample_double * sample_double);
+
+       return sT;
+}
+
+// Given a 0-1 mask, return an outline drawn around that mask
+float kernel_filter_outline(sampler2D sampler, int channelID = 0, int sample_size = 2)
+{
+       vec2 pixel_size = 1.0 / vec2(textureSize(sampler, 0));
+
+       float sT = 0;
+       int sample_double = sample_size * 2;
+       
+       // Process kernel
+       for(int x = 0; x <= sample_double; x++){
+               for(int y = 0; y <= sample_double; y++){
+                       sT += //texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
+                       (sample_size - min(length(vec2(-sample_size + x, -sample_size + y)), sample_size)) * 
+                       texture(sampler, TexCoords + vec2((-sample_size + x) * pixel_size.x, (-sample_size + y) * pixel_size.y))[channelID];
+               }
+       }
+
+       return max(min(sT, 1) - texture(sampler, TexCoords)[channelID], 0);
+}
+
 //                                       SHADER PROGRAM
 // ____________________________________________________________________________________________
 //     ( Write all your shader code & functions here )
@@ -88,12 +138,12 @@ void main()
        vec4 sObjectives = vec4(texture(tex_objectives, TexCoords));
 
        vec4 final = sBackground;
-       final = blend_normal(final, ao_color, sPlayspace.b);                                            // Drop shadow
-       final = blend_normal(final, sample_gradient(sPlayspace.g), sPlayspace.r);       // Playspace
-       final = blend_normal(final, outline_color, sPlayspace.a - sPlayspace.r);        // Outline
+       final = blend_normal(final, ao_color, kernel_filter_glow(tex_playspace, 3, 16));                                                // Drop shadow
+       final = blend_normal(final, sample_gradient(get_playspace_height(sPlayspace)), get_playspace(sPlayspace));      // Playspace
+       final = blend_normal(final, outline_color, kernel_filter_outline(tex_playspace, 3, 2)); // Outline
 
-       final = blend_normal(final, objective_color, sObjectives.r * sObjectives.a);                                    // Objectives
-       final = blend_normal(final, buyzone_color, sObjectives.g * sObjectives.a);                                              // Buyzones
+       //final = blend_normal(final, objective_color, sObjectives.r * sObjectives.a);                                  // Objectives
+       //final = blend_normal(final, buyzone_color, sObjectives.g * sObjectives.a);                                            // Buyzones
        // Return the final output color
        FragColor = final;
 }
\ No newline at end of file
index 6be14a219c56abee6a603e521b61ffdec2b9284f..f279f32dec87817af5908a2962861c276e51291a 100644 (file)
@@ -8,52 +8,12 @@ out vec4 FragColor;
 // Image Inputs _______________________________________________________________________________
 uniform sampler2D tex_in;      // Background texture
 
-//                                       SHADER HELPERS
-// ____________________________________________________________________________________________
-//     ( Simple sample with offset )
-vec2 pixel_size = 1.0 / vec2(textureSize(tex_in, 0));
-vec4 getSample(vec2 offset)
-{
-       return vec4(texture(tex_in, TexCoords + (offset * pixel_size)));
-}
-
 //                                       SHADER PROGRAM
 // ____________________________________________________________________________________________
 //     ( Write all your shader code & functions here )
 
 void main()
 {
-       vec4 sIn = getSample(vec2(0,0));
-
-       //Temp
-       int sampleCount = 64;
-       int outlineWidth = 1;
-
-       vec2 sT = vec2(0, 0);
-
-       // Glow sampler ==========================================================
-       for(int x = 0; x <= sampleCount; x++)
-       {
-               for(int y = 0; y <= sampleCount; y++)
-               {
-                       sT += (vec2(1, 1)-getSample(vec2(-32 + x,-32 + y)).rg) * (1 - ((abs(-32 +x) * abs(-32 +y)) / 512));
-               }
-       }
-
-       // Outline sampler =======================================================
-       vec2 olT = vec2(0, 0);
-       for(int x = 0; x <= outlineWidth * 2; x++)
-       {
-               for(int y = 0; y <= outlineWidth * 2; y++)
-               {
-                       olT += vec2(1, 1) - getSample(vec2(-outlineWidth + x,-outlineWidth + y)).rg;
-               }
-       }
-
-       float global_opacity = 0.075;
-
-       sT /= (sampleCount * sampleCount);
-       sT = vec2(pow(sT.r, 1.5), pow(sT.g, 1.5));
-       sT *= 0.75;
-       FragColor = vec4((sIn.r * olT.r) + (sIn.r * sT.r) + (sIn.r * global_opacity), (sIn.g * olT.g) + (sIn.g * sT.g) + (sIn.g * global_opacity), 0, sIn.r + sIn.g);
+       vec4 sample = vec4(texture(tex_in, TexCoords));
+       FragColor = vec4(sample.r, 0, 0, sample.r + sample.g);
 }
\ No newline at end of file
diff --git a/MCDV/shaders/ss_precomp_objectives_old.fs b/MCDV/shaders/ss_precomp_objectives_old.fs
new file mode 100644 (file)
index 0000000..6be14a2
--- /dev/null
@@ -0,0 +1,59 @@
+#version 330 core
+//                                         OPENGL
+// ____________________________________________________________________________________________
+in vec2 TexCoords;
+out vec4 FragColor;
+
+//                                     SAMPLER UNIFORMS
+// Image Inputs _______________________________________________________________________________
+uniform sampler2D tex_in;      // Background texture
+
+//                                       SHADER HELPERS
+// ____________________________________________________________________________________________
+//     ( Simple sample with offset )
+vec2 pixel_size = 1.0 / vec2(textureSize(tex_in, 0));
+vec4 getSample(vec2 offset)
+{
+       return vec4(texture(tex_in, TexCoords + (offset * pixel_size)));
+}
+
+//                                       SHADER PROGRAM
+// ____________________________________________________________________________________________
+//     ( Write all your shader code & functions here )
+
+void main()
+{
+       vec4 sIn = getSample(vec2(0,0));
+
+       //Temp
+       int sampleCount = 64;
+       int outlineWidth = 1;
+
+       vec2 sT = vec2(0, 0);
+
+       // Glow sampler ==========================================================
+       for(int x = 0; x <= sampleCount; x++)
+       {
+               for(int y = 0; y <= sampleCount; y++)
+               {
+                       sT += (vec2(1, 1)-getSample(vec2(-32 + x,-32 + y)).rg) * (1 - ((abs(-32 +x) * abs(-32 +y)) / 512));
+               }
+       }
+
+       // Outline sampler =======================================================
+       vec2 olT = vec2(0, 0);
+       for(int x = 0; x <= outlineWidth * 2; x++)
+       {
+               for(int y = 0; y <= outlineWidth * 2; y++)
+               {
+                       olT += vec2(1, 1) - getSample(vec2(-outlineWidth + x,-outlineWidth + y)).rg;
+               }
+       }
+
+       float global_opacity = 0.075;
+
+       sT /= (sampleCount * sampleCount);
+       sT = vec2(pow(sT.r, 1.5), pow(sT.g, 1.5));
+       sT *= 0.75;
+       FragColor = vec4((sIn.r * olT.r) + (sIn.r * sT.r) + (sIn.r * global_opacity), (sIn.g * olT.g) + (sIn.g * sT.g) + (sIn.g * global_opacity), 0, sIn.r + sIn.g);
+}
\ No newline at end of file
index 798378af8bf33fb406f34a1ce46e413e9e49369a..22f733862e1a4f39de45547b9d5db6a0550ab00a 100644 (file)
@@ -4,81 +4,18 @@
 in vec2 TexCoords;
 out vec4 FragColor;
 
-
 //                                     SAMPLER UNIFORMS
 // Image Inputs _______________________________________________________________________________
 uniform sampler2D tex_in;      // Background texture
 uniform sampler2D tex_in_1;
-uniform sampler2D tex_modulate;
-
-uniform float HEIGHT_MIN;
-uniform float HEIGHT_MAX;
-
-//                                       SHADER HELPERS
-// ____________________________________________________________________________________________
-//     ( Simple sample with offset )
-vec2 pixel_size = 1.0 / vec2(textureSize(tex_in, 0));
-vec4 getSample(vec2 offset)
-{
-       return vec4(texture(tex_in, TexCoords + (offset * pixel_size)));
-}
-
-// Simple remap from-to range.
-float remap(float value, float low1, float high1, float low2, float high2)
-{
-       return low2 + (value - low1) * (high2 - low2) / (high1 - low1);
-}
 
 //                                       SHADER PROGRAM
 // ____________________________________________________________________________________________
 //     ( Write all your shader code & functions here )
 void main()
 {
-       vec4 sIn = getSample(vec2(0,0));
-       if(sIn.r > 0.0)
-       {
-               float height1 = sIn.g;
-               float height2 = texture(tex_in_1, TexCoords).g;
-               float heightOut = sIn.g;
-
-               if((height1 - height2) > remap(128, HEIGHT_MIN, HEIGHT_MAX, 0, 1)){
-                       if(texture(tex_modulate, TexCoords).r > 0.5){
-                               heightOut = height2;
-                       }
-               }
-
-               FragColor = vec4(sIn.r, heightOut, sIn.g, sIn.a);
-       } 
-       else
-       {
-               //Temp
-               int sampleCount = 32;
-               int outlineWidth = 2;
-
-               // Glow sampler ==========================================================
-               float sT = 0;
-               for(int x = 0; x <= sampleCount; x++)
-               {
-                       for(int y = 0; y <= sampleCount; y++)
-                       {
-                               sT += getSample(vec2(-16 + x,-16 + y)).r;
-                       }
-               }
-
-               //Adjust slightly
-               sT *= 2;
-               sT /= (sampleCount * sampleCount);
-
-               // Outline sampler =======================================================
-               float olT = 0;
-               for(int x = 0; x <= outlineWidth * 2; x++)
-               {
-                       for(int y = 0; y <= outlineWidth * 2; y++)
-                       {
-                               olT += getSample(vec2(-outlineWidth + x,-outlineWidth + y)).r;
-                       }
-               }
+       vec4 sample_a = vec4(texture(tex_in, TexCoords));
+       vec4 sample_b = vec4(texture(tex_in_1, TexCoords));
                
-               FragColor = vec4(sIn.r, sIn.g, sT, olT);
-       }
+       FragColor = vec4(sample_a.g, sample_b.g, 0, sample_a.r);
 }
\ No newline at end of file
diff --git a/MCDV/shaders/ss_precomp_playspace_old.fs b/MCDV/shaders/ss_precomp_playspace_old.fs
new file mode 100644 (file)
index 0000000..798378a
--- /dev/null
@@ -0,0 +1,84 @@
+#version 330 core
+//                                         OPENGL
+// ____________________________________________________________________________________________
+in vec2 TexCoords;
+out vec4 FragColor;
+
+
+//                                     SAMPLER UNIFORMS
+// Image Inputs _______________________________________________________________________________
+uniform sampler2D tex_in;      // Background texture
+uniform sampler2D tex_in_1;
+uniform sampler2D tex_modulate;
+
+uniform float HEIGHT_MIN;
+uniform float HEIGHT_MAX;
+
+//                                       SHADER HELPERS
+// ____________________________________________________________________________________________
+//     ( Simple sample with offset )
+vec2 pixel_size = 1.0 / vec2(textureSize(tex_in, 0));
+vec4 getSample(vec2 offset)
+{
+       return vec4(texture(tex_in, TexCoords + (offset * pixel_size)));
+}
+
+// Simple remap from-to range.
+float remap(float value, float low1, float high1, float low2, float high2)
+{
+       return low2 + (value - low1) * (high2 - low2) / (high1 - low1);
+}
+
+//                                       SHADER PROGRAM
+// ____________________________________________________________________________________________
+//     ( Write all your shader code & functions here )
+void main()
+{
+       vec4 sIn = getSample(vec2(0,0));
+       if(sIn.r > 0.0)
+       {
+               float height1 = sIn.g;
+               float height2 = texture(tex_in_1, TexCoords).g;
+               float heightOut = sIn.g;
+
+               if((height1 - height2) > remap(128, HEIGHT_MIN, HEIGHT_MAX, 0, 1)){
+                       if(texture(tex_modulate, TexCoords).r > 0.5){
+                               heightOut = height2;
+                       }
+               }
+
+               FragColor = vec4(sIn.r, heightOut, sIn.g, sIn.a);
+       } 
+       else
+       {
+               //Temp
+               int sampleCount = 32;
+               int outlineWidth = 2;
+
+               // Glow sampler ==========================================================
+               float sT = 0;
+               for(int x = 0; x <= sampleCount; x++)
+               {
+                       for(int y = 0; y <= sampleCount; y++)
+                       {
+                               sT += getSample(vec2(-16 + x,-16 + y)).r;
+                       }
+               }
+
+               //Adjust slightly
+               sT *= 2;
+               sT /= (sampleCount * sampleCount);
+
+               // Outline sampler =======================================================
+               float olT = 0;
+               for(int x = 0; x <= outlineWidth * 2; x++)
+               {
+                       for(int y = 0; y <= outlineWidth * 2; y++)
+                       {
+                               olT += getSample(vec2(-outlineWidth + x,-outlineWidth + y)).r;
+                       }
+               }
+               
+               FragColor = vec4(sIn.r, sIn.g, sT, olT);
+       }
+}
\ No newline at end of file
diff --git a/MCDV/test.png b/MCDV/test.png
new file mode 100644 (file)
index 0000000..bc9540e
Binary files /dev/null and b/MCDV/test.png differ
index 19267ea6b6cf67314fe65cdeffae0b1a4c994f15..6584f7978727f206fa84546b3286c47bb3452e3a 100644 (file)
@@ -303,7 +303,7 @@ namespace vmf {
                        std::cout << "\n";
 
 #pragma endregion Solids
-
+#pragma region Entities
                        std::cout << "Processing entites\n";
 
                        //Process entities list
@@ -358,7 +358,7 @@ namespace vmf {
                                                        solid.faces.push_back(side);
                                                }
 
-                                               kv::DataBlock* editorValues = cBlock.GetFirstByName("editor");
+                                               kv::DataBlock* editorValues = block.GetFirstByName("editor");
 
                                                //Gather up the visgroups
                                                int viscount = -1;
@@ -403,6 +403,7 @@ namespace vmf {
 
                                this->entities.push_back(ent);
                        }
+#pragma endregion
 
                        std::cout << "Processing visgroups\n";
 
@@ -454,6 +455,26 @@ namespace vmf {
                        return list;
                }
 
+               std::vector<Solid*> getAllRenderBrushes() {
+                       std::vector<Solid*> list;
+                       for (auto && s : this->solids)
+                               list.push_back(&s);
+
+                       for (auto && ent : this->entities) {
+                               if (ent.classname == "func_detail" || ent.classname == "func_brush") {
+                                       for (auto && s : ent.internal_solids) {
+                                               list.push_back(&s);
+                                       }
+                               }
+                       }
+                       
+                       return list;
+               }
+
+               std::vector<Solid*> getAllBrushesByClassNameAppend(std::string classname) {
+
+               }
+
                std::vector<Solid*> getAllBrushesByClassName(std::string classname) {
                        std::vector<Solid*> list;
                        for (auto && ent : this->entities) {