Giter VIP home page Giter VIP logo

inochi2d's Introduction

日本語

Inochi2D

Support me on Patreon Discord

Inochi2D is a library for realtime 2D puppet animation and the reference implementation of the Inochi2D Puppet standard.

Currently this library and the standard is in the prototype stage and is not recommended for production use.
If you want to try it out anyways you can clone this repo and run dub add-local (inochi2d folder) "1.0.0" then manually add it as a dependency in to dub.sdl/json.

 

2022-05-03.02-46-34.mp4

Video from Beta 0.7.2, LunaFoxgirlVT, model art by kpon

 

Rigging

If you're a model rigger you may want to check out Inochi Creator, the official Inochi2D rigging app in development.
This repository is purely for the standard and is not useful if you're an end user.

 

Supported platforms

The reference library requires at least OpenGL 4.2 or above, as well support for the SPIR-V ARB extension for per-part shaders.
Inochi2D will disable custom shaders if SPIR-V is not found.

Implementors are free to implement Inochi2D over other graphics APIs and abstractions and should work on most modern graphics APIs (newer than OpenGL 2)

An official Unity implementation will be provided once 1.0 is complete.

 

How does Inochi2D work?

Inochi2D contains all your parts (textures) in a tree of Node objects.
Nodes have their own individual purpose.

Parts

Parts contain the actual textures and vertex information of your model.
Each part is an individual texture and set of vertices.

PathDeforms

PathDeforms deform its child Drawables based on its handles.
PathDeforms can deform multiple Drawables at once.

Masks

Masks are a Drawable which allow you to specify a shape.
That shape is used to mask Parts without being a texture itself.

 
More Node types to come...

Do Note

The spec is still work in progress and is subject to change.
More details will be revealed once 1.0 of the spec is released.

 

Bootstrapping Inochi2D

Bootstrapping Inochi2D depends on the backing window managment library you are using.

Inochi2D can be boostrapped in GLFW (bindbc) with the following code

// Loads GLFW
loadGLFW();
glfwInit();

// Create Window and initialize OpenGL 4.2 with compat profile
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
window = glfwCreateWindow(1024, 1024, "Inochi2D App".toStringz, null, null);

// Make OpenGL current and load its functions.
glfwMakeContextCurrent(window);
loadOpenGL();

// A timing function that returns the current applications runtime in seconds and milliseconds is needed
inInit(cast(double function())glfwGetTime);

// Get the viewport size, which is the size of the scene
int sceneWidth, sceneHeight;

// It is highly recommended to change the viewport with
// inSetViewport to match the viewport you want, otherwise it'll be 640x480
inSetViewport(1024, 1024);
inGetViewport(sceneWidth, sceneHeight);

// Also many vtuber textures are pretty big so let's zoom out a bit.
inGetCamera().scale = vec2(0.5);

// NOTE: If you want to implement camera switching (for eg camera presets) use
// inSetCamera

// NOTE: Loading API WIP, subject to change
Puppet myPuppet = inLoadPuppet("myPuppet.inp");

while(!glfwWindowShouldClose(window)) {
    // NOTE: Inochi2D does not itself clear the main framebuffer
    // you have to do that your self.
    glClear(GL_COLOR_BUFFER_BIT);

    // Run inUpdate first
    // This updates various submodules and time managment for animation
    inUpdate();

    // Imagine there's a lot of rendering code here
    // Maybe even some game logic or something

    // Begins drawing in to the Inochi2D scene
    // NOTE: You *need* to do this otherwise rendering may break
    inBeginScene();

        // Draw and update myPuppet.
        // Convention for using Inochi2D in D is to put everything
        // in a scene block one indent in.
        myPuppet.update();
        myPuppet.draw();

    // Ends drawing in to the Inochi2D scene.
    inEndScene();

    // Draw the scene, background is transparent
    inSceneDraw(vec4i(0, 0, sceneWidth, sceneHeight));

    // Do the buffer swapping and event polling last
    glfwSwapBuffers(window);
    glfwPollEvents();
}

NOTE

The version on dub is not always up to date with the newest features, to use inochi2d from the repo either:

  • Add ~master as your version in your dub.selections.json file after having added inochi2d as a dependency.
  • Clone this repo and run dub add-local (inochi2d folder) "1.0.0" to add inochi2d as a local package. You can then add inochi2d as a dependency.

 


The Inochi2D logo was designed by James Daniel

inochi2d's People

Contributors

lunathefoxgirl avatar asahilina avatar you-win avatar moderatelyconfused avatar

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.