IceBurger Posted October 13, 2022 Share Posted October 13, 2022 I really wanted to like Cryengine, but yes, it is sluggish, cramped, and hard to make look good (makes me cry). Leadwerks has a control scheme I really like (that's the main reason I use it, I also just like to tinker). Finally, page 18. Page 17 was so long. 1 i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
Josh Posted October 14, 2022 Author Share Posted October 14, 2022 I hate it when I say something that completely contradicts what I just said, but I'm pretty certain voxels will work for diffuse GI. It just requires yet another iteration of this technology, which might take a month. It was actually very helpful for me to have to explain my reasoning to you, because the answer to the problem is actually contained in my response. 1 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 14, 2022 Share Posted October 14, 2022 Another small bug report (with potential fix): When you move the camera to a position which is further away from the center than the far range, the sykbox becomes distorted and doesn't work anymore: auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetRange(0.1, 1000); camera->SetPosition(0, 0, -1000); with a change to sky.frag to this: #version 450 #extension GL_GOOGLE_include_directive : enable #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shader_draw_parameters : enable #extension GL_EXT_multiview : enable #include "../Base/Limits.glsl" #include "../Base/PushConstants.glsl" #include "../Base/StorageBufferBindings.glsl" #include "../Base/TextureArrays.glsl" #include "../Base/materials.glsl" #include "../Base/UniformBlocks.glsl" #include "../Utilities/ReconstructPosition.glsl" //#include "../base/base_frag.glsl" //layout(binding = TEXTURE_BUFFER_CUBE) uniform samplerCube textureCubeSampler[MAX_TEXTURES_CUBE]; //Inputs layout(location = 0) in flat mat4 cameraMatrix; layout(location = 9) in flat uint materialID; layout(location = 4) in flat mat4 cameraProjMatrix; //Outputs layout(location = 0) out vec4 outColor; void main() { if (EnvironmentMap_Background != -1) { vec3 screencoord; screencoord.xy = gl_FragCoord.xy / BufferSize; screencoord.z = 0.0;// get the depth at this coord; vec3 fragposition = ScreenCoordToWorldPosition(screencoord); vec3 v = normalize(CameraPosition - fragposition); v*=vec3(-1.0); //vec4 screencoord = vec4((gl_FragCoord.xy / bufferSize.xy - 0.5f) * 2.0f, 1.0f, 1.0f); //vec4 screencoord = vec4(((gl_FragCoord.xy - cameraViewport.xy) / cameraViewport.zw - 0.5f) * 2.0f, 1.0f, 1.0f); //vec3 texcoord = normalize(CameraPosition - (cameraProjMatrix * screencoord).xyz); outColor = textureLod(textureCubeSampler[EnvironmentMap_Background], v, 0);//9.5f) * 1.0f; } else { outColor = vec4(1,0,1,1); } } The sykbox is correctly centered around the camera at any position: 1 1 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 14, 2022 Author Share Posted October 14, 2022 @klepto2 FYI, you don't need to normalize cubemap texture coordinates, so you can save a square root by eliminating this. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 14, 2022 Share Posted October 14, 2022 True. This is not needed there. I have taken this from another shader i use and there i need to normalize the vector, but here it is indeed not needed. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 15, 2022 Author Share Posted October 15, 2022 Update is now available. I recommend deleting the Shaders folder since I deleted and cleaned up a lot. The post-processing effects are cut down to just a few I want to focus on. They should all be working correctly, with transparency, with or without refraction enabled. The new SSAO is very nice, as well as the SSR effect. The engine is now using exponential shadow maps, which I find give the best results and eliminate shadow acne. There is a possible artifact you can see on the edges of some shadows, but that can be fixed by detecting the problem and replacing it with a standard PCF filter on the bad pixels. (I think I only tested spotlights, so stay tuned for an update within 1-2 days.) So graphics are now more or less finished, and I think things will go very quickly from here to the release. Here's an example you can try, with post-processing effects in the order I recommend: #include "UltraEngine.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, 1600, 900, displays[0], WINDOW_TITLEBAR | WINDOW_CENTER); //Create a world auto world = CreateWorld(); //Create a framebuffer auto framebuffer = CreateFramebuffer(window); //Create a camera auto camera = CreateCamera(world); camera->SetFOV(70); camera->SetFOV(90); camera->SetPosition(10, 3, 0); //camera->SetRefraction(true); //camera->SetRealTime(false); //camera->SetRotation(0, 180, 0);fsetvxrt camera->SetClearColor(1,0,0,0); camera->AddPostEffect(LoadPostEffect("Shaders/PostEffects/SSR.json")); camera->AddPostEffect(LoadPostEffect("Shaders/PostEffects/SSAO.json")); camera->AddPostEffect(LoadPostEffect("Shaders/PostEffects/FXAA.json")); camera->AddPostEffect(LoadPostEffect("Shaders/PostEffects/Bloom.json")); world->SetEnvironmentMap(LoadTexture("Materials/Environment/Storm/Diffuse.dds"), ENVIRONMENTMAP_DIFFUSE); world->SetEnvironmentMap(LoadTexture("Materials/Environment/Storm/Specular.dds"), ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(LoadTexture("Materials/Environment/Storm/Specular.dds"), ENVIRONMENTMAP_BACKGROUND); auto wall = CreateBox(world, 10, 50, 0.5); wall->SetPosition(0, 2.5, 5.25); //wall->SetReflective(true); wall->SetColor(0, 1, 1); //world->SetAmbientLight(0.25); auto drag = LoadModel(world, "https://raw.githubusercontent.com/Leadwerks/Documentation/private/Assets/Models/Stanford/dragon.glb"); drag->SetScale(0.1f); drag->SetColor(1, 1, 1, 1, true); auto wall2 = CreateBox(world, 10, 5, 0.5); wall2->SetPosition(0, 2.5, -5.25); //wall2->SetReflective(true); wall2->SetColor(1, 0.5, 0); auto wall3 = CreateBox(world, 0.5, 5.5, 11); wall3->SetPosition(-5.25, 2.75, 0); //wall3->SetColor(0, 1, 0); auto model = CreateBox(world, 500, 1, 500); model->SetPosition(0, -0.5f, 0); //model->SetColor(0.5); //model->MakeStatic(); //model->SetReflective(true); auto mtl = CreateMaterial(); mtl->SetRoughness(0.1); mtl->SetMetalness(0.6); //mtl->SetColor(0.5); // mtl->SetTexture(LoadTexture("Materials/dirt01_dot3.dds"), TEXTURE_NORMAL); //mtl->SetTextureScale(0, 0.05, 0.05); model->SetMaterial(mtl); //model->SetColor(0, 1, 0); wall3->SetMaterial(mtl); // drag->SetPosition(100, 0, 0); auto mtl2 = mtl->Copy()->As<Material>(); auto mtl3 = mtl->Copy()->As<Material>(); wall->SetMaterial(mtl3); mtl2->SetMetalness(0.75); mtl2->SetRoughness(0.1); mtl2->SetTransparent(true); mtl2->SetColor(1,1,1,0.5); //mtl2->SetEmission(0, 1, 0); //mtl2->SetColor(0.25); //drag->SetHidden(true); drag->SetReflection(false); // mtl2->SetColor(1, 1, 1, 1); //mtl2->SetTransparent(true); camera->SetRefraction(true); //mtl2->SetReflection(true); // drag->SetColor(0.5, 0.5, 0.5, 1, true); //mtl2->SetEmission(0, 0.5, 0); drag->SetMaterial(mtl2, true); // drag->SetReflective(true); auto bb = CreateBox(world, 20, 20, 20); bb->SetPosition(0, 0, 20); auto bbb = CreateBox(world, 30, 30, 30); bbb->SetPosition(0, 0, 30); auto light = CreateSpotLight(world); light->SetPosition(2, 2.5, -5); light->SetRange(0.1, 38); light->SetShadowMapSize(1024); //light->SetDepthBias(0, 0); light->SetHidden(true); light->SetConeAngles(45,35); //auto b = light->GetDepthBias(); // light->SetDepthBias(100, 0); //auto light = CreateBoxLight(world); //light->SetPosition(20, 20, -20); //ight->SetScale(20, 20, 20); //light->SetRange(0, 20); //light->SetRotation(45, -45, 0); //light->Move(0, 0, -10); //light->SetShadowMapSize(1024); // light->SetDepthBias(0.5, 1.75); //light->SetScale(50, 50, 50); //light->SetRange(0.0f, 1.0f); //light->SetColor(4); //light->Staticize() // auto sp = CreateSphere(world); // sp->SetShadows(false); //sp->SetParent(light, true); //auto cone = CreateCone(world); //cone->SetScale(20, 10, 20); //cone->SetPosition(0, 5, 0); //wall->SetMaterial(mtl); wall2->SetMaterial(mtl); auto fw = CreateFileSystemWatcher(CurrentDir()); auto mousepos = window->GetMouseAxis(); Vec3 camerarotation = Vec3(0, -90, 0); camera->SetRotation(camerarotation); camera->Turn(45, 0, 0); const float mouselookspeed = 100.0f; Vec3 lookchange; const float mousesmoothing = 0.0f;// 0.75f; world->SetAmbientLight(0.15); auto tower = CreateBox(world, 10, 0.5f, 11); //tower->SetPosition(0, 10.25, 0); tower->SetPosition(0, 5.25, 0); //tower->SetReflective(true); //tower->SetRotation(0, 0, -10); tower->SetMaterial(mtl); //tower->SetColor(0, 1, 1); camera->Turn(0, 45, 0, true); //auto volume = CreateBoxBrush(world, 9.5, 5.5, 9.5); //volume->SetPosition(0, 5 + 2.5, 0); bool started = false; uint64_t updatedtime = 0; // //wall->Staticize(); //wall2->Staticize(); //wall3->Staticize(); //tower->Staticize(); //model->Staticize(); //drag->Staticize(); //camera->SetRotation(0,0,0); //camera->SetPosition(0, 10, -300); //camera->Sync(); /*auto col1 = CreateBox(world, 1, 4, 1); std::vector<shared_ptr<Entity> > cols; for (int x = 0; x < 20; ++x) { for (int y = 0; y < 20; ++y) { auto col = col1->Instantiate(world); col->SetPosition(x * 8 - 80, 2, y * 8 - 80); cols.push_back(col); col->Staticize(); } }*/ auto probe = CreateProbe(world); probe->SetPosition(0, 2.5, 0); probe->SetScale(10.1, 5.1, 10.1); probe->SetRange(0.1, 1000); probe->SetFadeDistance(4, CUBEMAP_POSITIVE_X); probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_X); probe->SetFadeDistance(0, CUBEMAP_POSITIVE_Y); probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_Y); probe->SetFadeDistance(0, CUBEMAP_POSITIVE_Z); probe->SetFadeDistance(0, CUBEMAP_NEGATIVE_Z); auto box = CreateBox(world); box->SetPosition(5, 0.5, 0); box->SetColor(1, 0.5, 0); // auto probe = CreateLight(world, LIGHT_POINT); // probe->SetPosition(0, 5, 0); //probe->SetRange(0.1, 100); //drag->SetColor(0, 1, 0,1,true); //drag->SetHidden(true); //probe2->SetRange(0.1, 10); //Vec2 depthbias = probe2->GetDepthBias(); //Main loop float r1 = 0; float r2 = 0; while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyDown(KEY_UP)) r1 += 10; if (window->KeyDown(KEY_DOWN)) r1 -= 10; if (window->KeyDown(KEY_RIGHT)) r2 += 0.01; if (window->KeyDown(KEY_LEFT)) r2 -= 0.01; r1 = max(r1, 0.0f); r2 = max(r2, 0.0f); //light->SetDepthBias(r1, r2); //Print(String(r1) + ", " + String(r2)); if (window->KeyDown(KEY_LEFT)) light->Move(0,-0.1, 0); if (window->KeyDown(KEY_RIGHT)) light->Move(0,0.1, 0); if (window->KeyDown(KEY_UP)) light->Move(0.1, 0, 0); if (window->KeyDown(KEY_DOWN)) light->Move(-0.1, 0, -0); // sp->SetHidden(true); // if (window->KeyDown(KEY_P)) depthbias.x += 0.1f; // if (window->KeyDown(KEY_L)) depthbias.x -= 0.1f; //probe2->SetDepthBias(depthbias.x, depthbias.y); // tower->Turn(0, 0.5, 0); // drag->Turn(0, 0.5, 0); // drag->Turn(0, 1, 0); while (PeekEvent()) { const auto ev = WaitEvent(); if (ev.id == EVENT_FILECREATE or ev.id == EVENT_FILECHANGE) { auto asset = FindCachedAsset(ev.text); if (asset) asset->Reload(); } } camera->UpdateControls(window); //model->SetPosition(0, 0, 0.1); //light->Turn(0, 0.1, 0, true); //if (window->KeyDown(KEY_LEFT)) probe2->Translate(0.05, 0, 0); // if (window->KeyDown(KEY_RIGHT)) probe2->Translate(-0.05, 0, 0); // if (window->KeyDown(KEY_UP)) light->Translate(0.0, 0, 0.05); // if (window->KeyDown(KEY_DOWN)) light->Translate(0.0, 0, -0.05); // if (window->KeyHit(KEY_SPACE)) light->SetPosition(light->position.x, light->position.y, -light->position.z); if (started) { auto curr = Millisecs(); //if (curr - updatedtime > 1500) if (window->KeyHit(KEY_SPACE)) { updatedtime = curr; //light->SetPosition(-light->position.x, 2, -2); //light->SetPosition(light->GetPosition(true), true); // light->Sync(); //camera->Render(); } } world->Update(); world->Render(framebuffer, false); } return 0; } 3 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 16, 2022 Share Posted October 16, 2022 The sample looks nice, but once you setup a directional light, the whole scene (except the background) becomes ultra bright: auto light = CreateDirectionalLight(world); light->SetRotation(45, -45, 0); Sidequestion: Is there a way to increase the Texturelimits? currently there are just 16 cubemaps allowed, Can this be altered in some way? In earler versions this was done through the ultra.json if i rembmer correctly. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
SpiderPig Posted October 16, 2022 Share Posted October 16, 2022 I think that's what's happening here too. There are four red spheres and two white (or grey) spheres. The sides that are facing the directional light are solid white. Link to comment Share on other sites More sharing options...
Josh Posted October 16, 2022 Author Share Posted October 16, 2022 Yeah, only spotlights will work right now, I am working on it... 2 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2022 Author Share Posted October 18, 2022 I've got point and box lights working, just need to bring directional lights back to life now... 2 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2022 Author Share Posted October 18, 2022 Update: Spot, point, box, and directional lights all working with exponential shadow maps. Directional lights have some issues with the shadow distance, but I wanted to just get the update out and then deal with the details after. Entity::SetReflection(false) will make an entity not appear in cubemap reflections. Dynamic objects or objects that are not close to the edge of a room should use this setting. Max cubemaps limit raised to 128 The shadow map blurring is disabled because I was testing things and forgot to enable it again, so shadow edges will be very aliased, but I'll fix that tomorrow. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
IceBurger Posted October 18, 2022 Share Posted October 18, 2022 4 minutes ago, Josh said: Entity::SetReflection(false) will make an entity not appear in cubemap reflections. Now that's gonna be fun i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2022 Author Share Posted October 18, 2022 @klepto2 @SpiderPig That might actually be the correct result. A diffuse environment map has a very big impact on brightness, and the only place it will not crank the brightness up is inside an environment probe, which effectively blocks the ambient light from coming in. I can't say for sure yet. If you have a directional light and a diffuse environment map, you are effectively lighting the scene twice as bright. Additional commands to tune the IBL brightness for diffuse and specular will be added. 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2022 Author Share Posted October 18, 2022 16 minutes ago, IceBurger said: Now that's gonna be fun That's what I had to do with the dragon model. Otherwise, it would appear stretched across the walls and distorted. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2022 Author Share Posted October 18, 2022 Okay, update is up with shadow filtering fixed. Exponential shadow maps only use a single texture lookup, instead of the 4x4 or 3x3 samples PCF requires. 2 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 19, 2022 Share Posted October 19, 2022 12 hours ago, Josh said: @klepto2 @SpiderPig That might actually be the correct result. A diffuse environment map has a very big impact on brightness, and the only place it will not crank the brightness up is inside an environment probe, which effectively blocks the ambient light from coming in. I can't say for sure yet. If you have a directional light and a diffuse environment map, you are effectively lighting the scene twice as bright. Additional commands to tune the IBL brightness for diffuse and specular will be added. yeah, that might be true. Setting the Color of a directional light to 0.1,0.1,0.1 instead of full bright fixes the problem as well, but there are still some issues with the directional shadows: The shadows are not very smooth. And they blend out way too early for directional lights (in my opinion). Blocky: Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
klepto2 Posted October 19, 2022 Share Posted October 19, 2022 oh and btw: the earth at real scale: 2 Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 19, 2022 Author Share Posted October 19, 2022 @klepto2 I am seeing a big jump in shadow width at the border between cascades. I think the solution is to decrease the blur radius each stage. I am adding a Light::SetShadowBlurRadius(pixels) command. What's the near camera range in the space shot above? My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted October 19, 2022 Share Posted October 19, 2022 The range is near: 50000.0 far:10000000.0 I dynamically increase the near range in steps the more i am away from the planet. I think it should be easier later if Doubles are used, but the shaders i have written are not yet build for that. Also I think a way to overcome this would be to use 2 cameras, one for the near objects, and a second for the planet stuff. The Radius of the earth is 6.371.000 m. Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted October 19, 2022 Author Share Posted October 19, 2022 1 minute ago, klepto2 said: Also I think a way to overcome this would be to use 2 cameras, one for the near objects, and a second for the planet stuff. Yeah, I recommend this. There are so few objects visible at far distances that it's easy to manage a camera for each heavenly body. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 19, 2022 Author Share Posted October 19, 2022 Trying a new technique I just invented. Conventional shadow map: My filtering: 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
IceBurger Posted October 19, 2022 Share Posted October 19, 2022 10 minutes ago, Josh said: Trying a new technique I just invented Patent pending? i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
Josh Posted October 19, 2022 Author Share Posted October 19, 2022 6 minutes ago, IceBurger said: Patent pending? No, that would cost about $30,000. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
IceBurger Posted October 19, 2022 Share Posted October 19, 2022 13 minutes ago, Josh said: No, that would cost about $30,000. Rip. It should still be legal to say it's "patent pending" even if you don't have a patent pending. Security through obscurity i now hate love C++ Beeeeeeeeeeeeeep~~This is a test of the emergency signature system~~Beeeeeeeeeeeeeep RX 6800XT | i5-13600KF | 32GB DDR5 | 1440p is perfect Link to comment Share on other sites More sharing options...
Josh Posted October 19, 2022 Author Share Posted October 19, 2022 22 minutes ago, IceBurger said: Rip. It should still be legal to say it's "patent pending" even if you don't have a patent pending. Security through obscurity It is, it's called a provisional patent, and it only costs a few hundred dollars. Once the patent is filed you have one year to complete the final patent. If you don't complete the final patent within one year you lose the ability to patent the item forever. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts