SpiderPig Posted August 20, 2023 Share Posted August 20, 2023 Got some weird results with this. It's using the default shaders for the material so I understand that the result is supposed to be red as there's only data in the red channel of the image. However only a few small areas appear to have a gradient between red and black pixels and the rest is just solid black or solid red. Unsure if an appropriate shader needs to be made to sample this or if the texture is not being created correctly. Saved result of the pixmap shown is Visual Studio: Result with bluegrid.dds: Result with R16 texture: The texture is spread across a grid, so each pixel should be a metre apart and there should be interpolation between each pixel shouldn't there? I'm seeing some pixels that worked and others that have rounded edges where I think they should be blending. #include "UltraEngine.h" using namespace UltraEngine; Vec3 mousepos = Vec3(0.0f); float move_adjustment = 0.1f; float move_speed = 1.0f; float lookspeed = 0.1f; float looksmoothing = 0.5f; int main(int argc, const char* argv[]) { auto displays = GetDisplays(); auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR); auto world = CreateWorld(); auto framebuffer = CreateFramebuffer(window); auto camera = CreateCamera(world); camera->SetClearColor(0.125); camera->SetFov(70); camera->SetPosition(0, 10, 0); auto light = CreateDirectionalLight(world); light->SetRotation(35, 35, 0); auto box = CreateBox(world); box->SetPosition(10.0f, 2049.0f, 10.0f); int size = 256; unsigned short* buffer = new unsigned short[size * size]; for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { buffer[(y * size) + x] = (unsigned short)Random(USHRT_MAX); } } auto data = CreateBuffer(size * size * 2); data->Poke(0, (const char*)buffer, size * size * 2); auto map = CreatePixmap(size, size, TEXTURE_R16, data); map->Save("Test.dds"); vector<shared_ptr<Pixmap>> mipchain; mipchain.push_back(map); auto texture = CreateTexture(TEXTURE_2D, size, size, map->format, mipchain); auto mat = CreateMaterial(); mat->SetTexture(texture, TEXTURE_DIFFUSE); //mat->SetTexture(LoadTexture("Materials\\Developer\\bluegrid.dds"), TEXTURE_DIFFUSE);//Works delete[] buffer; auto custom_model = CreateModel(world); auto mesh = custom_model->AddMesh(); int index = 0; for (int z = 0; z < size; z++) { for (int x = 0; x < size; x++) { mesh->AddVertex(x, 0.0f, z, 0.0f, 1.0f, 0.0f, (float)x / (float)size, (float)z / (float)size); if (x != 0 && x != size - 1 && z != 0 && z != size - 1) { mesh->AddPrimitive(index, index - size - 1, index - 1); mesh->AddPrimitive(index, index - size, index - size - 1); } index++; } } custom_model->UpdateBounds(); custom_model->SetMaterial(mat); while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F2) == true) { camera->SetWireframe(!camera->GetWireframe()); } auto _displaySize = window->GetSize(); float cx = Round((float)_displaySize.x / 2.0f); float cy = Round((float)_displaySize.y / 2.0f); auto mpos = Vec3(window->GetMousePosition().x, window->GetMousePosition().y, window->GetMousePosition().z); window->SetMousePosition(cx, cy); mpos = mpos * looksmoothing + mousepos * (1 - looksmoothing); auto dx = (mpos.x - cx) * lookspeed; auto dy = (mpos.y - cy) * lookspeed; auto camrot = camera->GetRotation(); camrot.x += dy; camrot.y += dx; camera->SetRotation(camrot); mousepos = mpos; auto speed = 0.1f; if (window->KeyDown(KEY_SHIFT) == true) { speed = speed * 10.0f; } if (window->KeyDown(KEY_W) == true) { camera->Move(0, 0, speed); } else if (window->KeyDown(KEY_S) == true) { camera->Move(0, 0, -speed); } if (window->KeyDown(KEY_A) == true) { camera->Move(-speed, 0, 0); } else if (window->KeyDown(KEY_D) == true) { camera->Move(speed, 0, 0); } world->Update(); world->Render(framebuffer); } return 0; } Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted August 20, 2023 Author Share Posted August 20, 2023 Just tested an .r16 map too. It seems some of the values are being clamped. auto buffer = LoadBuffer("Terrain.r16"); auto map = CreatePixmap(256, 256, TEXTURE_R16, buffer); map->Save("Test.dds"); Terrain.zip Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted August 20, 2023 Solution Share Posted August 20, 2023 The float values can be anything, but the visible range is only within 0-1, so at first glance the results are not surprising to me. 1 Quote 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...
SpiderPig Posted August 20, 2023 Author Share Posted August 20, 2023 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.