GithubHelp home page GithubHelp logo

pkuzhd / nativerenderingplugin4unity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from peggywang19/nativerenderingplugin4unity

0.0 0.0 0.0 33.18 MB

Using a thread to produce texture for openGL shader

License: MIT License

C++ 16.39% C 79.36% Objective-C 0.41% C# 1.23% Objective-C++ 1.65% Makefile 0.25% Batchfile 0.45% ShaderLab 0.25%

nativerenderingplugin4unity's Introduction

Native code (C++) rendering plugin example for Unity

This sample demonstrates how to render and do other graphics related things from a C++ plugin, via a native plugin interface.

Unity versions:

  • 2018.1+ use tip of default branch.
  • 5.6, 5.5, 5.4: use corresponding unity-x.x tag.

The plugin itself does very few things:

  • Demonstrates basic plumbing. How to initialize the graphics API, and how calls from Unity into plugin are made.
  • Draws a triangle. A single colored rotating triangle in the middle of the screen. For each backend API, this shows bare basics of how to setup vertex data, setup some shaders or render states, and do a draw call.
  • Changes Unity texture data. Unity side passes a texture into the plugin, and the code changes the pixels of it each frame, with an animated "plasma" pattern. This demonstrates how to work with Texture.GetNativeTexturePtr.
  • Changes Unity mesh vertex data. Unity side passes a vertex buffer into the plugin, and the code changes the vertices each frame, with an animated "heightfield" pattern. This demonstrates how to work with Mesh.GetNativeVertexBufferPtr.

Native code rendering is implemented for several platforms and graphics APIs:

  • Windows (D3D11, D3D12, OpenGL, Vulkan)
    • Note that Vulkan is not compiled in by default (requires Vulkan SDK); enable it by editing #define SUPPORT_VULKAN 0 to 1 under UNITY_WIN clause in PlatformBase.h
  • macOS (Metal, OpenGL)
  • Linux (OpenGL, Vulkan)
  • Windows Store aka UWP (D3D11, D3D12)
  • WebGL (OpenGL ES)
  • Android (OpenGL ES, Vulkan)
  • iOS/tvOS (Metal; Simulator is supported if you use unity 2020+ and XCode 11+)
  • EmbeddedLinux (OpenGL, Open GLES)
  • ...more platforms might be coming soon, we just did not get around to adding project files yet.

Code is organized as follows:

  • PluginSource is source code & IDE project files for the C++ plugin.
    • source: The source code itself. RenderingPlugin.cpp is the main logic, RenderAPI*.* files contain rendering implementations for different APIs.
    • projects/VisualStudio2015: Visual Studio 2015 project files for regular Windows plugin
    • projects/UWPVisualStudio2015: Visual Studio 2015 project files for Windows Store (UWP - Win10) plugin
    • projects/Xcode: Apple Xcode project file for Mac OS X plugin, Xcode 10.3 on macOS 10.14 was tested
    • projects/GNUMake: Makefile for Linux
    • projects/EmbeddedLinux: Windows .bat files to build plugins for different architectures
  • UnityProject is the Unity (2018.3.9 was tested) project.
    • Single scene that contains the plugin sample scene.

What license are the graphics samples shipped under?

Just like with most other samples, the license is MIT/X11.

nativerenderingplugin4unity's People

Contributors

aras-p avatar hkr avatar alexey-unity avatar tak avatar n7rx avatar borisshir avatar peggywang19 avatar graphinenicolas avatar matas-tunkevicius 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.