Jump to content

klepto2

Developers
  • Posts

    857
  • Joined

  • Last visited

Posts posted by klepto2

  1. In the latest version, the UI is not rendered correclty:

    image.thumb.png.949a0bbd52aedc43b3d9a2269d60046c.png

    There are 100 items in the list and below are 2 tabbers. If you look closely the tabbers are visible, but only the text in a dark grayish color.

    #include "UltraEngine.h"
    #include "ComponentSystem.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, 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);
        camera->SetViewport(200, 0, framebuffer->size.x -200, framebuffer->size.y);
    
        auto uiCamera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC);
        uiCamera->SetRenderLayers(RENDERLAYER_1);
        uiCamera->SetClearMode(CLEAR_DEPTH);
        uiCamera->SetPosition(framebuffer->size.x / 2, framebuffer->size.y / 2);
        auto ui = CreateInterface(world, LoadFont("Fonts/arial.ttf"), iVec2(200, framebuffer->size.y));
        ui->SetRenderLayers(RENDERLAYER_1);
    
        auto sz = ui->root->ClientSize();
        auto listbox = CreateListBox(5, 5, sz.x - 10, 200, ui->root, LISTBOX_DEFAULT)->As<ListBox>();
        auto tabber = CreateTabber(5, 205, sz.x - 10, sz.y - 205, ui->root)->As<Tabber>();
        tabber->AddItem("Settings", true);
        tabber->AddItem("Output");
    
        for (int i = 0; i < 100; i++)
        {
            listbox->AddItem("Item " + String(i));
        }
    
        //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);
    
        //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)
        {
            if (PeekEvent())
            {
                auto ev = WaitEvent();
                ui->ProcessEvent(ev);
            }
    
            world->Update();
            world->Render(framebuffer);
        }
        return 0;
    }

     

  2. 14 hours ago, Josh said:

    Update

    • Fix for textures not loading correctly from plugins, may fix validation error
    • Fixed shader family reloading issue

    Works :)

    10 hours ago, Josh said:

    Final steps:

    • The SSR shader needs to detect and calculate indirect lighting based on whether the material that wrote each pixel uses PBR, Spec/Gloss, or classic shading. These each use a different calculation of specular reflection.
    • Clean shader code up a bit.
    • Make sure the spec/gloss appearance is correct. A lot of Sketchfab models use this glTF extension.
    • ASyncRender will be renamed to AsyncRender

    Nice :)

    I would like to add some small thing to the list:

    if you clean up the shader code, then you might consider to reanable the mappingscale feature (currently SetMappingScale has no effect, pbr and terrain)

    Also if possible: readd the animation texture feature with volume textures, this would make life a lot easier.

    and minor feature request: add some more methods to access some major properties:

    • Camera:
      • GetMatrix() (projection, view, etc.)
      • GetFrustumn
    • Terrain: 
      • a way to get the heightmap texture (not only the pixmap) --> support for gpu based heightmap generation
      • a way to get  / set the alpha mask for each material --> better support for serialization 

     

  3. #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;
    }

    curlNoise.png.5492f312989ae59a0de2870dea680dfd.png

    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.

    image.thumb.png.031ac934a8f43bb0f6918ed1f0ab4eb3.png

  4. 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.

    • Thanks 1
  5. 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.

     

  6. 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.

  7. 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. 

    • Thanks 1
  8. 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).

  9. 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?

  10. This is a validation error i only get with nvidia nsight with forced validation on. But maybe a hint to enable this extension.

    image.png.d583d20bd3223121a33acda081d0e5d0.png

    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.

  11. 28 minutes ago, Josh said:

    That's what I get for uploading before I go to bed...I updated it again, should be working fine.

    @klepto2 Is that validation error occurring as a result of your own Vulkan code? It says the problem is an RGBA 32-bit integer texture is using a linear sampler.

    no, the validation comes as well, when i compile the previous posted sample in debug. 

  12. 4 hours ago, Josh said:

    Update

    Fixed this issue: https://www.ultraengine.com/community/topic/61132-ultra-engine-testing/page/26/#comment-297777

    @klepto2Quads are probably better for water. You can create a quad mesh by supplying MESH_QUADS in the last parameter.

    Basically for any geometry that can use quads, that will always tessellate better than triangles.

    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.

    • Sad 1
  13. 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 :)

  14. #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.

  15. 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.

    • Like 1
  16. 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.

    • Like 1
  17. 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.

  18. 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.

×
×
  • Create New...