All Projects β†’ alaingalvan β†’ GPU-Zen-2-Baker

alaingalvan / GPU-Zen-2-Baker

Licence: MIT license
πŸ₯§ An OpenGL 4.x example of GPU Zen 2's ray casting techniques for baked texture generation chapter.

Programming Languages

CMake
9771 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to GPU-Zen-2-Baker

Shader Doodle
A friendly web-component for writing and rendering shaders.
Stars: ✭ 356 (+1012.5%)
Mutual labels:  shaders, texture
Imogen
GPU Texture Generator
Stars: ✭ 648 (+1925%)
Mutual labels:  shaders, texture
MoravaEngine
2D/3D graphics engine written in C++ language. It currently supports the following graphics APIs: OpenGL 3.3+, Vulkan 1.2, DirectX 11. Its current purpose is to experiment with various CG concepts and techniques.
Stars: ✭ 129 (+303.13%)
Mutual labels:  shaders, raycasting
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+3146.88%)
Mutual labels:  shaders, texture
Unity Texture Curve
✏️ Example showing how to bake an AnimatedCurve into a Texture and use it in a shader.
Stars: ✭ 149 (+365.63%)
Mutual labels:  shaders, texture
Glslviewer
Console-based GLSL Sandbox for 2D/3D shaders shaders
Stars: ✭ 2,834 (+8756.25%)
Mutual labels:  shaders, texture
Luminance Rs
Type-safe, type-level and stateless Rust graphics framework
Stars: ✭ 632 (+1875%)
Mutual labels:  shaders, texture
Glslcanvas
Simple tool to load GLSL shaders on HTML Canvas using WebGL
Stars: ✭ 1,067 (+3234.38%)
Mutual labels:  shaders, texture
Glsleditor
Simple WebGL Fragment Shader Editor
Stars: ✭ 1,345 (+4103.13%)
Mutual labels:  shaders, texture
Nvjob Water Shader Simple And Fast
#NVJOB Simple Water Shaders. Free Unity Asset.
Stars: ✭ 172 (+437.5%)
Mutual labels:  shaders, texture
Unity Shader Basics Tutorial
A introduction into creating shaders for Unity
Stars: ✭ 243 (+659.38%)
Mutual labels:  shaders, texture
Shader-Playgrounds
A WebGL shaders editor for beginners and otherwise.
Stars: ✭ 28 (-12.5%)
Mutual labels:  shaders
SoftLight
A shader-based Software Renderer Using The LightSky Framework.
Stars: ✭ 2 (-93.75%)
Mutual labels:  shaders
surface splatting
OpenGL demo of a point rendering and texture filtering technique called Surface Splatting.
Stars: ✭ 125 (+290.63%)
Mutual labels:  shaders
sol
MacOS launcher & command palette
Stars: ✭ 1,335 (+4071.88%)
Mutual labels:  raycast
GodotRetro
A pack of retro shaders to Godot!
Stars: ✭ 196 (+512.5%)
Mutual labels:  shaders
compute-shader-101
Sample code for compute shader 101 training
Stars: ✭ 323 (+909.38%)
Mutual labels:  shaders
cub3d
This project is inspired by the world-famous eponymous 90’s game, which was the first FPS ever. It will enable you to explore ray-casting. Your goal will be to make a dynamic view inside a maze, in which you’ll have to find your way.
Stars: ✭ 18 (-43.75%)
Mutual labels:  raycasting
WaterColor
openframeworks parametric shader effect watercolor
Stars: ✭ 54 (+68.75%)
Mutual labels:  shaders
ModernUI
Modern desktop framework from low-level 3D graphics API to high-level view model, for development of 2D/3D rendering software or game engine, with internationalization support and many new technologies.
Stars: ✭ 168 (+425%)
Mutual labels:  shaders

GPU Zen 2 | Ray Casting Techniques for Baked Texture Generation

GPU Zen 2 cmake-img License Travis Tests

Note: 🚧 This repository is a work in progress as GPU Zen 2 gets closer to release, you can follow its progress in the develop branch.

When building real-time applications artists must conform to a performance budget according to their project’s system requirements. Baking allows for the caching of data from geometry with much higher polygon counts to image textures that can be used as inputs in shaders.

This example presents a series of techniques for baking textures to be used in real-time applications. Applications for baking include creating assets with varying levels of detail (LOD), caching lighting effects such as global illumination and diffuse lighting for static assets, and creating atlas maps for objects with multiple materials and UV spaces.

Getting Started

First install Git, then open any terminal such as Hyper in any folder and type:

# πŸ‘ Clone the repo
git clone https://github.com/alaingalvan/gpu-zen-2-baker --recurse-submodules

# πŸ’Ώ go inside the folder
cd gpu-zen-2-baker

# πŸ‘― If you forget to `recurse-submodules` you can always run:
git submodule update --init

From there we'll need to set up our build files. Be sure to have the following installed:

Then type the following in your terminal from the repo folder:

# πŸ‘· Make a build folder for your IDE files
mkdir build
cd build

# πŸ–ΌοΈ To build your Visual Studio solution on Windows x64
cmake .. -A x64

# 🍎 To build your XCode project on Mac OS
cmake .. -G Xcode

# 🐧 To build your .make file on Linux
cmake ..

# πŸ”¨ (Optional) Build your project:
cmake --build .

This example was written to work on:

  • πŸ–ΌοΈ Windows (Tested on Windows 10 | 3.0Ghz AMD Ryzen 1700 / NVIDIA 1080 / 32GB Ram)

  • 🍎 MacOS (Tested on MacOS 10.13 High Sierra | iMac 2017 / 3.4GHz Intel i5 / Radeon Pro 560 / 16GB Ram)

Usage

When the program starts a UI element will appear to the right that shows all the controls for the baker system.

Click Load Low Poly Mesh to load the low poly mesh you'll be applying textures to. Make sure this mesh has UVs.

Click load High Poly Mesh to load the high poly mesh you'll be getting your data from.

Click Choose Output Folder to change the output folder.

You can set the resolution, cage distance, and which maps to bake from the UI.

Click the Bake button to bake those textures and have them written to <yourpath>/<yourmap>.png.

Supported Maps

Surface

  • ⬆️ Normal

  • β†˜οΈ Object Normal

Lights

  • πŸŒ’ Ambient Occlusion

Navigation

Action Input
Rotate Camera Alt + Left Click
Pan Camera Alt + Middle Click
Zoom Camera Alt + Right Click
Move Light Shift + Left Click

Architecture

The file structure for this example is a basic actor-component engine, with a middleware component to the engine to handle shared state that actors can subscribe to (such as the graphics window).

β”œβ”€ external/
β”œβ”€ assets/
β”‚  β”œβ”€ shaders/
β”‚  β”‚  β”œβ”€ Bake.vert                  # Shared Vertex Shader across all baker passes
β”‚  β”‚  β”œβ”€ BakeNormals.frag           # Baker pass for normals / object normals
β”‚  β”‚  └─ BakeAmbientOcclusion.frag  # Baker pass for ambient occlusion
β”‚  └─ ...
β”œβ”€ src/
β”‚  β”œβ”€ Engine/
β”‚  β”‚  β”œβ”€ Core/                      # Core Engine structures, basic Actor-Component design
β”‚  β”‚  β”œβ”€ Actors/                    # Actors, where you'll find entities in the scene
β”‚  β”‚  β”œβ”€ Middleware/                # The engine's shared state, such as graphic windows and IMGUI
β”‚  β”‚  β”œβ”€ Engine.cpp
β”‚  β”‚  └─ Engine.h
β”‚  └─ XMain.cpp                     # Cross Platform main function
β”œβ”€ ...
└─ CMakeLists.txt

Execution Order

  1. Your platform dependent main function is called, which calls the abstraction main function void xmain(int argc, const char** argv).

  2. xmain creates an Engine to start() it.

  3. The Engine creates middleware that holds state that can be managed independently and shared to Actors. It creates a CoreMiddleware that manages events, the window, presentation, and keeps the engine running so long as the window hasn't closed.

  4. When the CoreMiddleware is updating, it passes the Engine's Scene over to the Renderer, which performs a preorder traversal of scene hierarchy, updating each actor and rendering it. Afterwords it renders the GUI.

The core logic of the Baker can be found in the Baker class located in /src/Engine/Actors/, with its shaders found in /assets/shaders.

Dependencies

  • CrossWindow - A Cross platform windowing library.

  • CrossWindow-Graphics - Creates and manages OpenGL context.

  • OpenGL-Registry - Header files for all OpenGL APIs.

  • Glad - OpenGL library Loader.

  • VectorMath - Modified version of Sony's open sourced vector and matrix math library.

  • stb - A number of public domain libraries, including a PNG writer / reader that we're using in this example.

  • dear imgui - a bloat-free graphical user interface library for C++.

  • Open Asset Import Library - Loads 40+ 3D file formats into one unified and clean data structure.

License

This project is licensed as either MIT or Apache-2.0, whichever you would prefer.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].