-
Posts
24,629 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Josh
-
Example: local json = require 'System/dkjson' local s = FetchUrl("https://ambientcg.com/api/v2/categories_json") local t = json.decode(s) if type(t) == "table" then local n for n = 1, #t do if (type(t[n]) == "table") then if type(t[n]["categoryName"]) == "string" then Print(t[n]["categoryName"]) end end end end Download and extract: DownloadFile("https://ambientcg.com/get?file=PavingStones137_1K-JPG.zip", GetPath(PATH_DESKTOP).."/test.zip" ) local pak = LoadPackage(GetPath(PATH_DESKTOP).."/test.zip") if pak then local dir = pak:LoadDir("") local n for n = 1, #dir do if pak:FileType(dir[n]) == 1 then pak:ExtractFile(dir[n], GetPath(PATH_DESKTOP).."/"..dir[n]) end end pak:Close() end
-
AmbientCG has about 3000 PBR materials and a simple REST web API. List categories: https://ambientcg.com/api/v2/categories_json List files in category: https://ambientcg.com/api/v2/full_json?include=imageData,downloadData&category=PavingStones These URLs can be loaded with FetchURL. There is a JSON parsing library included in the Scripts/System folder, dkjson.lua. This is used by the debugger. I have not used it myself for anything. More docs here: https://docs.ambientcg.com/api/v2/
-
Sorry about that. This will work now in build 246: mdl = LoadModel(nil, "models/developer/crate/crate.gltf") program:OpenAsset(mdl.base) Alternatively, you can just do this: program:OpenAsset("models/developer/crate/crate.gltf")
-
End of File and seek position outside of file bounds
Josh replied to CJO Games's topic in Bug Reports
I added some code in the FBX convert script that loads the glTF file as JSON data, changes the name and location of the bin file, and resaves it. This fixes the problem and allows use of .gltf rather than .glb. -
Editor API additions: program:BuildGI() program.assetbrowser:SelectFolder(path) program.assetbrowser:SelectFile(path) Example: program.assetbrowser:SelectFile("materials/developer/grid01.mat") local i = program.sidepanel:FindItem("Project") if i ~= 0 then program.sidepanel:SelectItem(i) EmitEvent(EVENT_WIDGETSELECT, program.sidepanel, i) end
-
model.base is now added to the Lua API and can be used as the asset to open a model.
-
This code treats the glTF file as JSON data, finds material textures, and converts them to the correct DDS format, and resaves the JSON data. This is very cool because it does not actually load a model, so glTF textures can be converted to DDS with no other changes. function CompressTexture(path, format) local k local pixmap = LoadPixmap(path) if pixmap == nil then return end local out = StripExt(path)..".dds" local chain2 = {} local mipchain = pixmap:BuildMipchain() if format == TEXTURE_BC7 or format == TEXTURE_BC6H or format == TEXTURE_BC5 or format == TEXTURE_BC4 then for k = 1, #mipchain do if mipchain[k].size.x < 4 or mipchain[k].size.y < 4 then break end if mipchain[k].format ~= format then mipchain[k] = mipchain[k]:Convert(format) end table.insert(chain2, mipchain[k]) end else chain2 = mipchain-- this might not work yet end return SaveTexture(out, TEXTURE_2D, chain2) end function glTFCompressTextures(path) local n, k local dir = ExtractDir(path) if dir ~= "" then dir = dir.."/" end --Load glTF as JSON data local t = LoadTable(path) if type(t) ~= "table" then return false end --Check for DDS extension if type(t["extensionsUsed"]) == "table" then for n = 1, #t["extensionsUsed"] do if type(t["extensionsUsed"][n]) == "string" then if t["extensionsUsed"][n] == "MSFT_texture_dds" then return false-- DDS textures already exist so return end end end else t["extensionsUsed"] = {} end table.insert(t["extensionsUsed"], "MSFT_texture_dds") if type(t["materials"]) ~= "table" then return false-- glTF file contains no materials end for n = 1, #t["materials"] do --Convert normal maps to BC5 DDS if type(t["materials"][n]["normalTexture"]) == "table" then if type(t["materials"][n]["normalTexture"]["index"]) == "number" then local textureindex = t["materials"][n]["normalTexture"]["index"] local imageindex = t["textures"][textureindex + 1]["source"] local imagefile = t["images"][imageindex + 1]["uri"] CompressTexture(dir..imagefile, TEXTURE_BC5) end end --Convert emissive texture to BC7 if type(t["materials"][n]["emissiveTexture"]) == "table" then if type(t["materials"][n]["emissiveTexture"]["index"]) == "number" then local textureindex = t["materials"][n]["emissiveTexture"]["index"] local imageindex = t["textures"][textureindex + 1]["source"] local imagefile = t["images"][imageindex + 1]["uri"] CompressTexture(dir..imagefile, TEXTURE_BC7) end end if type(t["materials"][n]["pbrMetallicRoughness"]) == "table" then --Convert base texture to BC7 if type(t["materials"][n]["pbrMetallicRoughness"]["baseColorTexture"]) == "table" then if type(t["materials"][n]["pbrMetallicRoughness"]["baseColorTexture"]["index"]) == "number" then local textureindex = t["materials"][n]["pbrMetallicRoughness"]["baseColorTexture"]["index"] local imageindex = t["textures"][textureindex + 1]["source"] local imagefile = t["images"][imageindex + 1]["uri"] CompressTexture(dir..imagefile, TEXTURE_BC7) end end local metalroughnesstextureindex = -1 --Convert metal/roughness texture to BC7 if type(t["materials"][n]["pbrMetallicRoughness"]["metallicRoughnessTexture"]) == "table" then if type(t["materials"][n]["pbrMetallicRoughness"]["metallicRoughnessTexture"]["index"]) == "number" then local textureindex = t["materials"][n]["pbrMetallicRoughness"]["metallicRoughnessTexture"]["index"] local imageindex = t["textures"][textureindex + 1]["source"] local imagefile = t["images"][imageindex + 1]["uri"] CompressTexture(dir..imagefile, TEXTURE_BC7) metalroughnesstextureindex = textureindex end end --Convert AO texture to BC4, unless it is merged with metal/roughness texture if type(t["materials"][n]["pbrMetallicRoughness"]["occlusionTexture"]) == "table" then if type(t["materials"][n]["pbrMetallicRoughness"]["occlusionTexture"]["index"]) == "number" then local textureindex = t["materials"][n]["pbrMetallicRoughness"]["occlusionTexture"]["index"] if textureindex ~= metalroughnesstextureindex then local imageindex = t["textures"][textureindex + 1]["source"] local imagefile = t["images"][imageindex + 1]["uri"] CompressTexture(dir..imagefile, TEXTURE_BC4) end end end end end --Add DDS images into image list local imagecount = #t["images"] for n = 1, imagecount do local imagefile = t["images"][n]["uri"] local ddsimg = {} ddsimg["uri"] = StripExt(imagefile)..".dds" table.insert(t["images"], ddsimg) end --Add DDS images to textures for n = 1, #t["textures"] do if type(t["textures"][n]["extensions"]) ~= "table" then t["textures"][n]["extensions"] = {} end t["textures"][n]["extensions"]["MSFT_texture_dds"] = {} t["textures"][n]["extensions"]["MSFT_texture_dds"]["source"] = imagecount + n - 1 end --Save JSON data as glTF --return SaveTable(t, StripExt(path).."_out.gltf") return SaveTable(t, path) end --test --glTFCompressTextures("models/gltf/boombox.gltf")
-
Added a non-blocking ASyncDownloadFile() function (in Lua, in the editor) Syntax ASyncDownloadFile(url, localpath) Returns a ASyncDownoadInfo object that has the following methods: GetStatus(): returns DOWNLOAD_FINISHED, DOWNLOAD_FAILED, or DOWNLOAD_INPROGRESS GetProgress(): returns the percentage progress complete. These commands can all be called from the main thread at any time. I suggest creating a timer that updates every 500 or 1000 milliseconds and calls GetProgress() to display the download's progress in a status bar. It's fine to have multiple downloads running at the same time. Each one will get its own thread. Also added some missing Lua bindings for Model:GetBase(), which returns a ModelBase object, which is derived from the Asset class. This object can be opened in the asset editor to display a model.
-
Okay, it's fixed now, for real.
-
This appears to be working correctly. You can just paste it in the console: mtl = LoadMaterial("Materials/Developer/grid01.mat") mtl:Save("Materials/Developer/test.mat") I will try it with a subfolder now like you are using....
-
How else would it work? Multiple asset windows can be opened, and they are never empty. The Model.base member is a class that is an asset, though I am not sure if it is exposed to Lua. I don't see it in the documentation...
-
Thank you I did not see this.
-
The camera drawing system is flexible enough you can do this without any special feature to support it. Render to a 1920x1080 texture buffer. Apply the texture to a material on a sprite that is placed in front of a camera with orthogonal projection. Take victory lap because you just won. This is exactly the steps any built-in window scaling feature would do, but you have exact control over it. If you wanted to get even fancier, it would be completely possible to render any GUI or HUD after this, with no downsampling, so those elements would be crisp and clear on top of the lower-res 3D render. The Interface class has a SetScale command which can be used to scale up the size of a GUI to match the window display scale setting.
-
Editor is updated (build 216)
-
The face tool allows you to adjust CSG face texture mapping.
-
Drag materials onto models in the viewports has been disabled.
-
You can retexture the models in the asset window and then save the model in glTF format.
-
Fixed.
-
Ooooh, I don't think it is good to drag materials onto models and expect them to work, but I will check anyways. Either drag and drop materials onto instanced models should be disabled, or there should be a way to override the material in the map file. I think this is a case of a situation that hasn't been fully accounted for...
-
Okay, so that is a Leadwerks map you loaded, and it is trying to load MDL and TEX files?
-
Did you load the FreeImage texture plugin?
-
Okay, I believe those cases are resolved now.
-
You don't ever need to compile shaders yourself. The shader binary files are provided in the /Shaders folder. The shader source code files are just there for customization.
-
Strange Artifacts in viewport and in game on blank starter template.
Josh replied to JetBrains's topic in Bug Reports
Currently I am waiting on a response from AMD. Sorry, I put a note about this on the purchase page and tried to make it clear that AMD is not fully supported yet. -
Strange Artifacts in viewport and in game on blank starter template.
Josh replied to JetBrains's topic in Bug Reports
First reported here: