I'm Julien
julienkay / com.doji.genesis Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Both AssetImporter.GetAtPath()s are returning null in the DepthSkyboxPrefabUtility.cs
The error is below; the debug.log is mine for the pngTargetPath
I believe the target path should be inside Assets/Genesis (just a guess), instead of:
Then again I'm using OSX, I guess its the path difference wrt windows: / vs \
Hi, Julien, your work is so impressive and enlightening!
I wonder if I can load texture in game mode? Currently, I am enable to load texture from the path outside unity asset folders, while when I failed to load any depth image to be the _DepthMap texture. I am sure that the depth image can be dragged to the DepthMap slot in editor mode, could you be so kind to help me find out what to process? Thanks a lot!!!
this is the code I used to load external textures:
using UnityEngine;
using System.Collections;
using System.IO;
using System.Linq;
public class TextureLoader : MonoBehaviour
{
public Material targetMaterial;
private string externalFolderPath = ...
void Start()
{
StartCoroutine(UpdateTextures());
}
private bool IsFileReady(string filename)
{
try
{
using (FileStream inputStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return inputStream.Length > 0;
}
}
catch (IOException)
{
return false;
}
}
private IEnumerator UpdateTextures()
{
while (true)
{
string latestColorTexturePath = FindLatestFile(externalFolderPath, "Color_*.png");
string latestDepthTexturePath = FindLatestFile(externalFolderPath, "Depth_*.png");
if (!string.IsNullOrEmpty(latestColorTexturePath) && IsFileReady(latestColorTexturePath))
{
Texture2D colorTexture = LoadTextureFromFile(latestColorTexturePath);
targetMaterial.SetTexture("_MainTex", colorTexture);
}
if (!string.IsNullOrEmpty(latestDepthTexturePath) && IsFileReady(latestDepthTexturePath))
{
Texture2D depthTexture = LoadTextureFromFile(latestDepthTexturePath);
targetMaterial.SetTexture("_DepthMap", depthTexture);
}
yield return new WaitForSeconds(1);
}
}
private string FindLatestFile(string folderPath, string searchPattern)
{
var directoryInfo = new DirectoryInfo(folderPath);
var latestFile = directoryInfo.GetFiles(searchPattern).OrderByDescending(f => f.LastWriteTime).FirstOrDefault();
return latestFile?.FullName;
}
private Texture2D LoadTextureFromFile(string filePath)
{
if (File.Exists(filePath))
{
byte[] fileData = File.ReadAllBytes(filePath);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(fileData);
return texture;
}
else
{
Debug.LogError("File not found at: " + filePath);
return null;
}
}
}
This repo is up to date with the current API: https://github.com/CatDarkGame/AISkyboxGenerator
Now that Blockadelabs provide depth maps, so how to use depth Maps provided by them.
It would be nice to have an option to use either of the depth maps.
It would be great to add license information
Packages\com.doji.genesis\Runtime\Scripts\DepthEstimator.cs(9,23): error CS0246: The type or namespace name 'NNModel' could not be found (are you missing a using directive or an assembly reference?)
Can you please add a license to the project
Hi, Julien, your work is so impressive and enlightening!
I wonder if I can load depth texture in game mode? The depth png texture is generated using leres method. Currently, I am enable to load color texture from the path outside unity asset folders, while when I failed to load any depth image to be the _DepthMap texture. I am sure that the depth image can be dragged to the DepthMap slot in editor mode, could you be so kind to help me find out what to process? Thanks a lot!!!
this is the code I used to load external textures:
using UnityEngine;
using System.Collections;
using System.IO;
using System.Linq;
public class TextureLoader : MonoBehaviour
{
public Material targetMaterial;
private string externalFolderPath = ...
void Start()
{
StartCoroutine(UpdateTextures());
}
private bool IsFileReady(string filename)
{
try
{
using (FileStream inputStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
return inputStream.Length > 0;
}
}
catch (IOException)
{
return false;
}
}
private IEnumerator UpdateTextures()
{
while (true)
{
string latestColorTexturePath = FindLatestFile(externalFolderPath, "Color_*.png");
string latestDepthTexturePath = FindLatestFile(externalFolderPath, "Depth_*.png");
if (!string.IsNullOrEmpty(latestColorTexturePath) && IsFileReady(latestColorTexturePath))
{
Texture2D colorTexture = LoadTextureFromFile(latestColorTexturePath);
targetMaterial.SetTexture("_MainTex", colorTexture);
}
if (!string.IsNullOrEmpty(latestDepthTexturePath) && IsFileReady(latestDepthTexturePath))
{
Texture2D depthTexture = LoadTextureFromFile(latestDepthTexturePath);
targetMaterial.SetTexture("_DepthMap", depthTexture);
}
yield return new WaitForSeconds(1);
}
}
private string FindLatestFile(string folderPath, string searchPattern)
{
var directoryInfo = new DirectoryInfo(folderPath);
var latestFile = directoryInfo.GetFiles(searchPattern).OrderByDescending(f => f.LastWriteTime).FirstOrDefault();
return latestFile?.FullName;
}
private Texture2D LoadTextureFromFile(string filePath)
{
if (File.Exists(filePath))
{
byte[] fileData = File.ReadAllBytes(filePath);
Texture2D texture = new Texture2D(2, 2);
texture.LoadImage(fileData);
return texture;
}
else
{
Debug.LogError("File not found at: " + filePath);
return null;
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.