Jump to content

reepblue

Developers
  • Posts

    2,484
  • Joined

  • Last visited

Everything posted by reepblue

  1. reepblue

    Finishing Touches

    What a wild six years this has been. I remember the first build being a. bunch of boxes in a blue void and look where it is now. Congrats on the release and it should only get better from here. Thank you for having me as part of the process through out the years! Now I'm gonna harass tell all my friends about how they should be using this instead of whatever they are currently using.
  2. Revisited my extension to generate basic materials from images and textures. This is good if you want non-game image formats part of your file blacklist. It was very helpful with the conversion script above to convert ten or so basic textures. local extension = {} function extension:CreateBlankMaterial() local defaultpath = CurrentDir().."/Materials/" local file = RequestFile("Select Material Location", defaultpath, "Ultra Engine Material File (*.mat):mat", 0, true) if file ~= nil then local mat = CreateMaterial() if mat ~= nil then mat:SetColor(1,1,1,1) local shaderfamily = LoadShaderFamily("Shaders/PBR.fam") if shaderfamily then mat:SetShaderFamily(shaderfamily) shaderfamily = nil end mat:Save(file); end end end function extension:Image2DDS(path) --Load image local pixmap = LoadPixmap(path) if pixmap==nil then Print("Error: Failed to generate texture \"" .. FixPath(output) .. "\"") return false end local mipchain = {} table.insert(mipchain,pixmap) --Generate mipmaps local w = pixmap.size.x local h = pixmap.size.y local mipmap = pixmap while (w > 4 and h > 4) do w = math.max(4, w / 2) h = math.max(4, h / 2) mipmap = mipmap:Resize(w,h) table.insert(mipchain,mipmap) end --Convert each image to BC1 (DXT1) compression for n=1, #mipchain do mipchain[n] = mipchain[n]:Convert(TEXTURE_BC1) end --Save mipchain to texture file local output = StripExt(path)..".dds" SaveTexture(output, TEXTURE_2D, mipchain, 1, SAVE_DEFAULT) return output end function extension:GenerateMaterialFromTexture() local defaultpath = CurrentDir().."/Materials/" local file = RequestFile("Select Texture", defaultpath, "Supported Files:dds,basis,png,jpg,jpeg,tga,bmp", 0) -- If we're not a texture, convert it if (ExtractExt(file) == "png" or ExtractExt(file) == "jpg" or ExtractExt(file) == "jpeg" or ExtractExt(file) == "tga" or ExtractExt(file) == "bmp") then local image = file file = extension:Image2DDS(image) end local output = StripExt(file)..".mat" if file ~= nil then local mat = CreateMaterial() if mat ~= nil then local tex = LoadTexture(file) if tex~=nil then mat:SetTexture(tex) mat:SetColor(1,1,1,1) local shaderfamily = LoadShaderFamily("Shaders/PBR.fam") if shaderfamily then mat:SetShaderFamily(shaderfamily) shaderfamily = nil end if mat:Save(output) then Print("Successfully saved \"" .. output .. "\"") end else Print("Failed to save \"" .. output .. "\" as texture is invaild!") end end mat = nil else Print("Failed to save \"" .. output .. "\" as file is invaild!") end end function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menuitem_blankmaterial then extension:CreateBlankMaterial() elseif event.source == extension.menuitem_matfromtex then extension:GenerateMaterialFromTexture() end end end -------------------------------------------------------------------- -- Add menu item -------------------------------------------------------------------- local menu = program.menu:FindChild("Scripting", false) if menu == nil then Print("Error: Could not find \"Scripting\" menu.") return end local submenu = menu:FindChild("Generate Material", false) if submenu == nil then submenu = CreateMenu("Generate Material", menu) end extension.menuitem_blankmaterial = CreateMenu("New Blank Material", submenu) extension.menuitem_matfromtex = CreateMenu("New Material From Texture/Image", submenu) ListenEvent(EVENT_WIDGETACTION, extension.menuitem_blankmaterial, extension.hook, extension) ListenEvent(EVENT_WIDGETACTION, extension.menuitem_matfromtex, extension.hook, extension)
  3. It works better as a converter. Works exactly how Leadwerks behaves. I understand the reason for texture creation for being manual since DDS doesn't cover all needs. local converter = {} converter.informat = "png" converter.outformat = "dds" function converter:Convert(path, output) --Load image local pixmap = LoadPixmap(path) if pixmap==nil then Print("Error: Failed to generate texture " ..path) return false end local mipchain = {} table.insert(mipchain,pixmap) --Generate mipmaps local w = pixmap.size.x local h = pixmap.size.y local mipmap = pixmap while (w > 4 and h > 4) do w = math.max(4, w / 2) h = math.max(4, h / 2) mipmap = mipmap:Resize(w,h) table.insert(mipchain,mipmap) end --Convert each image to BC1 (DXT1) compression for n=1, #mipchain do mipchain[n] = mipchain[n]:Convert(TEXTURE_BC1) end --Save mipchain to texture file SaveTexture(output, TEXTURE_2D, mipchain, 1, SAVE_DEFAULT) return true end program:AddConverter(converter)
  4. I guess I'm just so used making textures in Leadwerks. That makes my life easier! Code is still useful regardless.
  5. Everytime I right click on a PNG image to generate a material, it creates the DDS and a normal map. I just want to simply convert the image to a texture.
  6. It seems I can't generate a texture without the editor also making a normal map for each texture which I do not want. I decided to make an extension that would convert the image to a DDS using the code found below. But I'm now getting the "Mipchain contains mipmaps with dimensions smaller than the format's block size" error. How would I fix my code? local extension = {} function CreateNewMaterial() local defaultpath = CurrentDir().."Materials/" local file = RequestFile("Select Material Location", defaultpath, "Ultra Engine Material File (*.mat):mat", 0, true) if file ~= nil then local mat = CreateMaterial() if mat ~= nil then mat:SetColor(1,1,1,1) local shaderfamily = LoadShaderFamily("Shaders/PBR.fam") if shaderfamily then mat:SetShaderFamily(shaderfamily) shaderfamily = nil end mat:Save(file); end end end function GenerateTexture() local defaultpath = CurrentDir().."Materials/" local file = RequestFile("Select Image", defaultpath, "Image:png,tga,jpg,jpeg,bmp", 0, false) --Load image local pixmap = LoadPixmap(file) if pixmap==nil then Print("Error: Failed to generate texture " ..file) return end local mipchain = {} table.insert(mipchain,pixmap) --Generate mipmaps local w = pixmap.size.x local h = pixmap.size.y local mipmap = pixmap while (w > 1 and h > 1) do w = math.max(1, w / 2) h = math.max(1, h / 2) mipmap = mipmap:Resize(w,h) table.insert(mipchain,mipmap) end --Convert each image to BC7 compression for n=1, #mipchain do mipchain[n] = mipchain[n]:Convert(TEXTURE_BC7) end --Save mipchain to texture file local output = StripExt(file)..".dds" SaveTexture(output, TEXTURE_2D, mipchain, 1, SAVE_DEFAULT) end function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menuitem_newmaterial then CreateNewMaterial() elseif event.source == extension.menuitem_newDDS then GenerateTexture() end end end -------------------------------------------------------------------- -- Add menu item -------------------------------------------------------------------- local menu = program.menu:FindChild("Scripting", false) if menu == nil then Print("Error: Could not find \"Scripting\" menu.") return end local submenu = menu:FindChild("Utilities", false) if submenu == nil then submenu = CreateMenu("Utilities", menu) end extension.menuitem_newmaterial = CreateMenu("Create blank material", submenu) extension.menuitem_newDDS = CreateMenu("Convert image to DDS", submenu) ListenEvent(EVENT_WIDGETACTION, extension.menuitem_newmaterial, extension.hook, extension) ListenEvent(EVENT_WIDGETACTION, extension.menuitem_newDDS, extension.hook, extension)
  7. I've noticed that if you jump into a wall, the velocity distributes into forward movement. However, this makes climbing the stack of boxes in the start map difficult as I keep falling off. I think the player physics needs to be tweaked so I can climb the boxes while the controller still feeling natural.
  8. I think the probe models are being baked in the cubemaps similar to how the editor icons were. This is the default start map looking at the reflection of the crate model.
  9. To be honest, I had no luck using that tool. I accidentally copied over my Cyclone fbx files and it just made a bunch of useless garbage. I have better luck exporting as a gltf right out of blender.
  10. Pulled an update just now, and now it works. 🤷
  11. Broken again. Also, the DDS conversion isn't working.
  12. I think this was caused by the fix discussed here. As of writing, trying to delete any model from the map will cause an "Cannot delete Model Limbs" error when the model has no limbs to begin with.
  13. It seems to me with a little elbow grease, this can be converted into a tool in which an extension can be written to use to generate hdr cubemaps.
  14. I know if you look at any cubemaps texture in the Asset Browser it's also black despite it working in the world renderer. Did you try Setting the background to your generated cubemap?
  15. Read your compile errors. Simply looking at your code, you need to define texrture0. Not a shader expert, but I made my shaders by trial and error.
  16. Understandable. I'll await for it's return.
  17. Hmm, this does solve my problem of identifying what is level geometry and what is a decorative model. I can just use the As<Brush>() cast. I guess if brush collapsing returns, please put back the public "collapsedbrush" bool or something like you had in Leadwerks. I also want to mention that when I loaded my save file with Map::Load(), I noticed my materials lost their normal maps. These kinds of things are hard to write examples for as it requires a lot of code and assets to showcase the problem. Maybe it's a side effect from the same problem here.
  18. Every easy to recreate, just hard to notice without any shiny materials unless you look at the probe directly.
  19. Top one is from the Asset browser, correct. Sorry for not making that clear. The bottom screen is from the Map Tab.
  20. Found a new bug with the Save/Load system. I think the brushes are being re-created. This example has a transparent material in the scene, and it gets opaquer after each reload. Load the map, Press F5, and then press F6 to see the results. #include "UltraEngine.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); //Load scene auto scene = LoadMap(world, "Maps/savetest3.ultra"); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { if (window->KeyHit(KEY_F5)) { //Save the starting scene to a file scene->Save("game.sav"); } //Reload the starting scene when space key is pressed if (window->KeyHit(KEY_F6)) { scene->Reload("game.sav"); } world->Update(); world->Render(framebuffer); } return 0; } SaveTest3.zip
  21. Diffrent problem, but related. When the sound is resumed, it starts from the beginning. Replace the sound with the one attached. radio_dreamlandloop_mono.zip
  22. In the asset browser, I can't seem to change the Collision Type or gravity settings for a gltf+bin model. Might be a carry over from a previous bug. Also, for appearance, it's missing the "Static Reflection" option. Checked items are marked as False on the Map panel. I'll report more when I find them...
  23. Pausing/Resuming speakers aren't working as expected. #include "UltraEngine.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->Listen(); //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); //Sound auto sound = LoadSound("https://raw.githubusercontent.com/UltraEngine/Documentation/master/Assets/Sound/notification.wav"); auto speaker = CreateSpeaker(sound); speaker->SetPosition(box->GetPosition(true)); speaker->SetRange(10); auto speakerloop = CreateSpeaker(sound); speakerloop->SetPosition(box->GetPosition(true)); speakerloop->SetRange(10); speakerloop->SetLooping(true); auto speakerstate = speaker->GetState(); auto speakerloopstate = speakerloop->GetState(); bool paused = false; //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { // P Plays the normal non-looping speaker if (window->KeyHit(KEY_P)) { speaker->Play(); } // L Plays the looping speaker if (window->KeyHit(KEY_L)) { speakerloop->Play(); } // Space pauses both speakers if (window->KeyHit(KEY_SPACE)) { if (!paused) { speaker->Pause(); speakerloop->Pause(); paused = true; } else { speaker->Resume(); speakerloop->Resume(); paused = false; } } // Report the state if (speaker->GetState() != speakerstate) { Print("Normal Speaker state at: " + String(speaker->GetState())); speakerstate = speaker->GetState(); } if (speakerloop->GetState() != speakerloopstate) { Print("Looping Speaker state at: " + String(speakerloop->GetState())); speakerloopstate = speakerloop->GetState(); } //Move and turn with the arrow keys - best experienced with headphones if (window->KeyDown(KEY_UP)) camera->Move(0, 0, 0.1); if (window->KeyDown(KEY_DOWN)) camera->Move(0, 0, -0.1); if (window->KeyDown(KEY_LEFT)) camera->Turn(0, -1, 0); if (window->KeyDown(KEY_RIGHT)) camera->Turn(0, 1, -0); world->Update(); world->Render(framebuffer); } return 0; } Right now, I have to do this hack in my project. void GameSpeaker::Pause() { if (speaker) { if (speaker->GetState() == SPEAKER_PLAYING) { pausetime = speaker->GetTime(); speaker->Pause(); } } } void GameSpeaker::Resume() { if (speaker) { if (speaker->GetState() == SPEAKER_PAUSED || pausetime > 0) { speaker->SetTime(pausetime); speaker->Play(); pausetime = 0; } } }
  24. I'm trying to make an editor extension that'll create new files from the editor. I'm working on a "Create New Material" function, but I get an error with the Save command saying it expects usedata type and not a string, although I feel like this code is correct. local extension = {} function CreateNewMaterial() local file = RequestFile("Select Material Location", "", "Ultra Engine Material File (*.mat):mat", 0, true) if file ~= nil then local mat = CreateMaterial() if mat ~= nil then mat:SetColor(1,1,1,1) local shaderfamily = LoadShaderFamily("Shaders/PBR.fam") if shaderfamily then mat:SetShaderFamily(shaderfamily) shaderfamily = nil end mat:Save(file); end end end function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menuitem then CreateNewMaterial() end end end -------------------------------------------------------------------- -- Add menu item -------------------------------------------------------------------- local menu = program.menu:FindChild("Create", false) if menu ~= nil then local submenu = menu:FindChild("Asset", false) if submenu == nil then submenu = CreateMenu("Asset", menu) end extension.menuitem = CreateMenu("Material", submenu) end ListenEvent(EVENT_WIDGETACTION, extension.menuitem, extension.hook, extension) I also tried making a table and saving it, but it didn't work ether. local a = ctable() a["material"] = nil a["material"]["shaderFamily"] = "Shaders/PBR.fam" SaveTable(a, file) What am I doing wrong here?
  25. Old attachment but this demonstrates that the components are no longer being loaded although it's registered. savetest2.zip
×
×
  • Create New...