Jump to content

Dreikblack

Members
  • Posts

    516
  • Joined

  • Last visited

Everything posted by Dreikblack

  1. But it will be visible for main camera as well because second camera render target to sprite that visible in final render so skybox will be visible in a result at all, not just for second camera.
  2. How it can be behind other objects if it should be in front of the camera? Thats what i do for my intended objects and this camera does SetRenderTarget so everything is visible in this layer in final render
  3. How it can be done if this camera render to sprite everything that it can see?
  4. Or user name uses non-latin symbols
  5. I have error "vector subscript out of range" now with SetUniform (Steam, beta branch)
  6. Now it's too dark For comparison without sprite and fog: #include "UltraEngine.h" #include "ComponentSystem.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); //Set environment maps const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets"; auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); auto sz = framebuffer->GetSize(); int MAIN_LAYER = 1, OUTPUT_LAYER = 2, EXTRA_LAYER = 4; auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); auto backBox = CreateBox(world, 5); backBox->SetPosition(0, 0, 7); backBox->SetColor(0, 1, 0, 1); auto betweenBox = CreateBox(world); betweenBox->SetRenderLayers(EXTRA_LAYER); betweenBox->SetColor(1, 0, 0, 1); auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam"); auto boxMat = CreateMaterial(); boxMat->SetShaderFamily(unlitShader); betweenBox->SetMaterial(boxMat); auto betweenBox2 = CreateBox(world); betweenBox2->SetPosition(0.5, 0.5, 0); betweenBox2->SetRenderLayers(EXTRA_LAYER); betweenBox2->SetColor(1, 0, 0, 1); betweenBox2->SetMaterial(boxMat); auto frontBox = CreateBox(world, 1); frontBox->SetPosition(-0.5, 0, -0.5); frontBox->SetColor(1, 1, 0, 1); auto mainCameraInput = CreateCamera(world); mainCameraInput->SetPosition(0, 0, -3); mainCameraInput->SetRenderLayers(MAIN_LAYER); auto mainTextureBuffer = CreateTextureBuffer(sz.x, sz.y); mainCameraInput->SetRenderTarget(mainTextureBuffer); auto mainSprite = CreateSprite(world, sz.x, sz.y); mainSprite->SetRenderLayers(OUTPUT_LAYER); auto mainMaterial = CreateMaterial(); mainMaterial->SetShaderFamily(unlitShader); mainMaterial->SetTexture(mainTextureBuffer->GetColorAttachment()); mainSprite->SetMaterial(mainMaterial); auto mainCameraOutput = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); mainCameraOutput->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); mainCameraOutput->SetRenderLayers(OUTPUT_LAYER); mainCameraOutput->SetLighting(false); mainCameraOutput->SetClearMode(CLEAR_DEPTH); //red transporent boxes render part auto extraCameraInput = CreateCamera(world); extraCameraInput->SetPosition(0, 0, -3); extraCameraInput->SetRenderLayers(EXTRA_LAYER); extraCameraInput->SetMatrix(mainCameraInput->matrix); extraCameraInput->SetClearMode(CLEAR_COLOR); extraCameraInput->SetLighting(false); extraCameraInput->SetFogColor(0, 0, 0, 1); extraCameraInput->SetFogAngle(90, 91); extraCameraInput->SetFog(true); auto range = extraCameraInput->GetRange().y; extraCameraInput->SetFogRange(range * 0.98, range * 0.99); auto extraTextureBuffer = CreateTextureBuffer(sz.x, sz.y); extraTextureBuffer->SetDepthAttachment(mainTextureBuffer->GetDepthAttachment()); extraCameraInput->SetRenderTarget(extraTextureBuffer); auto extraSprite = CreateSprite(world, sz.x, sz.y); extraSprite->SetPosition(0, 0, -0.00001); extraSprite->SetRenderLayers(OUTPUT_LAYER); extraSprite->SetShadows(false); auto extraMaterial = CreateMaterial(); extraMaterial->SetShaderFamily(unlitShader); extraMaterial->SetTransparent(true); extraMaterial->SetTexture(extraTextureBuffer->GetColorAttachment()); extraMaterial->SetColor(1, 1, 1, 0.5); extraSprite->SetMaterial(extraMaterial); extraSprite->SetHidden(false); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  7. New problem with skybox: Added just: const WString remotepath = "https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets"; auto specmap = LoadTexture(remotepath + "/Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture(remotepath + "/Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); How to disable this effect for display sprite or camera?
  8. Final working example: #include "UltraEngine.h" #include "ComponentSystem.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 sz = framebuffer->GetSize(); int MAIN_LAYER = 1, OUTPUT_LAYER = 2, EXTRA_LAYER = 4, EXTRA_OUTPUT_LAYER = 8; auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); auto backBox = CreateBox(world, 5); backBox->SetPosition(0, 0, 7); backBox->SetColor(0, 1, 0, 1); auto betweenBox = CreateBox(world); betweenBox->SetRenderLayers(EXTRA_LAYER); betweenBox->SetColor(1, 0, 0, 1); auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam"); auto boxMat = CreateMaterial(); boxMat->SetShaderFamily(unlitShader); betweenBox->SetMaterial(boxMat); auto betweenBox2 = CreateBox(world); betweenBox2->SetPosition(0.5, 0.5, 0); betweenBox2->SetRenderLayers(EXTRA_LAYER); betweenBox2->SetColor(1, 0, 0, 1); betweenBox2->SetMaterial(boxMat); auto frontBox = CreateBox(world, 1); frontBox->SetPosition(-0.5, 0, -0.5); frontBox->SetColor(1, 1, 0, 1); auto mainCameraInput = CreateCamera(world); mainCameraInput->SetPosition(0, 0, -3); mainCameraInput->SetRenderLayers(MAIN_LAYER); auto mainTextureBuffer = CreateTextureBuffer(sz.x, sz.y); mainCameraInput->SetRenderTarget(mainTextureBuffer); auto mainSprite = CreateSprite(world, sz.x, sz.y); mainSprite->SetRenderLayers(OUTPUT_LAYER); auto mainMaterial = CreateMaterial(); mainMaterial->SetShaderFamily(unlitShader); mainSprite->SetMaterial(mainMaterial); mainMaterial->SetTexture(mainTextureBuffer->GetColorAttachment()); auto mainCameraOutput = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); mainCameraOutput->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); mainCameraOutput->SetRenderLayers(OUTPUT_LAYER); mainCameraOutput->SetLighting(false); mainCameraOutput->SetClearMode(CLEAR_DEPTH); //red transporent boxes render part auto extraCameraInput = CreateCamera(world); extraCameraInput->SetPosition(0, 0, -3); extraCameraInput->SetRenderLayers(EXTRA_LAYER); extraCameraInput->SetMatrix(mainCameraInput->matrix); extraCameraInput->SetClearMode(CLEAR_COLOR); extraCameraInput->SetLighting(false); auto extraTextureBuffer = CreateTextureBuffer(sz.x, sz.y); extraTextureBuffer->SetDepthAttachment(mainTextureBuffer->GetDepthAttachment()); extraCameraInput->SetRenderTarget(extraTextureBuffer); auto extraSprite = CreateSprite(world, sz.x, sz.y); extraSprite->SetPosition(0, 0, -0.00001); extraSprite->SetRenderLayers(OUTPUT_LAYER); auto extraMaterial = CreateMaterial(); extraMaterial->SetShaderFamily(unlitShader); extraSprite->SetMaterial(extraMaterial); extraMaterial->SetTransparent(true); extraMaterial->SetTexture(extraTextureBuffer->GetColorAttachment()); extraMaterial->SetColor(1, 1, 1, 0.5); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  9. Yes! But why when camera rendering to a texture buffer it's so dark?
  10. Same result but no lighting now for unknown reason: #include "UltraEngine.h" #include "ComponentSystem.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 sz = framebuffer->GetSize(); int MAIN_LAYER = 1, OUTPUT_LAYER = 2, EXTRA_LAYER = 4, EXTRA_OUTPUT_LAYER = 8; auto light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); auto backBox = CreateBox(world, 5); backBox->SetPosition(0, 0, 7); backBox->SetColor(0, 1, 0, 1); auto betweenBox = CreateBox(world); betweenBox->SetRenderLayers(EXTRA_LAYER); betweenBox->SetColor(1, 0, 0, 1); auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam"); auto boxMat = CreateMaterial(); boxMat->SetShaderFamily(unlitShader); betweenBox->SetMaterial(boxMat); auto frontBox = CreateBox(world, 1); frontBox->SetPosition(-0.5, 0, -0.5); frontBox->SetColor(1, 1, 0, 1); auto mainCameraInput = CreateCamera(world); mainCameraInput->SetPosition(0, 0, -3); mainCameraInput->SetRenderLayers(MAIN_LAYER); auto mainTextureBuffer = CreateTextureBuffer(sz.x, sz.y); mainCameraInput->SetRenderTarget(mainTextureBuffer); auto mainSprite = CreateSprite(world, sz.x, sz.y); mainSprite->SetRenderLayers(OUTPUT_LAYER); auto mainMaterial = CreateMaterial(); mainSprite->SetMaterial(mainMaterial); mainMaterial->SetTexture(mainTextureBuffer->GetColorAttachment()); auto mainCameraOutput = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); mainCameraOutput->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); mainCameraOutput->SetRenderLayers(OUTPUT_LAYER); mainCameraOutput->SetLighting(true); //red transporent box render part auto extraCameraInput = CreateCamera(world); extraCameraInput->SetPosition(0, 0, -3); extraCameraInput->SetRenderLayers(EXTRA_LAYER); extraCameraInput->SetMatrix(mainCameraInput->matrix); extraCameraInput->SetLighting(false); auto extraTextureBuffer = CreateTextureBuffer(sz.x, sz.y); extraCameraInput->SetRenderTarget(extraTextureBuffer); auto extraSprite = CreateSprite(world, sz.x, sz.y); extraSprite->SetRenderLayers(EXTRA_OUTPUT_LAYER); auto extraMaterial = CreateMaterial(); extraSprite->SetMaterial(extraMaterial); extraMaterial->SetTransparent(true); extraMaterial->SetTexture(extraTextureBuffer->GetColorAttachment()); extraMaterial->SetColor(1, 1, 1, 0.5); auto extraCameraOutput = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); extraCameraOutput->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); extraCameraOutput->SetRenderLayers(EXTRA_OUTPUT_LAYER); extraCameraOutput->SetClearMode(CLEAR_DEPTH); extraTextureBuffer->SetDepthAttachment(mainTextureBuffer->GetDepthAttachment()); extraCameraOutput->SetOrder(2); extraCameraOutput->SetLighting(false); //extraCameraOutput->SetHidden(true); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  11. Yes, with setOrder(2) nothing changes, with cam3->SetOrder(-1); red box invisible at all
  12. How should be but with red box behind yellow box Result with SetClearMode(CLEAR_COLOR), white fog color and black clear color #include "UltraEngine.h" #include "ComponentSystem.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 light = CreateBoxLight(world); light->SetRotation(35, 45, 0); light->SetRange(-10, 10); Vec4 color(0, 1, 0, 1); //Create a box auto box = CreateBox(world); //Render to texture box->SetRenderLayers(2); box->SetColor(1, 0, 0, 1); auto unlitShader = LoadShaderFamily("Shaders/Unlit.fam"); auto boxMat = CreateMaterial(); boxMat->SetShaderFamily(unlitShader); box->SetMaterial(boxMat); auto cam2 = CreateCamera(world); cam2->SetClearColor(0, 0, 0, 0); cam2->SetRenderLayers(2); cam2->SetFov(camera->GetFov()); cam2->SetMatrix(camera->matrix); cam2->SetLighting(false); 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()); mtl->SetColor(1, 1, 1, 0.5); auto cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); cam3->SetClearMode(CLEAR_COLOR); cam3->SetRenderLayers(4); cam3->SetPosition(sz.x * 0.5f, sz.y * 0.5f, 0); cam3->SetLighting(false); cam3->SetFog(true); cam3->SetFogRange(0, 0); cam3->SetFogColor(1, 1, 1, 1); cam3->SetClearColor(0, 0, 0, 1); auto box2 = CreateBox(world, 5); box2->SetPosition(0, 0, 7); box2->SetColor(color); auto box3= CreateBox(world, 1); box3->SetPosition(-0.5, 0, -0.5); Vec4 color2(1, 1, 0, 1); box3->SetColor(color2); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; }
  13. Tried to replicate how i made loading screen in my game but for some reason loading screen shows with big delay in this example #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; shared_ptr<World> gameWorld; shared_ptr<World> world; shared_ptr<Interface> ui; shared_ptr<Camera> uiCamera; shared_ptr<Map> gameScene; shared_ptr<Window> window; shared_ptr<Framebuffer> framebuffer; shared_ptr<World> loadingWorld; shared_ptr<Interface> loadingUi; shared_ptr<Camera> loadingCamera; shared_ptr<Widget> loadingLabel; shared_ptr<Widget> menuPanel; bool isMainMenuOn = true; bool newGameButtonCallback(const Event& ev, shared_ptr<Object> extra) { ui = nullptr; world = nullptr; loadingWorld->Render(framebuffer); WString mapName = "Maps/start.ultra"; gameScene = LoadMap(gameWorld, mapName); isMainMenuOn = false; return true; } bool exitButtonCallback(const Event& ev, shared_ptr<Object> extra) { exit(0); return true; } void loadingInit() { loadingWorld = CreateWorld(); //Loading UI auto font = LoadFont("Fonts/arial.ttf"); loadingUi = CreateInterface(loadingWorld, font, framebuffer->GetSize()); loadingUi->SetScale(1); loadingUi->SetRenderLayers(2); loadingUi->LoadColorScheme("Resources/configs/Style.json"); //Label LOADING... int centerX = float(framebuffer->GetSize().x) * 0.5f; int centerY = float(framebuffer->GetSize().y) * 0.5f; float labelHeight = float(framebuffer->GetSize().y) * 0.2f; loadingLabel = CreateLabel("LOADING", float(framebuffer->GetSize().x) * 0.05f, centerY - labelHeight * 0.5f, float(framebuffer->GetSize().x) * 0.95f, labelHeight, loadingUi->root, LABEL_CENTER | LABEL_MIDDLE); loadingLabel->SetFontScale(20); //Create ui camera loadingCamera = CreateCamera(loadingWorld, PROJECTION_ORTHOGRAPHIC); loadingCamera->SetPosition(centerX, centerY, 0); loadingCamera->SetRenderLayers(2); loadingCamera->SetClearMode(CLEAR_DEPTH); loadingCamera->SetLighting(false); } int main(int argc, const char* argv[]) { RegisterComponents(); //Load FreeImage plugin (optional) auto fiplugin = LoadPlugin("Plugins/FITextureLoader"); //Get the displays auto displays = GetDisplays(); //Create a window window = CreateWindow("Ultra Engine", 0, 0, 1280 * displays[0]->scale, 720 * displays[0]->scale, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); //Create a framebuffer framebuffer = CreateFramebuffer(window); //Create a world world = CreateWorld(); //Load a font auto font = LoadFont("Fonts/arial.ttf"); //Create user interface ui = CreateInterface(world, font, framebuffer->GetSize()); ui->SetRenderLayers(2); ui->root->SetColor(0.2f, 0.2f, 0.2f, 1.0f); ui->LoadColorScheme("Resources/configs/Style.json"); //Create ui camera auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); uiCamera->SetPosition(float(framebuffer->GetSize().x) * 0.5f, float(framebuffer->GetSize().y) * 0.5f, 0); uiCamera->SetRenderLayers(2); uiCamera->SetClearMode(CLEAR_DEPTH); auto newGameButton = CreateButton("New game", 200, 125, 200, 50, ui->root); ListenEvent(EVENT_WIDGETACTION, newGameButton, newGameButtonCallback); auto exitButton = CreateButton("Exit", 200, 200, 200, 50, ui->root); ListenEvent(EVENT_WIDGETACTION, exitButton, exitButtonCallback); gameWorld = CreateWorld(); gameWorld->RecordStats(); loadingInit(); shared_ptr<World> currentWorld = world; shared_ptr<Interface> currentUI = ui; while (window->Closed() == false) { if (!isMainMenuOn) currentWorld = gameWorld; while (PeekEvent()) { const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWCLOSE: if (ev.source == window) { exit(0); break; } break; default: currentUI->ProcessEvent(ev); break; } } currentWorld->Update(); currentWorld->Render(framebuffer); } return 0; }
  14. Without diffuse and specular maps still looks wrong. Anyway even if i fix shader and gamma for all cameras manually the Editor still needs a gamma settings then to fix it there. Also gamma settings would be nice for Camera in the Editor entity properties to avoid creating extra component and applying it every time
  15. So i still have to fix shader manually with every update when it changed What about gamma max value then? And is not it too bright by default?
  16. Last steam beta. Lightning now is broken in my project with any values of gamma in shader or game code until they are both 1.0 Default: Camera->SetGamma(1.0f); Only in shader gamma 1.0: How should be and looks like gamma 1.0 in shader AND game code
  17. Ability to set pick mode for selected entity in properties
  18. I think combo box for component field should not be changed by mouse scroll until i open it. I'm changing a values all time by accident when i scroll entity proprieties widget.
  19. Yeah, probably it should be enough. Currently prefabs are just useless if i need to change anything in component values.
  20. cam2:SetUniform(1, "Thickness", 4); -- Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -2) -- Create a light local light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) -- Create a model local model = CreateBox(world) model:SetColor(0, 0, 1) model:SetRenderLayers(1 + 2) local cam2 = CreateCamera(world); cam2:SetClearColor(0, 0, 0, 0); cam2:SetRenderLayers(2); cam2:SetFov(camera:GetFov()); cam2:SetMatrix(camera:GetMatrix()); cam2:AddPostEffect(LoadPostEffect("Shaders/Outline.fx")); cam2:SetUniform(1, "Thickness", 4); -- ERROR HERE local sz = framebuffer:GetSize(); local texbuffer = CreateTextureBuffer(sz.x, sz.y); cam2:SetRenderTarget(texbuffer); -- Display overlay local sprite = CreateSprite(world, sz.x, sz.y); local color = Vec4(0, 1, 0, 1); sprite:SetColor(color); sprite:SetRenderLayers(4); local mtl = CreateMaterial(); sprite:SetMaterial(mtl); mtl:SetTransparent(true); mtl:SetTexture(texbuffer:GetColorAttachment()); local cam3 = CreateCamera(world, PROJECTION_ORTHOGRAPHIC); cam3:SetClearMode(CLEAR_DEPTH); cam3:SetRenderLayers(4); cam3:SetPosition(sz.x * 0.5, sz.y * 0.5, 0); -- Main loop while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do model:Turn(0, 1, 0) world:Update() world:Render(framebuffer) end
×
×
  • Create New...