Jump to content

klepto2

Developers
  • Posts

    858
  • Joined

  • Last visited

Posts posted by klepto2

  1. From my experience, you only need the miplevels. (At least i just needed the layercount) the layer for the cubemap are accessed by the z component. In the sky rendering I always render to the full cubemap at once. Well for the clouds I currently try to implement temporal reprojection, this allows rendering of 1/16th of the whole cubemap in one frame without a noticeable lag or noise. ( the clouds in the above screenshot let the framerate drop from hundreds to just 20 fps so there is need for optimization)

  2. eg: a cheap fog using real atmospheric lookups. Currently, this would need (and is probably the better way) a modification of the PBR shaders and additional textures and parameters to the material system. There are tons of pfx which may not only rely on down scaled 2d textures but also on custom 3d textures etc.. I haven't tried the pfx system yet that much, so i can't really say how flexible this will be. To be honest i think we can't compare Leadwerks and Ultraengine on this topic. While it was easy to render a sky as a posteffect (or water like shadmar did) as it would break the PBR rendering. 

    But one sample comes into my mind: underwater fx. if the water/ocean has a flexible height we need to pass the ocean heightfield and the parameters to the underwater posteffect to mask out the areas where the camera is partially above the water. 

  3. 3 hours ago, Josh said:

    I'm going to implement that fragment shader from Khronos for blurring / downsampling cubemaps, but it will work as a compute shader. Since real-time cubemap reflections are just not a good idea, I would rather focus on the quality of their reflections, and it's a lot easier to work with a compute shader than to set up a rendering pass. Environment probes should just get rendered once when the level loads.

    @klepto2 What inputs would you need for the post-processing system? What would the hook look like?

    
    void PostProcessHook(VkRenderer renderer, VkTexture depth, VkTexture color, VkTexture screennormals...?, shared_ptr<Object> extra)

    It depends what verengerter is and what it data it holds. I assume color texture would be the later framebuffer / output? I don‘t know how the internal pix system works, but I to work flawlessly I needs to be similar to the way Leadwerks does it. Eg we need to load a shader (fragment or compute) and add not only textures but also variables ( push constants or uniform buffers). I must admit that I haven‘t fully thought about that yet. I know speed goes over flexibility but to get people into shader or effect programming it should be easy but flexible as possible.

  4. 31 minutes ago, SpiderPig said:

    Looks great, good job.  What's the FPS like?

    I get around 150 fps but this is because the rendering of the diffuse irradiance is very heavy and needs to be optimized or another faster way needs to be found. Through the nature of the precomputation, the sky and reflections are rendered in ~1ms (maybe faster). 

    22 minutes ago, Josh said:

    With the 64-bit float build, you'll be able to render the earth, moon, other planets, and the sun all to-scale.

    yes, while this is possible, i will currently focus on 1 planet. multiple planets at once will be supported later.

    Now i am starting withthe cloudsystem :)

    • Like 2
  5. I don't know if this is a bug for sure, but it seems the pbr reflection is not correctly aligned:

    image.thumb.png.49e1af95c92f0c096ff56bf068e6644c.png

    Green: actual sun/light position

    Red: specular reflection is correct

    Yellow: actual reflection is off.

    Note: all cubemaps use the same layout and are rendered the same way.

    • Thanks 1
  6. yes, i found the FileSystemWatcher in your VXRT sample, and already using it.

    with glslc or better libshaderc you don't need an external process, you can use a cpp api to handle the compilation and get errors etc. some people have done runtime descriptorSetgenerators with this ^^.

  7. Yes, of course it will rely on some UltraEngine internals like the CommandBuffer or some transfer data, like the VKTexture you implemnted for me. But everything else should be handled by the external lib by itself. I even use my own Vkbuffer instances, because it would be hard to acces your internals in the way it would be optimal for the library, also you would need to write things like VKTexture for everything which possibly might interact with vulkan. 

    As said earlier, a more dynamic access to the posteffect system (add custom textures, as you have already subpasses you coud add some dummy pass which does nothing but pass external generated textures to the effect) would be awesome. 

    For the computeshader (will work for all shaders) I am currently integrating glslc together with some Filewatching and logging system, which will recompile the shader code on the fly either at the start of the program or on a file change. this way you just need to edit the original shader and the spv is generated at runtime when needed (when the source has changed). 

  8. I use some vulkan helper classes to make it easier to instantiate some of the VK_STRUCTURE_TYPES and handle/check for errors, but everything else for the compute shader is pure vulkan code by myself (of course collected from tutorials). Only a small part in my ComputeLibrary comes directly from Ultraengine (VulkanInstance, Device, ShaderModule, and math)

  9. mipmap generation works great now :)

    thx Josh.

    this is the main code i use currently to setup the environment pipeline:

    auto light = CreateLight(world, LIGHT_DIRECTIONAL);
    	light->SetRotation(35, 45, 0);
    	light->SetColor(1, 1, 1);
    
    	auto environment = initalize_atmosphere(world);
    
    	auto envSky = CreateTexture(TEXTURE_CUBE, 1024, 1024, TEXTURE_RGBA32, {}
    		, 6, TEXTURE_STORAGE, TEXTUREFILTER_LINEAR, 0);
    
    	auto envSkyWithoutSun = CreateTexture(TEXTURE_CUBE, 1024, 1024, TEXTURE_RGBA32, {}
    	, 6, TEXTURE_STORAGE, TEXTUREFILTER_LINEAR, 0);
    
    	auto reflectionTexture = CreateTexture(TEXTURE_CUBE, 256, 256, TEXTURE_RGBA32, {}
    	, 6, TEXTURE_STORAGE | TEXTURE_MIPMAPS , TEXTUREFILTER_LINEAR, 0);
    
    	auto diffTexture = CreateTexture(TEXTURE_CUBE, 64, 64, TEXTURE_RGBA32, {}
    	, 6, TEXTURE_STORAGE, TEXTUREFILTER_LINEAR, 0);
    
    	EnvironmentSkyContants skypush;
    	skypush.cameraposition = Vec4(camera->GetPosition(), 0.0);
    	skypush.lightdir = Vec4(Vec3(-light->matrix.k.x, -light->matrix.k.y, -light->matrix.k.z).Normalize(), 0.0);
    
    	auto cshader = ComputeShader::Create("Shaders\\Environment\\simple_test.comp.spv");
    	cshader->SetupPushConstant(sizeof(EnvironmentSkyContants));
    	cshader->AddTargetImage(envSky);
    	cshader->AddTargetImage(envSkyWithoutSun);
    	cshader->AddUniformBuffer(&environment->_atmosphereData, sizeof(AtmosphereData), false);
    	cshader->AddSampler(environment->m_transmittance_texture);
    	cshader->AddSampler(environment->m_irradiance_texture);
    	cshader->AddSampler(environment->m_scattering_texture);
    	cshader->AddSampler(environment->m_optional_single_mie_scattering_texture);
    	cshader->AddSampler(LoadTexture("Materials/Environment/noise.png"));
    
    	cshader->BeginDispatch(world, envSky->GetSize().x / 16, envSky->GetSize().y / 16, 6, false, &skypush, sizeof(EnvironmentSkyContants));
    
    	auto irrshader = ComputeShader::Create("Shaders\\Environment\\env_irradiance_gen.comp.spv");
    	irrshader->AddSampler(reflectionTexture);
    	irrshader->AddTargetImage(diffTexture);
    
    	irrshader->BeginDispatch(world, diffTexture->GetSize().x / 16, diffTexture->GetSize().y / 16, 6, false);
    
    	vector<EnvironmentSkyReflectionContants> reflShaders;
    	for (int layer = 0; layer < reflectionTexture->CountMipmaps(); layer++)
    	{
    		auto refshader = ComputeShader::Create("Shaders\\Environment\\env_reflection_gen.comp.spv");
    		refshader->AddSampler(envSkyWithoutSun);
    		refshader->AddTargetImage(reflectionTexture,layer);
    		refshader->SetupPushConstant(sizeof(EnvironmentSkyReflectionContants));
    		EnvironmentSkyReflectionContants data;
    		data.reflectiondata.x = layer / reflectionTexture->CountMipmaps();
    		refshader->BeginDispatch(world, reflectionTexture->GetSize().x / 16, reflectionTexture->GetSize().y / 16, 6, false, &data,sizeof(EnvironmentSkyReflectionContants));
    		reflShaders.push_back(data);
    	}
    
    	world->SetEnvironmentMap(envSky, ENVIRONMENTMAP_BACKGROUND);
    	world->SetEnvironmentMap(reflectionTexture, ENVIRONMENTMAP_SPECULAR);
    	world->SetEnvironmentMap(diffTexture, ENVIRONMENTMAP_DIFFUSE);

    The initalize_atmosphere is the method where the most magic happens, all required lookup textures are pre-generated for later use and are only calculated once.

    the other Computeshaders run recurring (which can be optimized to only run when parameters have changed)

     

     

  10. If you create a texture with a size of 512 you have 10 image views, but the array just contains 9. 

    512*512 -> not in array

    256*256 - 1*1 are in the array.

    here is some hints from the debug:

    image.thumb.png.cfee884d1b5ce8b2b08b06ce9740cf5f.png

    on the left you see all provided imageviews in the VKTexture. On the right you see the missing main imageView of the texture (marked yellow).

    and here is the result in NSight:

    image.thumb.png.1fa6f8327017a0ddc5e5174253a22824.png  

    at the bottom you can see that the actual mipmapsize is 10 not 9. and the toplevel mipmap is not rendered.

  11. The IBL is generated this way, and it is generated now with a size of 64*64 and a sample size of 0.125 which is a good compromise for realtime use.

    In theory the atmosphere can be used for full atmospheres viewed from space and from ground (with fluent transition) . So yes, the planet will become smaller and smaller.

    @Josh: I found a small bug with the GetVKTexture() Method. I am trying to render into the mipmaps (which works fine) but when using textures with mipmaps the imageview array just contains 9 levels instead of 10. not including the main level and at the first index of this array is just the first miplevel not the actual highest res one.

  12. you mean like this: image.thumb.png.2a9d174e4f748cdd8736d1b026dbc700.png

    It is currently distorted because of the render to cubemap. Rendering it as a post effect would be better for those outer atmosphere sequences. Then it would be also possible to support multiple planets etc.

    Here is another shot with a small 64*64 irradiance map: for the diffuse layer. the generation slows the whole process down a lot, rendering to higher resolution will bring it down to less than 20 fps which is far too slow. But i have ideas how to make this with just the pre computed textures instead of sampling the generated cubemap. 

    image.thumb.png.0762b6a81f67267a3013bc326c561d8b.png

    • Like 2
    • Upvote 1
  13. I now have used WinDbg to get more details about the annoying GUARD_PAGE error and this is more detailed:

    (36c8.4f68): Guard page violation - code 80000001 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    *** WARNING: Unable to verify checksum for GUARD_ERROR_d.exe
    VCRUNTIME140D!memcpy+0x27f:
    00007ffa`d786156f c4a17e7f8c0900ffffff vmovdqu ymmword ptr [rcx+r9-100h],ymm1 ds:0000014c`f5828000=00
    

    And the StackTrace:

    VCRUNTIME140D!memcpy(void)+0x27f [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\string\amd64\memcpy.asm @ 385] 
    GUARD_ERROR_d!UltraRender::RenderContext::TransferData+0xcbd
    GUARD_ERROR_d!UltraRender::RenderContext::Render+0x557
    GUARD_ERROR_d!UltraRender::RenderContext::Render+0x1f7
    GUARD_ERROR_d!UltraRender::RenderingThreadManager::Update+0x1d62
    GUARD_ERROR_d!UltraCore::ThreadManager::EntryPoint+0xae
    GUARD_ERROR_d!UltraEngine::Thread::thread_function+0xaa
    ucrtbased!thread_start<unsigned int (void * parameter = 0x0000014c`db315fe0)+0xb0 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97] 
    KERNEL32!BaseThreadInitThunk+0x14
    ntdll!RtlUserThreadStart+0x21

    If you need more info we can arrange a remote debug session for tomorrow, today i am to busy.

×
×
  • Create New...