Jump to content

reepblue

Developers
  • Posts

    2,600
  • Joined

  • Last visited

Everything posted by reepblue

  1. These are the logic components planned to ship with the planned FPS template. These are still considered a work in progress and subject to change. At this time, there's no Lua variants. These components and more will be documented and have examples in the future. Feel free to report any issues or suggestions! Logic.zip
  2. That's how normal maps should look. The yellowing is due to BC5 compression. All normals should look like that as a game texture.
  3. You need to generate the mipmaps and the compression needs to be BC5. Replace the bottom with this. auto dest = CreatePixmap(src->size.x, src->size.y, src->format); SobelFilter((uint8_t*)dest->pixels->Data(), (uint8_t*)src->pixels->Data(), src->size.x, src->size.y, 32); //dest->Save(StripExt(filePath) + "_normal.dds"); //Build mipmap chain auto mipchain = dest->BuildMipchain(); auto ddsformat = TEXTURE_BC5; auto blocksize = 4; auto count = mipchain.size(); auto block = dest->blocksize; if (ddsformat != 0) { std::vector<shared_ptr<Pixmap>> mipchain2; for (int i = 0; i < count; i++) { if (mipchain[i]->size.x < blocksize or mipchain[i]->size.y < blocksize) break; else { mipchain2.push_back(mipchain[i]->Convert(ddsformat)); if (mipchain2[i] == NULL) { Print("Error: Failed to convert \"" + path + "\" to format " + String(ddsformat)); } } } mipchain = mipchain2; } SaveTexture(StripExt(filePath) + "_normal.dds", TEXTURE_2D, mipchain);
  4. Quick patch: local extension = {} extension.currentsuffix = "" extension.suffix = "metalroughness" function extension.IsSpecMap(file) if file == nil then return false end if FileType(file) == 0 then return false end -- Check the file extention, make sure it's an image. local ext = ExtractExt(string.lower(file)) if ext ~= "tga" and ext ~= "png" and ext ~= "jpg" and ext ~= "bmp" then return false end -- Check to see if the file has a specular suffix at the end if Right(StripExt(file), 8) == string.lower("specular") then extension.currentsuffix = string.lower("specular") elseif Right(StripExt(file), 4) == string.lower("spec") then extension.currentsuffix = string.lower("spec") elseif Right(StripExt(file), 1) == string.lower("s") then extension.currentsuffix = string.lower("s") else extension.currentsuffix = "" return false end -- Return true if all conditions met! return true end function extension.StorePixelsInChannel(src, dst, channel) if src then local sz = src.size if src.blocksize ~= 1 then src = src:Convert(TEXTURE_RGBA) if src == nil then Print("Error: Failed to convert pixmap format") return false end end if src.size ~= sz then src = src:Resize(sz.x, sz.y) end if not src:CopyChannel(channel, dst, channel) then Print("Error: Pixmap:CopyChannel failed on channel "..tostring(n)) end end end function extension.ConvertSpecToMetalRoughness(file) local pixmap = LoadPixmap(file) if pixmap==nil then Print("Error: Failed to generate texture \"" .. file .. "\"") return false end if pixmap.blocksize ~= 1 then pixmap = pixmap:Convert(TEXTURE_RGBA) end -- Define the channels local roughnesschannel = 2 -- Green local specchannel = 3 -- blue local dst = CreatePixmap(pixmap.size.x, pixmap.size.x) dst:Fill(Rgba(0,0,0,255)) -- Store the spec in the blue channel. extension.StorePixelsInChannel(pixmap, dst, specchannel) -- Roughness is the specular but we invert the colors. (This is also really slow) local roughness = CreatePixmap(pixmap.size.x, pixmap.size.y) roughness:Fill(Rgba(0,0,0,255)) Print("Swapping colors from the specular map. This might take a while...") for x = 0, pixmap.size.x - 1 do for y = 0, pixmap.size.y - 1 do local rgba = pixmap:ReadPixel(x, y) local r = 255-Red(rgba) local g = 255-Green(rgba) local b = 255-Blue(rgba) rgba = Rgba(r, g, b, 255) roughness:WritePixel(x, y, rgba) end end extension.StorePixelsInChannel(roughness, dst, roughnesschannel) roughness = nil -- Save as a DDS texture local d = StripExt(file) local name = Left(d, Len(d) - Len(extension.currentsuffix)) local output = name .. extension.suffix .. ".dds" --Build mipmap chain local mipchain = dst:BuildMipchain() local ddsformat = TEXTURE_BC7--Everything else local blocksize = 4 local count = #mipchain local block = dst.blocksize --Convert to desired compression format if ddsformat ~= 0 then local mipchain2 = {} local n for n = 1, #mipchain do if mipchain[n].size.x < blocksize or mipchain[n].size.y < blocksize then break else mipchain2[n] = mipchain[n]:Convert(ddsformat) if mipchain2[n] == nil then Print("Error: Failed to convert \""..path.."\" to format "..tostring(ddsformat)) return false end end end mipchain = mipchain2 end --Save the texture return SaveTexture(output, TEXTURE_2D, mipchain) end function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menu[1] then if program.assetbrowser.selectedfile then if program.assetbrowser.selectedfile.package == nil then Print("Converting \""..StripDir(program.assetbrowser.selectedfile.path).."\"") if extension.ConvertSpecToMetalRoughness(program.assetbrowser.selectedfile.path) then extension.currentsuffix = "" Print("Done!") end collectgarbage() end end end elseif event.id == EVENT_WIDGETOPEN then if event.source == program.assetbrowser.filepopupmenu then --Hide the menu items if they exist if extension.menu ~= nil then extension.menu[1]:SetHidden(true) extension.menu[2]:SetHidden(true) end if program.assetbrowser.selectedfile then if program.assetbrowser.selectedfile.package == nil then if extension.IsSpecMap(program.assetbrowser.selectedfile.path) then --Create menu items if needed if extension.menu == nil then widget = Widget(event.source) extension.menu = {} extension.menu[1] = CreateMenu("Convert Specular to Metal-Roughness", widget) extension.menu[2] = CreateMenu("", widget) extension.menu[2]:SetParent(widget, 0) extension.menu[1]:SetParent(widget, 0) ListenEvent(EVENT_WIDGETACTION, extension.menu[1], extension.hook, extension) end --Show the menu item and divider extension.menu[1]:SetHidden(false) extension.menu[2]:SetHidden(false) end end end end end end ListenEvent(EVENT_WIDGETOPEN, program.assetbrowser.filepopupmenu, extension.hook, extension)
  5. That seems to fix it for the most part, but the concrete wall is still not the same unless I change the roughness down to 0.989. I'm noticing some flickering with what I've sent.
  6. It seems with the new beta, the light doesn't affect materials like it used to. 0.9.8b 0.9.8
  7. This demo shows projection issues in 0.9.8. VRTest.7z
  8. I brought this up with you last week and you've told me that it has to do with e scene loading code, and render layers, but it still isn't fixed. So I'm making this a bug report as a gentle reminder.
  9. I think a better option is to save out the calculation in a binary file and be able to load them instead of having them in memory at all times.
  10. This extension is for those who have existing materials that were made for the Blinn-Phong shading (diffuse+normal+specular) such as the textures for Leadwerks. Right click on an image with a specular suffix in the name and a "Convert Specular to Metal-Roughness" option will show up. This will take the spec sheet, insert the existing pixels in the blue channel, then swap the pixels and store that copy into the green channel. (This seems to take a bit) The result will be a blue and green texture. In your material, you then can use the Metalness and Roughness spinners to adjust the values. I find setting the Metalness to 0.1 is what you want for most non-metal textures to mimic the specular effect. For things that are metal, well that's up to you to tweak and find out. It really helps if you know how the material should look. The only thing you might need to consider is any roughness map you've made if you came from Leadwerks. That mask wasn't really conventional, and you may want to look into packing that yourself with the Channel Packing Tool to get the desired look. SpecMapToMetalRoughness.lua
  11. I am now running into this issue in my map where the models don't render on map load unless I first highlight them. This is the start map in the XFORM project.
  12. "environment": { "ambientlight": [ 0.0, 0.0, 0.0 ], "diffusereflection": { "path": "Materials/Environment/Default/diffuse.dds" }, "effects": [ { "path": "C:/Users/username/Documents/GitHub/XFORM/Effects/SSAO.fx" }, { "path": "C:/Users/username/Documents/GitHub/XFORM/Effects/Bloom.fx" } ], If you ship the game, post effects will be broken since the developer's hard path is saved,
  13. You can retrieve the framebuffer from the active window.
  14. Build and launch the release build of XFORM.
  15. A "Change/Load Theme" option would be nice. Also, Here's how my old "Midnight" theme looks.
  16. There should be a simpler way to do this!
  17. Dumb question but are you using the VRPlayer component?
  18. I've had this happen to me and it looks like you beat me to reporting this.
  19. I was working on a catapult trigger last week and it wasn't working for some reason. Made a new test component and seemed to work ok. I'll mark this as "solved" for right now but if I have any issues, I'll be sure to let you know.
  20. The properties highlighted don't seem to get saved, Friction is written, but never updated to reflect the fields. There are no Damping, gravity, elasticity nor buoyancy values! { "castshadows": true, "collisiontype": 1, "components": {}, "decallayers": 1, "extras": {}, "friction": [ 0.5, 0.8999999761581421 ], "group": "2344763719232", "mass": 5.0, "matrix": [ "0x3f6803ca", "0x0", "0xbed86168", "0x0", "0x0", "0x3f800000", "0x0", "0x0", "0x3ed86168", "0x0", "0x3f6803ca", "0x0", "0x411c28f6", "0x3ef5c278", "0x40ccccce", "0x3f800000" ], "model": { "islimb": false, "path": "Models/ExampleContent/WeightedBox.mdl" }, "name": "weightedbox", "physicsmode": 1, "pickmode": 1, "position": [ "0x411c28f6", "0x3ef5c278", "0x40ccccce" ], "quaternion": [ "0x80000000", "0xbe5da255", "0x80000000", "0x3f79ee89" ], "reflection": true, "rotation": [ "0x80000000", "0x41c7fffd", "0x0" ], "scale": [ "0x3f800000", "0x3f800000", "0x3f800000" ], "uuid": "5cf9e831-0f12-404b-bc87-50c8f490ac79" },
  21. The target property doesn't get in the map file when assigned. If you replace this with a normal string field and manually enter the uuid, the code will work fine. You can step through this. component.zip
  22. The following collision types that aren't exposes to lua from my testing. COLLISION_DEBRIS COLLISION_PROJECTILE Ultra Engine - Best game engine for VR optimized for fastest virtual reality 3D performance --Initialze Steam (optional) --if not Steamworks.Initialize() then return 1 end --Load FreeImage plugin (optional) local fiplugin = LoadPlugin("Plugins/FITextureLoader") --Get the displays local displays = GetDisplays() --Create a window local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_CENTER | WINDOW_TITLEBAR) --Create a framebuffer local framebuffer = CreateFramebuffer(window) --Create a world local world = CreateWorld() --Load a map local mapname = "Maps/start.ultra" local cl = CommandLine() if type(cl["map"]) == "string" then mapname = cl["map"] end local scene = LoadMap(world, mapname) local box = CreateBox(world) box:SetCollisionType(COLLISION_DEBRIS) while window:Closed() == false do --Garbage collection step collectgarbage() --Update the world world:Update() Steamworks.Update() --Render the world to the framebuffer world:Render(framebuffer) end Steamworks.Shutdown()
×
×
  • Create New...