Jump to content

klepto2

Developers
  • Posts

    929
  • Joined

  • Last visited

Everything posted by klepto2

  1. This, or make the camerarange 1.0 to 1000.0 instead of 0.1 to 1000.0
  2. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { auto plg = LoadPlugin("Plugins/KTX2TextureLoader"); auto plg2 = LoadPlugin("Plugins/FITextureLoader"); //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(); //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,0,1); auto box_mat = CreateMaterial(); auto texture = LoadTexture("Materials/curlNoise.png"); box_mat->SetTexture(texture, TEXTURE_DIFFUSE); box->SetMaterial(box_mat); //Entity component system auto actor = CreateActor(box); auto component = actor->AddComponent<Mover>(); component->rotation.y = 45; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); world->Render(framebuffer); } return 0; } if you run the above code, you will still see a blue box. The app output states that the image is loaded succesfully, but it seems it is not uploaded.
  3. Ok, i found the problem It seems that the ktx2 and png loaders are broken. if i change all of my textures to be dds or generated on the fly it works. But as soon as i load a ktx2 or png image i get this validation error. I will check if i can provide a sample.
  4. no, I just create the views myself. But I have tracked it a bit further down. It is definitly not on your side. In my Atmospheric scattering code i run around 30 computeshaders, and only one is causing the trouble ant that might be due to a pingpong algorithm i use. All other shaders work flawlessly. I think it might be just a simple access problem which is now catched with the new sdk and was not catched before.
  5. I get the access to Rendertexture by modifing the headers a bit: i added a class predfintion in the texture.h like: class TextureMemberAccessor; and in the Texture class i added a friend class TextureMemberAccessor; Then i could do the following in my code: namespace UltraEngine { class TextureMemberAccessor { public: static shared_ptr<UltraRender::RenderTexture> GetRenderTexture(shared_ptr<Texture> texture) { return texture->rendertexture; } }; } It is a very ugly way, but for testing purposes it is temporay valid. But the GetLayout() member returns GENERAL, but as your code keeps sink of it, it might not yet be the correct state in the vulkan layer. I will test this a bit further.
  6. Ok, I investigated it a bit further. It seems to be a synchronization problem due to the async architecture of vulkan itself. As it works in release or by deactivating the validationlayers in debug mode. I will not look into it right now as i plan to refactor the whole system anyway later to have its own cmdbuffer and queues, which ideally should solve this. for those who are interested: to deactivate all validation layers in Ultraengine: UltraRender::GPUDevice::validationlayers.clear(); Put this on top of your application.
  7. The texture class has only protected member for the rendertexture, like most more deeper members. And as it is protected only friend classes can access them. Same goes for some members of the camera class which could be handy ( all matrix stuff for example).
  8. I already have found this, but I can’t access it well, with some small modifications to the texture.h it would be possible. But not out of the box.
  9. Yes, in release it works as expected. But It could be that it is just ignored until it has the correct layout.
  10. I only use textures generated with createtexture, but as I register the hooks right from the start it might be, that the textures are not initialized in the first run. I will check this tomorrow. But how can I check if a texture is already initialized? Maybe if I wait for the first transfer hook to finish, before I run anything else?
  11. This is a validation error i only get with nvidia nsight with forced validation on. But maybe a hint to enable this extension. Another thing is that my Computepipeline isn't working anymore. There seems to be some changes regarding image initialisation. I need a way to savely retreive the current VkImageLayout to transition to the required one. Maybe its due to the new VulkanSDK as well, but this is the current message i get: Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1f970310e50, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] command buffer VkCommandBuffer 0x1f970310e50[] expects VkImage 0x7992cc00000002d1[] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_GENERAL--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED. Any idea? [Edit:] This obviously only occurs in debug mode, in release the validation error is ignored and the computepipeline worksas expected.
  12. Additional Info: The validation error only occurs, when a terrain is in the scene. Without terrain it works.
  13. no, the validation comes as well, when i compile the previous posted sample in debug.
  14. Couldn't test it. The debug library throws validation errors: Validation Error: [ VUID-vkCmdDrawIndexedIndirect-mipmapMode-04770 ] Object 0: handle = 0x176083000000005f, type = VK_OBJECT_TYPE_DESCRIPTOR_SET; Object 1: handle = 0xb097c90000000027, type = VK_OBJECT_TYPE_SAMPLER; Object 2: handle = 0xa2eb680000000026, type = VK_OBJECT_TYPE_IMAGE_VIEW; | MessageID = 0x46f7c46a | vkCmdDrawIndexedIndirect: Descriptor set VkDescriptorSet 0x176083000000005f[] Sampler (VkSampler 0xb097c90000000027[]) is set to use VK_SAMPLER_MIPMAP_MODE_LINEAR with compareEnable is set to VK_FALSE, but image view's (VkImageView 0xa2eb680000000026[]) format (VK_FORMAT_R32_UINT) does not contain VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT in its format features. The Vulkan spec states: If a VkSampler created with mipmapMode equal to VK_SAMPLER_MIPMAP_MODE_LINEAR and compareEnable equal to VK_FALSE is used to sample a VkImageView as a result of this command, then the image view's format features must contain VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT (https://vulkan.lunarg.com/doc/view/1.3.236.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexedIndirect-mipmapMode-04770) and the release lib is damaged. I indeed use Quads for the water mesh, i just leaved it out in the sample as it didn't matter in this case. Also i wouldn't say they tesselate better, but with dynamic tessellation the blending is much smoother.
  15. Just a sidenote: using System; using System.ComponentModel; using System.Runtime.InteropServices; using UltraEngine; using static UltraEngine.Functions; using Object = UltraEngine.Object; namespace UltraAppKitCore.Sample { class Program { static void Main(string[] args) { //Get the displays var displays = GetDisplays(); //Create a window var window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WindowStyles.WINDOW_CENTER | WindowStyles.WINDOW_TITLEBAR); //Create a world var world = CreateWorld(); //Create a framebuffer var framebuffer = CreateFramebuffer(window); //Create a camera var camera = CreateCamera(world); camera.SetClearColor(0.125f, 0.125f,0.125f); camera.SetFov(70f); //Create a light var light = CreateDirectionalLight(world); light.SetRotation(35f, 45f, 0f); light.SetRange(-10, 10); //Main loop while (window.Closed() == false && window.KeyDown(KeyCode.KEY_ESCAPE) == false) { world.Update(); world.Render(framebuffer); } } } } this is a sample which actually runs in c# and .net core
  16. You need to call : world->RecordStats(true);
  17. #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Terrain Paint", 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, 100, -100); 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); //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); rocks->SetDisplacement(0.5); //Camera controls auto actor = CreateActor(camera); actor->AddComponent<CameraControls>(); auto specmap = LoadTexture("Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture("Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); auto plane_mat = CreateMaterial(); plane_mat->SetTessellation(true); plane_mat->SetTransparent(true); plane_mat->SetColor(0.0, 0.0, 1.0, 0.5); auto plane = CreatePlane(world, 4096, 4096, 64, 64); plane->SetMaterial(plane_mat); plane->SetPosition(0.0, 35.0, 0.0); auto camera_second = CreateCamera(world); camera_second->SetTessellation(2.0); auto textbuffer = CreateTextureBuffer(256, 256); camera_second->SetRenderTarget(textbuffer); bool refraction = false; bool tesselation = false; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F1)) camera->SetWireframe(!camera->GetWireframe()); if (window->KeyHit(KEY_F2)) { tesselation = !tesselation; if (tesselation) camera->SetTessellation(32.0); else camera->SetTessellation(0.0); } if (window->KeyHit(KEY_F3)) { refraction = !refraction; camera->SetRefraction(refraction); } if (window->MouseDown(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto pickinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (pickinfo.success) { if (pickinfo.entity == terrain) { iVec2 pos; pos.x = Round(pickinfo.position.x) + terrain->resolution.x / 2; pos.y = Round(pickinfo.position.z) + terrain->resolution.y / 2; int radius = 20; for (int x = pos.x - radius; x < pos.x + radius; ++x) { for (int y = pos.y - radius; y < pos.y + radius; ++y) { float strength = 1.0f - Vec3(x, y, 0).DistanceToPoint(Vec3(pos.x, pos.y, 0)) / float(radius); if (strength <= 0.0f) continue; float wt = terrain->GetMaterialWeight(x, y, rocks); wt += 0.1f; terrain->SetMaterial(x, y, rocks, wt); } } } } } world->Update(); world->Render(framebuffer); WString title = "Tesselation - Test: "; title += "F1 - Wireframe(" + WString(camera->GetWireframe() ? "true" : "false") + ") "; title += "F2 - Tesselation(" + WString(tesselation ? "true" : "false") + ") "; title += "F3 - Refraction(" + WString(refraction ? "true" : "false") + ") "; window->SetText(title); } return 0; } 1. Tesselation and Refraction (with transparent objects) still doesn't work. 2. in this sample i have a second camera with a high tesselation (2.0) and the main camera has a tesselation-factor of 32. Now if you turn on tesselation you might notice that everything is tesselated with factor 2.0 instead of 32.0. In more complex samples you can see that it might be a uniform issue as it seems to switch between 2 and 32 randomly.
  18. Ok i have analysed the problem. You currently try to use the actual backbuffer as the reflection buffer. This will not work as the backbuffer will always align with the actual camera, where the reflection must be a real reflection texture based on the reflection-physics. The code would look something like this: auto matrix = camera->GetMatrix(); // Save curent camera matrix ocean->Hide(); // Hide the ocean, so it doesn't hide reflection geometry camera->SetRotation(camera->GetRotation() * Vec3(-1.0, 1.0, -1.0)); camera->SetPosition(camera->position.x, -camera->position.y + 2 * waterheight, camera->position.z); World::GetCurrent()->graphicsdriver->clipplane[0] = Vec4(0, -1.0, 0, waterheight); // Setup a clipplane to clip everything which is under water, otherwise you can see items under water in the reflection. // Render World to reflection texture // Reset camera, clipplane and show ocean camera->SetMatrix(matrix); World::GetCurrent()->graphicsdriver->clipplane[0] = Vec4(0.0); ocean->Show(); //Render the scene as normal As the clipplanes are only availabe in c++, this will not completely work from lua.
  19. If you want you can send me a sample project and I can look into it.
  20. How do you create the reflection texture? And how do you assign it? I am very sure that this will not work from within the editor as the scripts are not updated (except postprocessing).
  21. You normally just need to do something like this: vec3 screencoord = vec3(gl_FragCoord.x/buffersize.x,gl_FragCoord.y/buffersize.y,1.0); screencoord.y = 1.0 - screencoord.y; vec3 reflectionvector = screencoord; vec3 reflection = textureProj(texture10,(reflectionvector + normal)).rgb; This is how i have done it.
  22. Works much better now, but i have found another issue: #include "UltraEngine.h" #include "ComponentSystem.h" using namespace UltraEngine; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Terrain Paint", 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, 100, -100); 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); //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); //Camera controls auto actor = CreateActor(camera); actor->AddComponent<CameraControls>(); auto specmap = LoadTexture("Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture("Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); auto plane_mat = CreateMaterial(); plane_mat->SetTessellation(false); plane_mat->SetTransparent(true); plane_mat->SetColor(0.0, 0.0, 1.0, 0.5); auto plane = CreatePlane(world, 2048, 2048,64,64); plane->SetMaterial(plane_mat); plane->SetPosition(0.0, 35.0, 0.0); bool refraction = false; bool tesselation = false; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F1)) camera->SetWireframe(!camera->GetWireframe()); if (window->KeyHit(KEY_F2)) { tesselation = !tesselation; if (tesselation) camera->SetTessellation(8.0); else camera->SetTessellation(0.0); } if (window->KeyHit(KEY_F3)) { refraction = !refraction; camera->SetRefraction(refraction); } if (window->MouseDown(MOUSE_LEFT)) { auto mousepos = window->GetMousePosition(); auto pickinfo = camera->Pick(framebuffer, mousepos.x, mousepos.y); if (pickinfo.success) { if (pickinfo.entity == terrain) { iVec2 pos; pos.x = Round(pickinfo.position.x) + terrain->resolution.x / 2; pos.y = Round(pickinfo.position.z) + terrain->resolution.y / 2; int radius = 20; for (int x = pos.x - radius; x < pos.x + radius; ++x) { for (int y = pos.y - radius; y < pos.y + radius; ++y) { float strength = 1.0f - Vec3(x, y, 0).DistanceToPoint(Vec3(pos.x, pos.y, 0)) / float(radius); if (strength <= 0.0f) continue; float wt = terrain->GetMaterialWeight(x, y, rocks); wt += 0.1f; terrain->SetMaterial(x, y, rocks, wt); } } } } } world->Update(); world->Render(framebuffer); WString title = "Tesselation - Test: "; title += "F1 - Wireframe(" + WString(camera->GetWireframe() ? "true" : "false") + ") "; title += "F2 - Tesselation(" + WString(tesselation ? "true" : "false") + ") "; title += "F3 - Refraction(" + WString(refraction ? "true" : "false") + ") "; window->SetText(title); } return 0; } if you run this, you will see a terrain with a transparent plane (as pseudo water). The water is only visible under the following conditions: Tesselation on, Refraction off Tesselation off, Refraction on Tesselation off, Refrection off (just to clarify that it all works, when now refraction is used) Also the plane_mat->SetTesselation has no effect. The plane is always tesselated when the camera uses tesselation.
  23. True, but as soon as you trigger the pbr-pipeline the background and transparent objects are not visible anmyore: just add this to the sample above: auto specmap = LoadTexture("Materials/Environment/Storm/specular.dds"); auto diffmap = LoadTexture("Materials/Environment/Storm/diffuse.dds"); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_BACKGROUND); world->SetEnvironmentMap(specmap, ENVIRONMENTMAP_SPECULAR); world->SetEnvironmentMap(diffmap, ENVIRONMENTMAP_DIFFUSE); and you will see, that with tesselation the background is not rendering, without tesselation it works.
  24. That works great, though all other geometry is not rendered with tessalation enabled. Another issue is that you can't create terrains higher than 1024. There comes an exception from newton.
  25. https://developer.nvidia.com/nvidia-texture-tools-exporter try this, it can also export cubemaps, etc. and you can add filters etc.
×
×
  • Create New...