--- /dev/null
+#include <stdint.h>
+#include <string>
+
+#include "util.h"
+#include "interpolation.h"
+
+struct Color255 {
+ uint8_t r = 0;
+ uint8_t g = 0;
+ uint8_t b = 0;
+ uint8_t a = 255;
+
+ Color255() {
+
+ }
+
+ Color255(std::string src) {
+ std::vector<std::string> strings;
+ strings = split(src);
+
+ if (strings.size() >= 1) r = ::atoi(strings[0].c_str());
+ if (strings.size() >= 2) g = ::atoi(strings[1].c_str());
+ if (strings.size() >= 3) b = ::atoi(strings[2].c_str());
+ if (strings.size() >= 4) a = ::atoi(strings[3].c_str());
+ }
+};
+
+class GradientTexture : public Texture{
+public:
+ Color255 c0;
+ Color255 c1;
+ Color255 c2;
+
+ //unsigned int texture_id;
+
+ GradientTexture(Color255 _c0, Color255 _c1, Color255 _c2) {
+ this->c0 = _c0; this->c1 = _c1; this->c2 = _c2;
+
+ glGenTextures(1, &this->texture_id);
+
+ unsigned char* data = (unsigned char*)malloc(256*4);
+
+ // Do texture generation
+ for (int i = 0; i < 256; i++) {
+ Color255* a = &this->c0;
+ Color255* b = &this->c1;
+
+ if (i >= 128) { a = b; b = &this->c2; }
+
+ data[i * 4 + 0] = lerpT(a->r, b->r, (float)(i % 128) / 128.0f);
+ data[i * 4 + 1] = lerpT(a->g, b->g, (float)(i % 128) / 128.0f);
+ data[i * 4 + 2] = lerpT(a->b, b->b, (float)(i % 128) / 128.0f);
+ data[i * 4 + 3] = lerpT(a->a, b->a, (float)(i % 128) / 128.0f);
+ }
+
+ glBindTexture(GL_TEXTURE_2D, this->texture_id);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ free(data);
+ }
+
+ /*void bindOnSlot(int slot = 0) {
+ glActiveTexture(GL_TEXTURE0 + slot);
+ glBindTexture(GL_TEXTURE_2D, this->texture_id);
+ }*/
+};
\ No newline at end of file
<ClInclude Include="fuzzy_select.h" />
<ClInclude Include="gamelump.hpp" />
<ClInclude Include="globals.h" />
+ <ClInclude Include="GradientMap.hpp" />
<ClInclude Include="interpolation.h" />
<ClInclude Include="generic.hpp" />
<ClInclude Include="lumps_geometry.hpp" />
<ClInclude Include="globals.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="GradientMap.hpp">
+ <Filter>OpenGL\engine</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
public:
unsigned int texture_id;
Texture(std::string filepath, bool clamp = false);
+ Texture() {};
void bind();
void bindOnSlot(int slot);
#pragma once
-#define entry_point_testing
\ No newline at end of file
+//#define entry_point_testing
\ No newline at end of file
return (a * (1.0f - f)) + (b * f);
}
+template<typename T>
+static T lerpT(T a, T b, float f) {
+ return (T)((float)a * (1.0f - f)) + ((float)b * f);
+}
+
static glm::vec3 lerp(glm::vec3 a, glm::vec3 b, float f) {
return glm::vec3(lerpf(a.x, b.x, f),
lerpf(a.y, b.y, f),
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include "dds.hpp"
+#include "GradientMap.hpp"
/* Grabs the currently bound framebuffer and saves it to a .png */
void render_to_png(int x, int y, const char* filepath){
bool m_comp_ao_enable;
#endif
+//tar_config overrides
uint32_t m_renderWidth = 1024;
uint32_t m_renderHeight = 1024;
+bool tar_cfg_enableAO = true;
+int tar_cfg_aoSzie = 16;
+
+bool tar_cfg_enableShadows = false;
+
+bool tar_cfg_enableOutline = false;
+int tar_cfg_outlineSize = 2;
+
+Texture* tar_cfg_gradientMap;
+
/* Main program */
int app(int argc, const char** argv) {
#ifndef _DEBUG
std::cout << "Loading textures... ";
Texture tex_background = Texture("textures/grid.png");
- Texture tex_gradient = Texture("textures/gradients/gradientmap_6.png", true);
+ //Texture tex_gradient = Texture("textures/gradients/gradientmap_6.png", true);
Texture tex_height_modulate = Texture("textures/modulate.png");
+
+ //GradientTexture gtex_gradient = GradientTexture(std::string("32 68 136 255"), std::string("149 0 0 255"), std::string("178 113 65"));
std::cout << "done!\n\n";
vmf_main.ComputeGLMeshes();
vmf_main.ComputeDisplacements();
-
+
+ // TAR entities
+ std::vector<vmf::Entity*> tavr_ent_tar_config = vmf_main.findEntitiesByClassName("tar_config");
+
+ if (tavr_ent_tar_config.size() > 1) {
+ std::cout << "More than 1 tar config found! Currently unsupported... Using last.\n";
+ }
+
+ vmf::Entity* tar_config = NULL;
+ if (tavr_ent_tar_config.size() > 0) {
+ tar_config = tavr_ent_tar_config.back();
+
+ // Color scheme
+ std::string schemeNum = kv::tryGetStringValue(tar_config->keyValues, "colorScheme", "0");
+ if (schemeNum == "7") { // Custom color scheme
+ tar_cfg_gradientMap = new GradientTexture(
+ kv::tryGetStringValue(tar_config->keyValues, "customCol0", "0 0 0 255"),
+ kv::tryGetStringValue(tar_config->keyValues, "customCol1", "128 128 128 255"),
+ kv::tryGetStringValue(tar_config->keyValues, "customCol2", "255 255 255 255"));
+ } else {
+ tar_cfg_gradientMap = new Texture("textures/gradients/gradientmap_" + schemeNum + ".png", true);
+ }
+
+ // Ambient occlusion
+ tar_cfg_enableAO = (kv::tryGetStringValue(tar_config->keyValues, "enableAO", "1") == "1");
+ tar_cfg_aoSzie = kv::tryGetValue(tar_config->keyValues, "aoSize", 16);
+
+ // Outline
+ tar_cfg_enableOutline = (kv::tryGetStringValue(tar_config->keyValues, "enableOutline", "0") == "1");
+ tar_cfg_outlineSize = kv::tryGetValue(tar_config->keyValues, "outlineWidth", 2);
+
+ // Shadows
+ tar_cfg_enableShadows = (kv::tryGetStringValue(tar_config->keyValues, "enableShadows", "0") == "1");
+ }
+ else {
+ tar_cfg_gradientMap = new Texture("textures/gradients/gradientmap_6.png", true);
+ }
+
std::cout << "Collecting Objects... \n";
- std::vector<vmf::Solid*> tavr_solids = vmf_main.getAllBrushesInVisGroup("tavr_layout");
- std::vector<vmf::Solid*> tavr_solids_negative = vmf_main.getAllBrushesInVisGroup("tavr_negative");
+ std::vector<vmf::Solid*> tavr_solids = vmf_main.getAllBrushesInVisGroup(tar_config == NULL? "tar_layout" : kv::tryGetStringValue(tar_config->keyValues, "vgroup_layout", "tar_layout"));
+ std::vector<vmf::Solid*> tavr_solids_negative = vmf_main.getAllBrushesInVisGroup(tar_config == NULL? "tar_mask" : kv::tryGetStringValue(tar_config->keyValues, "vgroup_negative", "tar_mask"));
std::vector<vmf::Solid*> tavr_entire_brushlist = vmf_main.getAllRenderBrushes();
- std::vector<vmf::Solid*> tavr_cover = vmf_main.getAllBrushesInVisGroup("tavr_cover"); for (auto && v : tavr_cover) v->temp_mark = true;
+ std::vector<vmf::Solid*> tavr_cover = vmf_main.getAllBrushesInVisGroup(tar_config == NULL ? "tar_cover" : kv::tryGetStringValue(tar_config->keyValues, "vgroup_cover", "tar_cover"));
+ for (auto && v : tavr_cover) { v->temp_mark = true; tavr_solids.push_back(v); }
//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");
- std::vector<vmf::Entity*> tavr_ent_tavr_height_min = vmf_main.findEntitiesByClassName("tavr_height_min");
- std::vector<vmf::Entity*> tavr_ent_tavr_height_max = vmf_main.findEntitiesByClassName("tavr_height_max");
+ std::vector<vmf::Entity*> tavr_ent_tavr_height_min = vmf_main.findEntitiesByClassName("tar_min");
+ std::vector<vmf::Entity*> tavr_ent_tavr_height_max = vmf_main.findEntitiesByClassName("tar_max");
std::cout << "done!\n";
shader_comp_main.setVec3("bounds_SEL", glm::vec3(x_bounds_max, y_bounds_min, z_render_min));
/* Render flags */
- shader_comp_main.setInt("cmdl_shadows_enable", m_comp_shadows_enable ? 1 : 0);
- shader_comp_main.setInt("cmdl_ao_enable", m_comp_ao_enable ? 1 : 0);
+ shader_comp_main.setInt("cmdl_shadows_enable", tar_cfg_enableShadows ? 1 : 0);
+ shader_comp_main.setInt("cmdl_ao_enable", tar_cfg_enableAO ? 1 : 0);
+ shader_comp_main.setInt("cmdl_ao_size", tar_cfg_aoSzie);
+ shader_comp_main.setInt("cmdl_outline_enable", tar_cfg_enableOutline);
+ shader_comp_main.setInt("cmdl_outline_size", tar_cfg_outlineSize);
/* Bind texture samplers */
tex_background.bindOnSlot(0);
fb_tex_objectives.BindRTtoTexSlot(2);
shader_comp_main.setInt("tex_objectives", 2);
- tex_gradient.bindOnSlot(4);
+ tar_cfg_gradientMap->bindOnSlot(4);
shader_comp_main.setInt("tex_gradient", 4);
mesh_screen_quad->Draw();
{
"editorversion" "400"
"editorbuild" "8075"
- "mapversion" "54"
+ "mapversion" "91"
"formatversion" "100"
"prefab" "0"
}
"visgroupid" "13"
"color" "223 124 205"
}
- visgroup
- {
- "name" "tavr_cover"
- "visgroupid" "14"
- "color" "198 223 188"
- }
}
viewsettings
{
world
{
"id" "1"
- "mapversion" "54"
+ "mapversion" "91"
"classname" "worldspawn"
"detailmaterial" "detail/detailsprites"
"detailvbsp" "detail.vbsp"
}
}
solid
- {
- "id" "416"
- side
- {
- "id" "478"
- "plane" "(-616 352 464) (-616 416 464) (-528 416 464)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -128] 0.25"
- "vaxis" "[0 -1 0 64] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "479"
- "plane" "(-616 416 0) (-616 352 0) (-528 352 0)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -128] 0.25"
- "vaxis" "[0 -1 0 64] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "480"
- "plane" "(-616 352 0) (-616 416 0) (-616 416 464)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[0 1 0 448] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "481"
- "plane" "(-528 416 0) (-528 352 0) (-528 352 464)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[0 1 0 448] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "482"
- "plane" "(-616 416 0) (-528 416 0) (-528 416 464)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -128] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "483"
- "plane" "(-528 352 0) (-616 352 0) (-616 352 464)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -128] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- editor
- {
- "color" "0 249 138"
- "visgroupid" "8"
- "visgroupid" "14"
- "visgroupshown" "1"
- "visgroupautoshown" "1"
- }
- }
- solid
- {
- "id" "431"
- side
- {
- "id" "495"
- "plane" "(-896 1080 424) (-808 1080 424) (-808 696 424)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -32] 0.25"
- "vaxis" "[0 -1 0 1440] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "494"
- "plane" "(-896 696 0) (-808 696 0) (-808 1080 0)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -32] 0.25"
- "vaxis" "[0 -1 0 1440] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "493"
- "plane" "(-896 1080 424) (-896 696 424) (-896 696 0)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[0 1 0 96] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "492"
- "plane" "(-808 1080 0) (-808 696 0) (-808 696 424)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[0 1 0 96] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "491"
- "plane" "(-808 1080 424) (-896 1080 424) (-896 1080 0)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -32] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- side
- {
- "id" "490"
- "plane" "(-808 696 0) (-896 696 0) (-896 696 424)"
- "material" "AR_DIZZY/DIZZY_INSULATION_BACK_COLOR"
- "uaxis" "[1 0 0 -32] 0.25"
- "vaxis" "[0 0 -1 0] 0.25"
- "rotation" "0"
- "lightmapscale" "16"
- "smoothing_groups" "0"
- }
- editor
- {
- "color" "0 249 138"
- "visgroupid" "8"
- "visgroupshown" "1"
- "visgroupautoshown" "1"
- }
- }
- solid
{
"id" "346"
side
{
"id" "484"
"classname" "tar_config"
- "aoSize" "16"
- "customCol0" "39 56 79"
- "customCol1" "77 74 72"
- "customCol2" "178 113 65"
+ "aoSize" "10"
+ "colorScheme" "1"
+ "customCol0" "32 68 136"
+ "customCol1" "149 0 0"
+ "customCol2" "179 217 26"
+ "enableAO" "1"
+ "enableOutline" "0"
"enableShadows" "1"
- "origin" "112.86 3.28465 33"
+ "outlineWidth" "4"
+ "vgroup_cover" "tavr_cover"
+ "vgroup_layout" "tavr_layout"
+ "vgroup_negative" "tavr_negative"
+ "origin" "96 80 32"
editor
{
"color" "220 30 220"
{
"editorversion" "400"
"editorbuild" "8075"
- "mapversion" "740"
+ "mapversion" "742"
"formatversion" "100"
"prefab" "0"
}
world
{
"id" "1"
- "mapversion" "740"
+ "mapversion" "742"
"classname" "worldspawn"
"detailmaterial" "detail/detailsprites"
"detailvbsp" "detail.vbsp"
}
}
entity
+{
+ "id" "293287"
+ "classname" "tar_config"
+ "aoSize" "16"
+ "customCol0" "39 56 79"
+ "customCol1" "77 74 72"
+ "customCol2" "178 113 65"
+ "enableAO" "1"
+ "origin" "-448 -353.209 32"
+ editor
+ {
+ "color" "220 30 220"
+ "visgroupshown" "1"
+ "visgroupautoshown" "1"
+ "logicalpos" "[0 500]"
+ }
+}
+entity
{
"id" "289962"
"classname" "tavr_height_max"
uniform vec2 bombsite_b; // **Location of bombsite B (UV Screenspace)
uniform int cmdl_shadows_enable; // Commandline switch --ao
+
uniform int cmdl_ao_enable; // Commandline switch --shadows
+uniform int cmdl_ao_size;
+
+uniform int cmdl_outline_enable;
+uniform int cmdl_outline_size;
// SAMPLER UNIFORMS
// Image Inputs _______________________________________________________________________________
final = blend_normal(final, cover_color, sPlayspace.b); // Cover
if(cmdl_shadows_enable == 1) final = blend_normal(final, vec4(0,0,0,1), trace_shadow(tex_playspace) * 0.2); // Shadows
- if(cmdl_ao_enable == 1) final = blend_normal(final, vec4(0,0,0,1), kernel_ao_basic(tex_playspace, 0, 8) * 0.9); // AO
+ if(cmdl_ao_enable == 1) final = blend_normal(final, vec4(0,0,0,1), kernel_ao_basic(tex_playspace, 0, cmdl_ao_size) * 0.9); // AO
- final = blend_normal(final, outline_color, kernel_filter_outline(tex_playspace, 3, 2)); // Outline
+ if(cmdl_outline_enable == 1) final = blend_normal(final, outline_color, kernel_filter_outline(tex_playspace, 3, cmdl_outline_size)); // Outline
final = blend_normal(final, objective_color, // Objectives
(kernel_filter_glow(tex_objectives, 0, 16, 1) * sObjectives.r) +
-@PointClass base(Targetname) iconsprite("tar/editor/tar_config.vmt") = tar_config :
+@PointClass iconsprite("tar/editor/tar_config.vmt") = tar_config :
"Configuration entity for Terri's Auto Radar"
[
// HB Color
7: "Custom Scheme"
]
- customCol0(color255) : "Custom low level color" : "39 56 79"
- customCol1(color255) : "Custom middle level color" : "77 74 72"
- customCol2(color255) : "Custom high level color" : "178 113 65"
+ customCol0(color255) : "Custom low level color" : "39 56 79" : "What the color of the radar should be at the lowest points of the map"
+ customCol1(color255) : "Custom middle level color" : "77 74 72" : "What the color of the radar should be in the middle of the map"
+ customCol2(color255) : "Custom high level color" : "178 113 65" : "What the color of the radar should be at the heighest points of the map"
// Ambient occlusion
- enableAO(choices) : "Ambient Occlusion" : 0 =
+ enableAO(choices) : "Ambient Occlusion" : 1 =
[
- 0: "Enabled"
- 1: "Disabled"
+ 0: "Disabled"
+ 1: "Enabled"
]
- aoSize(float) : "Ambient Occlusion Size" : "16"
+ aoSize(float) : "Ambient Occlusion Size" : "8" : "How far should ambient occlusion sample (use values between 2 and 128)"
// Shadows
- enableAO(choices) : "Shadows" : 1 =
+ enableShadows(choices) : "Shadows" : 0 =
[
- 0: "Enabled"
- 1: "Disabled"
+ 0: "Disabled"
+ 1: "Enabled"
]
+
+ // Outline
+
+ enableOutline(choices) : "Outline" : 0 =
+ [
+ 0: "Disabled"
+ 1: "Enabled"
+ ]
+
+ outlineWidth(float) : "Outline width" : "2" : "How big should the outline be"
+
+ // Visgroup specifiers
+ vgroup_layout(string) : "Visgroup: Layout" : "tar_layout" : "Name of the visgroup that specifies the layout of the map"
+ vgroup_negative(string) : "Visgroup: Mask" : "tar_mask" : "Name of the visgroup that specifies subtractive brushes of the maps layout (use on walls)"
+ vgroup_cover(string) : "Visgroup: Cover" : "tar_cover" : "Name of the visgroup that specifies the cover of the map. Chuck all yr crates in here"
+]
+
+@PointClass iconsprite("tar/editor/tar_min.vmt") = tar_min :
+ "Overrides the minimum height of the map"
+[
+
+]
+
+@PointClass iconsprite("tar/editor/tar_max.vmt") = tar_max :
+ "Overrides the maximum height of the map"
+[
+
]
\ No newline at end of file
--- /dev/null
+"Sprite"
+{
+ "$spriteorientation" "vp_parallel"
+ "$spriteorigin" "[ 0.50 0.50 ]"
+ "$basetexture" "tar/editor/tar_max"
+ "$no_fullbright" 1
+}
\ No newline at end of file
--- /dev/null
+"Sprite"
+{
+ "$spriteorientation" "vp_parallel"
+ "$spriteorigin" "[ 0.50 0.50 ]"
+ "$basetexture" "tar/editor/tar_min"
+ "$no_fullbright" 1
+}
\ No newline at end of file