Jump to content

Dreikblack

Members
  • Posts

    323
  • Joined

  • Last visited

Everything posted by Dreikblack

  1. If you mean tetrahedron i need it to be transparent with ~25% alpha. Other brushes are not transparent. btw i'm using unlit material, idk if there is a better ways to achieve this visual result (except bug part). 3 lines are not wireframe but 3 models.
  2. btw is that culling effect when brushes partly disappear behind another one? But should not be due transparency of the brush in this case. For clarification blue outlines and yellow tetrahedron are brushes. Yellow lines are models. This happens with some camera positions and with another ones all looks fine.
  3. widget->SetColor(1, 0, 0, 1, WIDGETCOLOR_FOREGROUND);
  4. Edit button just for having 2 buttons in a menu: add shared_ptr<Panel> contextMenu; to ListView.h In ListView.cpp update Initialize method: bool ListView::Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, shared_ptr<ListViewData> header, int columnCount) { bool isInit = Widget::Initialize("", x, y, width, height, parent, 0); itemSize = iVec2(width, getItemHeight()); ListView::columnCount = columnCount; initBlockCount += (columnCount * 2); ListView::header = header; contextMenu = CreatePanel(0, 0, 100, 40, gui->root); contextMenu->Hide(); auto editButton = CreateButton("Edit", 0, 0, 100, 20, contextMenu);//just for an example, no function auto removeButton = CreateButton("Remove", 0, 20, 100, 20, contextMenu); ListenEvent(EVENT_WIDGETACTION, removeButton, RemoveCallback, Self()->As<ListView>()); return isInit; } and MouseDown method: void ListView::MouseDown(const MouseButton button, const int x, const int y) { contextMenu->Hide(); if (x >= 0 and y >= getItemHeight() and x < size.x and y < size.y) { int itemId = y / getItemHeight() - 1; if (itemId >= 0 and itemId < items.size()) { selectedItemId = itemId; Redraw(); if (button == MOUSE_LEFT) { if (pickItemListener) { pickItemListener(Event(EVENT_WIDGETACTION, Self(), selectedItemId)); } } else if (button == MOUSE_RIGHT) { contextMenu->Show(); contextMenu->SetShape(iVec2(x, y), contextMenu->GetSize()); } } } } Also add this function to same class: bool RemoveCallback(const Event& ev, shared_ptr<Object> extra) { auto listView = extra->As<ListView>(); listView->removeSelectedItem(); listView->contextMenu->Hide(); return true; }
  5. I may try to make something like that for UAK a bit later.
  6. Done! ListViewData.cpp: #pragma once #include <UltraEngine.h> using namespace UltraEngine; class ListViewData { protected: ListViewData() {} public: static std::shared_ptr<ListViewData> create() { struct Struct : public ListViewData {}; auto instance = std::make_shared<Struct>(); return instance; } static std::shared_ptr<ListViewData> create(vector<WString> fields) { struct Struct : public ListViewData {}; auto instance = std::make_shared<Struct>(); instance->fields = fields; return instance; } vector<WString> fields; bool operator==(const ListViewData& other) const { if (fields.size() != other.fields.size()) return false; for (int i = 0; i < fields.size(); i++) { if (fields[i] != other.fields[i]) { return false; } } return true; } }; ListView.h #pragma once #include <UltraEngine.h> #include "ListViewData.cpp" using namespace UltraEngine; class ListView : public Widget { protected: ListView(); virtual bool Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, shared_ptr<ListViewData> header, int columnCount); iVec2 itemSize = iVec2(100, 20); //Called each time the widget is redrawn virtual void Draw(const int x, const int y, const int width, const int height); //Called when the mouse button is pressed virtual void MouseDown(const MouseButton button, const int x, const int y); //Called when the mouse moves if this widget has the focus virtual void MouseMove(const int x, const int y); std::function<bool(Event)> pickItemListener; int initBlockCount = 4; int selectedItemId = -1; int highlightItemId = -1; int columnCount = 1; int textAlignment = TEXT_CENTER | TEXT_MIDDLE; vector <shared_ptr<ListViewData>> items; shared_ptr<ListViewData> header; public: static std::shared_ptr<ListView> create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, shared_ptr<ListViewData> header, int columnCount = 1); virtual void Show(); int getItemHeight(); void setListener(std::function<bool(Event)> listener); void addItem(shared_ptr<ListViewData> item); void addItems(vector<shared_ptr<ListViewData>> items); void selectItem(shared_ptr<ListViewData> item); void removeSelectedItem(); void clearItems(); vector <shared_ptr<ListViewData>> getItems(); shared_ptr<ListViewData> getSelectedItem(); int getItemCount(); int getHeight(); void resize(); }; ListView.cpp: #include "UltraEngine.h" #include "ListView.h" ListView::ListView() { blocks.resize(initBlockCount);//background, border, highlight background for selected item, highlight under cursor textAlignment = TEXT_MIDDLE; } std::shared_ptr<ListView> ListView::create(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, shared_ptr<ListViewData> header, int columnCount) { struct Struct : public ListView {}; auto instance = std::make_shared<Struct>(); instance->Initialize(x, y, width, height, parent, header, columnCount); return instance; } bool ListView::Initialize(const int x, const int y, const int width, const int height, shared_ptr<Widget> parent, shared_ptr<ListViewData> header, int columnCount) { bool isInit = Widget::Initialize("", x, y, width, height, parent, 0); itemSize = iVec2(width, getItemHeight()); ListView::columnCount = columnCount; initBlockCount += (columnCount * 2); ListView::header = header; return isInit; } int ListView::getItemHeight() { return Round(float(GetInterface()->GetFontHeight(font, fontscale, fontweight))); } void ListView::Draw(const int x, const int y, const int width, const int height) { for (auto& block : blocks) { block.hidden = true; } //Background blocks[0].color = color[WIDGETCOLOR_SUNKEN]; blocks[0].wireframe = false; blocks[0].position = iVec2(0); blocks[0].size = size; blocks[0].hidden = false; //Border blocks[1].hidden = false; blocks[1].color = color[WIDGETCOLOR_BORDER]; blocks[1].wireframe = true; blocks[1].position = iVec2(0); blocks[1].size = size; blocks[1].radius = 0; //Highlight for selected if (selectedItemId >= 0) { blocks[2].color = color[WIDGETCOLOR_SUNKEN] * 0.6f; blocks[2].wireframe = false; blocks[2].position = iVec2(0, itemSize.height * (selectedItemId + 1)); blocks[2].size = itemSize; blocks[2].hidden = false; } //Highlight under cursor if (highlightItemId >= 0 && highlightItemId != selectedItemId) { blocks[3].color = color[WIDGETCOLOR_SUNKEN] * 0.85f; blocks[3].wireframe = false; blocks[3].position = iVec2(0, itemSize.height * (highlightItemId + 1)); blocks[3].size = itemSize; blocks[3].hidden = false; } int fieldWidth = itemSize.width / columnCount; //headers for (int column = 0; column < columnCount; column++) { blocks[4 + column].hidden = false; blocks[4 + column].position = iVec2(fieldWidth * column, 0); blocks[4 + column].size = iVec2(fieldWidth, itemSize.height); blocks[4 + column].SetText(header->fields[column]); blocks[4 + column].textalignment = textAlignment; blocks[4 + column].color = 1; blocks[4 + column + columnCount].hidden = false; blocks[4 + column + columnCount].position = iVec2(fieldWidth * column, 0); blocks[4 + column + columnCount].size = iVec2(fieldWidth, itemSize.height); blocks[4 + column + columnCount].wireframe = true; blocks[4 + column + columnCount].color = Vec4(0.6f, 0.6f, 0.6f, 1); } // items int blockSize = initBlockCount + items.size(); for (int column = 0; column < columnCount; column++) { int extraFiledI = items.size() * column; auto iterItem = items.begin(); for (int i = initBlockCount; i < blockSize; i++) { blocks[i + extraFiledI].hidden = false; blocks[i + extraFiledI].position = iVec2(fieldWidth * column, itemSize.height * (i - initBlockCount + 1)); blocks[i + extraFiledI].size = iVec2(fieldWidth, itemSize.height); blocks[i + extraFiledI].SetText(iterItem->get()->fields[column]); blocks[i + extraFiledI].textalignment = textAlignment; blocks[i + extraFiledI].color = 1; iterItem++; } for (int i = initBlockCount; i < blockSize; i++) { blocks[items.size() * columnCount + i + extraFiledI].hidden = false; blocks[items.size() * columnCount + i + extraFiledI].position = iVec2(fieldWidth * column, itemSize.height * (i - initBlockCount + 1)); blocks[items.size() * columnCount + i + extraFiledI].size = iVec2(fieldWidth, itemSize.height); blocks[items.size() * columnCount + i + extraFiledI].wireframe = true; blocks[items.size() * columnCount + i + extraFiledI].color = color[WIDGETCOLOR_BORDER]; } } } void ListView::MouseDown(const MouseButton button, const int x, const int y) { if (button == MOUSE_LEFT) { if (x >= 0 and y >= getItemHeight() and x < size.x and y < size.y) { int itemId = y / getItemHeight() - 1; if (itemId >= 0 and itemId < items.size()) { selectedItemId = itemId; Redraw(); if (pickItemListener) { pickItemListener(Event(EVENT_WIDGETACTION, Self(), selectedItemId)); } } } } } void ListView::MouseMove(const int x, const int y) { int oldValue = highlightItemId; if (x >= 0 and y >= getItemHeight() and x < size.x and y < size.y) { int itemId = y / getItemHeight() - 1; if (itemId >= 0 and itemId < items.size()) { highlightItemId = itemId; } else { highlightItemId = -1; } } else { highlightItemId = -1; } if (oldValue != highlightItemId) { Redraw(); } } void ListView::Show() { highlightItemId = -1; } void ListView::addItem(shared_ptr<ListViewData> item) { items.push_back(item); resize(); Redraw(); } void ListView::addItems(vector<shared_ptr<ListViewData>> newItems) { items.insert(items.end(), newItems.begin(), newItems.end()); resize(); Redraw(); } void ListView::selectItem(shared_ptr<ListViewData> item) { int i = 0; for (shared_ptr<ListViewData>& currentItem : items) { if (currentItem == item) { selectedItemId = i; break; } i++; } } void ListView::removeSelectedItem() { if (selectedItemId == -1) return; items.erase(items.begin() + selectedItemId); //for some reason without readding items with just erase + Redraw() some fields has visual glitches auto newItems = items; clearItems(); addItems(newItems); } void ListView::clearItems() { selectedItemId = -1; highlightItemId = -1; items.clear(); blocks.resize(initBlockCount); Redraw(); } vector<shared_ptr<ListViewData>> ListView::getItems() { return items; } shared_ptr<ListViewData> ListView::getSelectedItem() { if (selectedItemId >= 0 && selectedItemId < getItemCount()) { return items[selectedItemId]; } return nullptr; } int ListView::getItemCount() { return items.size(); } int ListView::getHeight() { return GetSize().height; } void ListView::resize() { blocks.resize(initBlockCount + items.size() * 2 * columnCount); } void ListView::setListener(std::function<bool(Event)> listener) { pickItemListener = listener; } main.cpp: #include "UltraEngine.h" #include "ListView.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CENTER); //Create User Interface auto ui = CreateInterface(window); //Create widget auto sz = ui->root->GetSize(); auto listView = ListView::create(10, 10, 600, 300, ui->root, ListViewData::create({ WString("header0 "), WString("header1") }), 2); for (int i = 0; i < 2; i++) { listView->addItem(ListViewData::create({ WString("filed0 ") + WString(i), WString("filed1 ") + WString(i) })); } auto textField0 = CreateTextField(10, 320, 100, 20, ui->root); textField0->SetText("filed0"); auto textField1 = CreateTextField(110, 320, 100, 20, ui->root); textField1->SetText("filed1"); auto addBtn = CreateButton("Add", 10, 340, 100, 20, ui->root); auto removeBtn = CreateButton("Remove", 110, 340, 100, 20, ui->root); listView->setListener( [textField0, textField1, listView](Event event) { auto data = listView->getSelectedItem(); textField0->SetText(data->fields[0]); textField0->Redraw(); textField1->SetText(data->fields[1]); textField1->Redraw(); return true; }); while (true) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WIDGETACTION: if (ev.source == addBtn) { listView->addItem(ListViewData::create({ WString(textField0->GetText()), WString(textField1->GetText()) })); } if (ev.source == removeBtn) { listView->removeSelectedItem(); } break; case EVENT_QUIT: case EVENT_WINDOWCLOSE: return 0; break; default: break; } } return 0; }
  7. Tried newer version from here - https://github.com/UltraEngine/ultraengine.github.io/raw/main/files/UltraClient.exe and it worked . Found in a patch notes. Probably main link should be updated? - https://ultraengine.github.io/files/UltraClient.exe
  8. Moved to the forum since apparently it's harder to soilve than i thought, I can login after first client start and after that i see only this pic for few sces before it's closes: Tried: - Run as Admin - Compatobilty mode - Clean reinstall at different disc - Using configs from old PC where it's still works with connection (Windows 10) - Disabling Anti-Virus and adding an exception Config folder has only user.dat and WebCache with my pfp. Everything else (Ultra App Kit client, few games and programs) for now seems to working on this fresh W11 setup (drivers updated, Vulkan SDK and ms redistributable visual c++ installed)
  9. For some reason it was not working in one of components but in another one it worked
  10. I know how to do it in .c and .cpp classes with forward declaration but it does not work for component .hpp classes. I have one component having a second component member and i need a first component member for a second component.
  11. #include "UltraEngine.h" #include "Components/Mover.hpp" using namespace UltraEngine; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> menuWold; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Widget> btn; shared_ptr<Scene> scene; void initGui() { auto default_font = LoadFont("Fonts\\arial.ttf"); ui = CreateInterface(menuWold, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); uiCamera = CreateCamera(menuWold, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); btn = CreateButton("Delete", 0, 0, 100, 20, ui->root); //Create scenery auto box = CreateBox(menuWold); box->AddComponent<Mover>(); scene->AddEntity(box); } int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 1000, 1000, displays[0], WINDOW_DEFAULT); //Create a world menuWold = CreateWorld(); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create light auto light = CreateBoxLight(menuWold); light->SetRange(-10, 10); light->SetRotation(15, 15, 0); light->SetColor(2); //Create camera auto camera = CreateCamera(menuWold); camera->SetClearColor(0.125); camera->SetPosition(0, 0, -3); camera->SetFov(70); scene = CreateScene(); initGui(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == btn && ev.id == EVENT_WIDGETACTION) { scene->entities.clear(); } ui->ProcessEvent(ev); } menuWold->Update(); menuWold->Render(framebuffer); } return 0; }
  12. Similar issue with icons: #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto button = CreateButton("Button", 10, 10, 120, 30, ui->root); auto icon = LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/23cbb91bbaa1f22d6f3eb20cfa54a747d3062c33/Assets/Icons/help.svg"); button->SetIcon(icon); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { auto ev = WaitEvent(); if (ev.source == button && ev.id == EVENT_WIDGETACTION) { button->SetIcon(LoadIcon("https://raw.githubusercontent.com/UltraEngine/Documentation/23cbb91bbaa1f22d6f3eb20cfa54a747d3062c33/Assets/Icons/new.svg")); } ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; }
  13. Replaced tile outlines with brushed. Better perfomance and i think it's looks better. But even one camera outline still degrade perfomance significantly and i wonder how to do proper downsampling for outline. I don't know what am i doing wrong in Outline.json for that: { "postEffect": { "buffers": [ { "size": [ 0.25, 0.25 ] } ], "subpasses": [ { "samplers": [ "DEPTH", "PREVPASS" ], "shader": { "float32": { "fragment": "Shaders/Outline.frag.spv" } } } ] } }
  14. What exactly? My whole UI made of custom widgets of my own. Basic ones mostly same as default but having listeners that attach when i create them, plus some few things as scaling from parameter, localization, fix for vertical text offset in 3D UI etc. For settings i have a singleton manager that reads parameters from a json when it's first called before creating main menu window to define sizes and fullscreen mode. If something was changed in settings menu after hitting OK button a settings manager updates parameter members and settings config file, and a window and UI are recreates with new parameters if something that requires it was changed. For localization i have another manager that reads a text file of current language and keep it in a strings map.
  15. I remade it in Ultra + main menu with settings.
  16. Ok, thanks. I will try something else instead of outlines for tiles then.
  17. I have a new problem with this implementation- can't see outline of first object if it's above another one. It's crucial for cases when selected (and outlined) unit stays on outlined tiles (which shows where can unit go to) (also i used to outline avaiable tile under cursor with another color ad can't see it now as well) outlineBox2->SetPosition(0.5f, 0.5f, 0); box2->SetPosition(0.5f, 0.5f, 0);
  18. Damn, it was correct .frag this time - i just had few mistakes in a code. #include "UltraEngine.h" #include "Components/Mover.hpp" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, displays[0]->GetSize().width, displays[0]->GetSize().height, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_FULLSCREEN); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(1, 0, 0); auto outlineBox = CreateBox(world); outlineBox->SetColor(0, 1, 0); auto material = CreateMaterial(); auto unlitShader = LoadShaderFamily("Shaders/Unlit.json"); material->SetShaderFamily(unlitShader); outlineBox->SetMaterial(material); //Create a box2 auto box2 = CreateBox(world); box2->SetColor(1, 0, 0); auto outlineBox2 = CreateBox(world); outlineBox2->SetColor(0, 0, 1); auto material2 = CreateMaterial(); auto unlitShader2 = LoadShaderFamily("Shaders/Unlit.json"); material2->SetShaderFamily(unlitShader); outlineBox2->SetMaterial(material); outlineBox2->SetPosition(2, 0, 0); box2->SetPosition(2, 0, 0); //Entity component system auto component = box->AddComponent<Mover>(); component->rotationspeed.y = 45; auto outlineComponent = outlineBox->AddComponent<Mover>(); outlineComponent->rotationspeed.y = 45; auto component2 = box2->AddComponent<Mover>(); component2->rotationspeed.y = 45; auto outlineComponent2 = outlineBox2->AddComponent<Mover>(); outlineComponent2->rotationspeed.y = 45; //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Render to texture outlineBox->SetRenderLayers(2); outlineBox2->SetRenderLayers(2); auto cam2 = CreateCamera(world); cam2->SetClearColor(0, 0, 0, 0); cam2->SetRenderLayers(2); cam2->SetFov(camera->GetFov()); cam2->SetMatrix(camera->matrix); cam2->AddPostEffect(LoadPostEffect("Shaders/PostEffects/Outline.json")); auto sz = framebuffer->GetSize(); auto texbuffer = CreateTextureBuffer(sz.x, sz.y); cam2->SetRenderTarget(texbuffer); ////Display overlay auto sprite = CreateSprite(world, sz.x, sz.y); sprite->SetRenderLayers(4); auto mtl = CreateMaterial(); sprite->SetMaterial(mtl); mtl->SetTransparent(true); mtl->SetTexture(texbuffer->GetColorAttachment()); auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); cam3->SetClearMode(CLEAR_DEPTH); cam3->SetRenderLayers(4); cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; }
  19. This works in 2D UI but in 3D widget became not interactive but visible. Maybe where is another way to delete widgets in 3D UI? #include "UltraEngine.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); auto default_font = LoadFont("Fonts\\arial.ttf"); auto ui = CreateInterface(world, default_font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.0f, 0.0f, 0.0f, 0.0f); auto ui_camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); ui_camera->SetPosition((float)framebuffer->GetSize().x * 0.5f, (float)framebuffer->GetSize().y * 0.5f, 0); ui_camera->SetRenderLayers(2); ui_camera->SetClearMode(CLEAR_DEPTH); auto button = CreateButton("Button", 10, 10, 120, 30, ui->root); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { while (PeekEvent()) { const Event ev = WaitEvent(); if (ev.source == button && ev.id == EVENT_WIDGETACTION) { button->SetParent(NULL); } ui->ProcessEvent(ev); } world->Update(); world->Render(framebuffer); } return 0; }
  20. Oh wait, wav, not waw, so it was a typo after all
  21. I chose for an example a sound with simple name and path just to make sure it has not typo Will make water tiles but later.
  22. No problem with models but LoadSound returns null (and works for sounds outside an archive). In the asset editor sounds can be loaded. #include "UltraEngine.h" #include "Components/CameraControls.hpp" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); world->SetAmbientLight(0); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Load FreeImage plugin auto plg = LoadPlugin("Plugins/FITextureLoader"); auto quakeLoaderPlugin = LoadPlugin("Plugins/QuakeLoader"); //Load model WString path = AppDir(); auto pak = LoadPackage(path + "/PAK0.PAK"); ChangeDir(path); auto model = LoadModel(world, "progs/quaddama.mdl"); model->Turn(0, 180, 0, true); auto soundPath = WString("sound/misc/water2.waw"); auto sound = LoadSound(soundPath); sound->Play(); //Environment maps auto specmap = LoadTexture("https://github.com/UltraEngine/Assets/raw/main/Materials/Environment/footprint_court/specular.dds"); auto diffmap = LoadTexture("https://github.com/UltraEngine/Assets/raw/main/Materials/Environment/footprint_court/diffuse.dds"); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0, 0, 1); camera->SetPosition(model->GetBounds().center); camera->Move(0, 0, -0.3); camera->SetRange(0.01, 100); camera->SetFov(70); camera->AddPostEffect(LoadPostEffect("Shaders/PostEffects/FXAA.json")); //Create light auto light = CreateBoxLight(world); light->SetRange(-10, 10); light->SetArea(15, 15); light->SetRotation(45, 35, 0); light->SetColor(1.2); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  23. Still no outline with main.cpp above: { "postEffect": { "subpasses": [ { "samplers": [ "DEPTH", "PREVPASS"], "shader": { "float32": { "fragment": "Shaders/Outline.frag.spv" } } } ] } } #version 450 #extension GL_GOOGLE_include_directive : enable #extension GL_ARB_separate_shader_objects : enable #extension GL_EXT_multiview : enable #include "../Base/PushConstants.glsl" #include "../Base/CameraInfo.glsl" #include "../Base/TextureArrays.glsl" #include "../Utilities/Dither.glsl" layout(location = 0) in vec2 texCoords; layout(location = 0) out vec4 outColor; void main() { outColor = texture(texture2DSampler[PostEffectTexture1], texCoords.xy); outColor.a = 0.0f; float depth = texture(texture2DSampler[PostEffectTexture0], texCoords.xy).r; vec4 c; bool sel; //Handle selected objects if (depth < 1.0f) { const int m = 3; vec2 pixelsize = 1.0f / BufferSize; for (int x = -m; x <= m; ++x) { for (int y = -m; y <= m; ++y) { if (x == 0 && y == 0) continue; float neighbor = texture(texture2DSampler[PostEffectTexture0], texCoords.xy + pixelsize * vec2(x, y)).r; if (neighbor == 1.0f) { outColor = texture(texture2DSampler[PostEffectTexture1], texCoords.xy); return; } } } } }
  24. I just don't know how to get this color in .frag. Trying this but nothing happens: #version 450 #extension GL_GOOGLE_include_directive : enable #extension GL_ARB_separate_shader_objects : enable #extension GL_EXT_multiview : enable #include "../Base/PushConstants.glsl" #include "../Base/CameraInfo.glsl" #include "../Base/TextureArrays.glsl" #include "../Utilities/Dither.glsl" layout(location = 0) in vec2 texCoords; layout(location = 0) out vec4 outColor; const vec4 SelectionColor = vec4(1,1,1,1); void main() { outColor = SelectionColor; outColor.a = 0.0f; float depth = texture(texture2DSampler[PostEffectTexture0], texCoords.xy).r; vec4 c; bool sel; //Handle selected objects if (depth < 1.0f) { const int m = 3; vec2 pixelsize = 1.0f / BufferSize; for (int x = -m; x <= m; ++x) { for (int y = -m; y <= m; ++y) { if (x == 0 && y == 0) continue; float neighbor = texture(texture2DSampler[PostEffectTexture0], texCoords.xy + pixelsize * vec2(x, y)).r; if (neighbor == 1.0f) { outColor = texture(texture2DSampler[PostEffectTexture0], texCoords.xy); return; } } } } } #include "UltraEngine.h" #include "Components/Mover.hpp" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the displays auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, displays[0]->GetSize().width, displays[0]->GetSize().height, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_FULLSCREEN); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 0, -3); //Create a light auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); //Create a box auto box = CreateBox(world); box->SetColor(0.5f, 0.5f, 0); auto outlineBox = CreateBox(world); outlineBox->SetColor(0, 0, 1); auto material = CreateMaterial(); auto unlitShader = LoadShaderFamily("Shaders/Unlit.json"); material->SetShaderFamily(unlitShader); outlineBox->SetMaterial(material); //Entity component system auto component = box->AddComponent<Mover>(); component->rotationspeed.y = 45; auto component2 = outlineBox->AddComponent<Mover>(); component2->rotationspeed.y = 45; //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Render to texture outlineBox->SetRenderLayers(1 + 2); auto cam2 = CreateCamera(world); cam2->SetClearColor(0, 0, 0, 0); cam2->SetRenderLayers(2); cam2->SetFov(camera->GetFov()); cam2->SetMatrix(camera->matrix); cam2->AddPostEffect(LoadPostEffect("Shaders/PostEffects/Outline.json")); auto sz = framebuffer->GetSize(); auto texbuffer = CreateTextureBuffer(sz.x, sz.y); cam2->SetRenderTarget(texbuffer); ////Display overlay auto sprite = CreateSprite(world, sz.x, sz.y); // sprite->SetColor(0, 1, 1, 1); sprite->SetRenderLayers(4); auto mtl = CreateMaterial(); sprite->SetMaterial(mtl); mtl->SetTransparent(true); mtl->SetTexture(texbuffer->GetColorAttachment()); auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); cam3->SetClearMode(CLEAR_DEPTH); cam3->SetRenderLayers(4); cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); //------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------ //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer, false); } return 0; }
×
×
  • Create New...