Jump to content

klepto2

Developers
  • Posts

    857
  • Joined

  • Last visited

Everything posted by klepto2

  1. klepto2

    sneak_peak_clouds

    Yes, this is first basic implementation without nearly no optimizations. E.g the clouds are raymarched at full resolution. Also it uses 128 to 256 steps per ray multiplied by 6 lightcone raymarches per step. What disturbed me more is the high culling time and the useless shadow render and high instance count. But this is something I will investigate further and file a bug report on that later.
  2. klepto2

    sneak_peak_clouds

    a small sneak-peak at the current status of cloud rendering :)
  3. Also Terrain::GetElevation doesn't take the Terrain-Position into account. Which is understandable as the terrain matrix is fully modifiable (scale, position and rotation), but it should be mentioned in the Docs.
  4. Hi, while i am working on my "Environement / Atmosphere / Weather" - system i'm working a lot with the terrain system and found some bugs and missing functionality from the API. Bugs: The layer system works only when you first assign a material to the terrain. In my opinion, this should not be required and a default terrain material should be set until it is overridden by the user (later planetary implementation or streaming terrain). On further investigation this was just a one time bug for me, but i let it here for reference. #include "UltraEngine.h" #include "Components/CameraControls.hpp" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the display list 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); //Create a camera auto camera = CreateCamera(world); camera->SetFov(70); camera->SetPosition(0, 50, 0); camera->SetRotation(45, 0, 0); camera->SetClearColor(0.125); //Sunlight auto light = CreateDirectionalLight(world); light->SetRotation(45, 35, 0); light->SetColor(2); //Create terrain auto terrain = CreateTerrain(world, 512); terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/512.r16"); terrain->SetScale(1, 100, 1); //Create base material auto ground = CreateMaterial(); auto diffusemap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_diff_4k.dds"); auto normalmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/river_small_rocks_nor_gl_4k.dds"); ground->SetTexture(diffusemap, TEXTURE_DIFFUSE); ground->SetTexture(normalmap, TEXTURE_NORMAL); terrain->SetMaterial(ground); // Comment out this line and the whole terrain will be black //Create paint material auto rocks = CreateMaterial(); diffusemap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k.dds"); normalmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k_dot3.dds"); auto dispmap = LoadTexture("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Materials/Ground/Rocks_Dirt_Ground_2k_disp.dds"); rocks->SetTexture(diffusemap, TEXTURE_DIFFUSE); rocks->SetTexture(normalmap, TEXTURE_NORMAL); rocks->SetTexture(dispmap, TEXTURE_DISPLACEMENT); int layer = terrain->AddLayer(rocks); terrain->SetLayerTextureMapping(layer, TERRAINMAPPING_VERTICAL); //Apply material based on terrain slope for (int x = 0; x < terrain->resolution.x; ++x) { for (int y = 0; y < terrain->resolution.y; ++y) { float slope = terrain->GetSlope(x, y); if (slope > 15.0f) { float wt = Min((slope - 15.0f) / 10.0f, 1.0f); terrain->SetLayerWeight(layer,x, y, wt); } } } //Camera controls camera->AddComponent<CameraControls>(); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } Missing methods: 1. The Fill method is commented out in the header file and my should maybe renamed to FillLayer(int layerid) 2. The methods to set and get the layer scaling are missing, or better: they are in the protected area. 3 All get Methods for LayerProperties should be provided. Currently it is not possible to access things like the Slope / height constraints of a specific layer.
  5. Thanks, i somehow overlooked that ^^
  6. Hi, i wanted to use them to build a small control ui. Unfortunatly the Widget system seems to have changed. the Widget::gui is protected and a weak ptr. So the provided Widgets are not working anymore.
  7. On a side note, which i will later post in a block in more depth: While the limit of parameters is now 64, this is still not enough for the precomputed scattering. I needed at least 88 unique identifiers (maybe 2 or 3 less, as i haven't fully optimized each vec4) + 4 texture slots. so i currently need a total of around 92 floats/values passed to the posteffect. Well to overcome this i used a common practice used in shadertoy and maybe this can be made more practical later. As a background: I need to precalculate a lot of these shadervalues, but once they are calculated, most of them don't change anymore. So i created a tiny texture, lets say 13 * 3 PX in RGBA32 format and the corresponding pixmap. Then I store each set of Vec4 in the pixmap and upload it to the texture. In the shader i can now simply get the values with a texelFetch. void WritePixel(shared_ptr<Pixmap> pixmap, int x, int y, iVec4 data) { pixmap->WritePixel(x, y, Vec4(data.x, data.y, data.z, data.w)); } void WritePixel(shared_ptr<Pixmap> pixmap, int x, int y, Vec4 data) { pixmap->WritePixel(x, y, data); } void WritePixel(shared_ptr<Pixmap> pixmap, int x, int y, Mat4 data) { pixmap->WritePixel(x, y, data[0]); pixmap->WritePixel(x + 1, y, data[1]); pixmap->WritePixel(x + 2, y, data[2]); pixmap->WritePixel(x + 3, y, data[3]); } void AtmosphereCalculator::updateUniforms_forpfx(double* lambdas, double* luminance_from_radiance) { auto pixmap = CreatePixmap(iVec2(m_settings_texture->GetSize().x, m_settings_texture->GetSize().y), TEXTURE_RGBA32); // constants WritePixel(pixmap, 0, 0, _atmosphereData.c.data0); WritePixel(pixmap, 1, 0, _atmosphereData.c.data1); WritePixel(pixmap, 2, 0, _atmosphereData.c.data2); WritePixel(pixmap, 3, 0, _atmosphereData.c.SKY_SPECTRAL_RADIANCE_TO_LUMINANCE); WritePixel(pixmap, 4, 0, _atmosphereData.c.SUN_SPECTRAL_RADIANCE_TO_LUMINANCE); ... much more data goes in here m_settings_texture->SetPixels(pixmap); } // and in the shader it looks like this: void SetupUniformDataForPFX(sampler2D settings) { AtmosphereParameters atmParams; AtmosphereConstants constants; constants.data0 = ivec4(texelFetch(settings, ivec2(0,0),0)); constants.data1 = ivec4(texelFetch(settings, ivec2(1,0),0)); constants.data2 = ivec4(texelFetch(settings, ivec2(2,0),0)); constants.SKY_SPECTRAL_RADIANCE_TO_LUMINANCE = texelFetch(settings, ivec2(1,0),0); constants.SUN_SPECTRAL_RADIANCE_TO_LUMINANCE = texelFetch(settings, ivec2(2,0),0); ... }
  8. Ok, i will temporarily use the "make public approach" and i get some very nice results precomputed atmospheric scattering as a posteffect in Ultraengine: And this is the actual code in main.cpp to integrate it: auto settings = EnvironmentSettings::GetEarthSettings(); auto env = CreateEnvironment(world, settings); env->AssignToCamera(camera); env->Start();
  9. ah ok, so it should even work without using hooks as the id is resolved already when needed. but why does it work seamingless with this: c->SetPostEffectParameter(_camera_posteffects[c], 3, _textureStorage->m_transmittance_array[READ]->rendertexture->core->id); Edit: Nevermind, found it. It is an override for int and i assume this already use the inttofloatbits.
  10. Ok, for an experiment, I made everything public in texture.h and corrected my code to add a RENDER_HOOK to assign the textures. (Before rendering the id system is not initialized) With these changes the following works and the correct ids are stored in the parameters: void BeginEnvironmentHook(const UltraEngine::Render::VkRenderer& renderer, shared_ptr<Object> extra) { auto env = extra->As<Environment>(); if (env != nullptr) { env->StartInternal(); } } void Environment::StartInternal() { for (auto c : _cameras) { // First 3 Values are to check if the new parameter system works for simple values and they work; c->SetPostEffectParameter(_camera_posteffects[c], 0, 1.0f); c->SetPostEffectParameter(_camera_posteffects[c], 1, 0.0f); c->SetPostEffectParameter(_camera_posteffects[c], 2, 0.0f); // Made everything public in Texture.h to access the internals and it works as expected c->SetPostEffectParameter(_camera_posteffects[c], 3, _textureStorage->m_transmittance_array[READ]->rendertexture->core->id); c->SetPostEffectParameter(_camera_posteffects[c], 4, _textureStorage->m_scattering_array[READ]->rendertexture->core->id); c->SetPostEffectParameter(_camera_posteffects[c], 5, _textureStorage->m_irradiance_array[READ]->rendertexture->core->id); } } but this is not working even with a hook: void Environment::StartInternal() { for (auto c : _cameras) { // First 3 Values are to check if the new parameter system works for simple values and they work; c->SetPostEffectParameter(_camera_posteffects[c], 0, 1.0f); c->SetPostEffectParameter(_camera_posteffects[c], 1, 0.0f); c->SetPostEffectParameter(_camera_posteffects[c], 2, 0.0f); // Default behaviour with protected access modifiers and it doesn't work c->SetPostEffectParameter(_camera_posteffects[c], 3, _textureStorage->m_transmittance_array[READ]); c->SetPostEffectParameter(_camera_posteffects[c], 4, _textureStorage->m_scattering_array[READ]); c->SetPostEffectParameter(_camera_posteffects[c], 5, _textureStorage->m_irradiance_array[READ]); } } parameters for values 3,4,5 are zero.
  11. I have tried it this way but none way is working. Any idea why? : first i create the textures: i verfied that they are created by applying a material with the texture to a box. now i tried to pass them to the posteffect like this: void Environment::SetupCamera(shared_ptr<Camera> camera) { _cameras.push_back(camera); auto pfx_id = camera->AddPostEffect(_posteffect); _camera_posteffects[camera] = pfx_id; } ... for (auto c : _cameras) { c->SetPostEffectParameter(_camera_posteffects[c], 3, _textureStorage->m_transmittance_array[READ]); c->SetPostEffectParameter(_camera_posteffects[c], 4, _textureStorage->m_scattering_array[READ]); c->SetPostEffectParameter(_camera_posteffects[c], 5, _textureStorage->m_irradiance_array[READ]); } in the post effect itself i tried different different ways to get the correct texture, but both failed: mat4 params = ExtractPostEffectParameters(0); int transmittance_id = floatBitsToInt(params[0][3]); col = texture(texture2DSampler[transmittance_id], uv).xyz; Direct using the PostEffectTextureID which also fails: col = texture(texture2DSampler[PostEffectTextureID3], uv).xyz;
  12. yes, this might work. But wouldn't that mean, that we need a way to assign the textures via code? From my understanding the current system (based on the json) would still rerender the textures every time. And we don't have a way to get the correct texture index, so we can not pass it with the parameters.
  13. A small experiment, using atmospheric scattering (simple) in a posteffect and rendering a planet with a subdivied quadsphere (similar to the one provided, but with a different texcoord approach to allow spherical maps)
  14. klepto2

    Terrain editing WIP

    I really like the fill button I was always missing this from the LE-Editor.
  15. thats why i said, not in every case In my opinion pixmap is pixmap, if a user wants to use other formats than r16, then why not. Just make a disclaimer, that low precision can lead to artifacts.
  16. btw, the mappingscale is not taken into account when texturing the terrain.
  17. well, not in every case : Source of the heightmap: https://johnflower.org/heightmap/mt-ruapehu-mt-ngauruhoe and the code how i apply the height: terrain->SetScale(tscale, scale, tscale); auto pixmap = LoadPixmap("Heightmaps/hm_nz.png"); pixmap = pixmap->Resize(terrain->resolution.x, terrain->resolution.y); float low_p = 1.0; for (int x = 0; x < terrain->resolution.x; x++) for (int y = 0; y < terrain->resolution.y; y++) { auto h = pixmap->Sample(iVec2(x, y)).r; terrain->SetHeight(x, y,h); //auto h = terrain->GetHeight(x, y); if (h < low_p) low_p = h; } terrain->SetPosition(0.0, -1.0 * (low_p * scale), 0.0);
  18. Ok, with r16 maps it works now. Other image formats (png) still leads to flat terrain, even with provided scale parameter.
  19. Or to make it work as before, you can set the default back to 1.0 instead of 1000.0. With 1.0 it works as expected: terrain->LoadHeightmap("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Terrain/1024.r16",1); terrain->SetScale(1, 100, 1);
  20. Since the latest update (terrain-normals) it seems the terrainsystem is broken. this sample (https://www.ultraengine.com/learn/Terrain_SetMaterial?lang=cpp) shows no terrain at all. (only when you comment out the LoadHeightmap the terrain shows up) And in my code it shows with LoadHeightmap (using a png instead of r16) but still the terrain is flat.
  21. klepto2

    pfx_pow.png

    Indeed i plan to sell it, but before that i need to resolve some things. A lot of refactoring, making it easier to use and i need to wait for some engine refinements, so that it will actually work really fast.
×
×
  • Create New...