Code Monkey home page Code Monkey logo

com.doji.genesis's Introduction

Hey! ๐Ÿ‘‹

I'm Julien

For enquiries, reach out on LinkedIn or over on Twitter.

Become a Patron! ย ย  Buy Me a Coffee at ko-fi.com

com.doji.genesis's People

Contributors

julienkay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

com.doji.genesis's Issues

AssetImporter null error (OSX)

Both AssetImporter.GetAtPath()s are returning null in the DepthSkyboxPrefabUtility.cs

The error is below; the debug.log is mine for the pngTargetPath

Screen Shot 2023-02-24 at 1 39 26 PM

I believe the target path should be inside Assets/Genesis (just a guess), instead of:

Screen Shot 2023-02-24 at 1 43 34 PM

Then again I'm using OSX, I guess its the path difference wrt windows: / vs \

Reload Texture in Game Mode

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;
        }
    }
}
 

Errors after initial installation

I'm using the editor 2021.3.19f1 with built-in render pipeline as well, but getting the following errors right after package import.. I cant see a Genesis tab in menu, probably because of this?

Screen Shot 2023-02-24 at 11 28 53 AM

genesis import error in unity

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?)

Reload Texture in Game Mode

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;
        }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.