# GLCore **Repository Path**: Storm_rain/GLCore ## Basic Information - **Project Name**: GLCore - **Description**: 基于OpenGL及OptiX的渲染框架,供个人实现算法使用,详细介绍见Markdown - **Primary Language**: C++ - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-10-13 - **Last Updated**: 2022-03-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: Rendering, Opengl, Optix, PathTracing, Irradiance ## README # GLCore GLCore 是一个基于 OpenGL 及 OptiX 的渲染框架,供个人实现算法使用。
现因Gitee不支持LFS,新仓库地址[https://world-tree.coding.net/public/GLCore/GLCore/git/files](https://world-tree.coding.net/public/GLCore/GLCore/git/files)
## 21 Features - 延迟渲染 (Deferred rendering)
by multi render targets framebuffer named GBuffer
- 全阶段着色器支持 (Full stage shaders supported)
by glsl tess control, tess evaluation, geometry, compute shaders
- 着色器头文件包含 (Shading language include)
by GL_ARB_shading_language_include and GLCore's File utility
- Debug标签 (Renderdoc event and resource label)
by glPushDebugGroup()... and glObjectLabel() to locate Graphics resources
- 交叉编译 (Compile to SPIR-V)
by GL_SHADER_BINARY_FORMAT_SPIR_V and shaderc to compile glsl or hlsl to SPIR-V
- 光线追踪管线 (Ray tracing pipeline)
by OptiX raygen, hitgroup(intersect, closesthit, anyhit), miss shaders
- 多材质路径追踪 (Multi materials path tracing)
by OptiX shaders and CUDA texture, surface object
- DDGI (Dynamic diffuse Global Illumination)
by probes trace radiance, depth and convolution to tetra atlas and sample volume atlas
- OptiX降噪器 (OptiX AI denoiser)
by OptixDenoiser and CUDA OpenGL interoperation
- 无绑定纹理及图像 (Bindless texture and image)
by GL_ARB_bindless_texture and glGetImageHandleARB()...
- 间接绘制 (Indirect drawing)
by glMultiDrawArraysIndirect()... and indirect buffer
- 各向异性过滤 (Anisotropic filtering)
by trilinear filtering and GL_TEXTURE_MAX_ANISOTROPY
- 压缩纹理 (Compressed texture)
by GL_COMPRESSED_RGBA_S3TC_DXT5_EXT... and manually load and flip DDS blocks
- FBX场景读取 (Load FBX scene)
by FBX sdk and GLCore's Model, Material, Light components
- PBR材质 (PBR material)
by BaseColor, Normal, Roughness, Metallic, AO maps and Albedo, RMA render targets
- HDR工作流 (HDR workflow)
by sRGB gamma correction, linear space compute and result tone mapping
- Shadertoy框架 (Shadertoy framework)
by imple shadertoy's whole input uniforms and GLCore's Renderpass
- 组件式封装 (Encapsule as components)
by minimizing include files in header and treat Graphics concepts as individuals
- 好用的ImGUI (Friendly ImGUI)
by C17 std::variant and lambda, functional to introduce SHeader and SWidget
- 四元数相机 (Quaternion camera)
by user euler angle interface and inner quaternion rotation
- 屏幕文本绘制 (Screen text drawing)
by bindless texture(renderdoc can't debug) or texture2D array with times.ttf
## Built-in RenderPasses - 前向渲染SimplePass
  输入需要显示的各模型名,输出漫反射结果到当前帧缓冲 - 延迟渲染GBufferPass
  输入GBuffer需要的各模型名,输出Position,Normal,Albedo,RMA等纹理 - 局部光照BlinnPhongPass
  输入GBuffer各纹理名,输出Lambert漫反射,BlinnPhong镜面反射,常量环境光的局部光照纹理 - 天空盒SkyboxPass
  输入立方体贴图路径或纹理名,输出天空盒到当前帧缓冲 - 辐照度卷积EnvironmentMapConvolutionPass
  输入各环境立方体贴图名,输出各环境辐照度立方体贴图 - 屏幕四边形ScreenQuadPass
  输入需要全屏显示的纹理名,禁用深度测试输出到当前帧缓冲 - 色调映射ToneMappingPass
  输入HDR纹理名,输出经过ACES映射后的SDR纹理 - 本地版ShadertoyPass
  输入Shadertoy的片段着色器路径,输出运行结果 - 文本绘制DrawTextPass
  输入文本及位置,颜色,大小等属性,输出屏幕文本到当前帧缓冲 - 模型描边OutlinePass
  输入需要描边的各模型名及颜色,输出描边结果到当前帧缓冲 - 对象选取SelectObjectPass
  输入需要监控的资源,如模型,灯光,通过接口返回被鼠标选取对象

## Experiments && Examples ### Shadertoy框架光线步进 ![Ray Marcing](doc/Introduction/RayMarching.gif)

### 符号距离场建场及可视化 ![Visual SDF](doc/Introduction/VisualSDF.png)

### 双抛物面点光源阴影贴图 ![Duel Paraboloid](doc/Introduction/DuelParaboloid.png)

### 康奈尔盒DDGI ![IBL](doc/Introduction/DDGI.png)

### 基于图像的光照 ![IBL](doc/Introduction/IBL.png)

### 辐照度球谐编码 ![IBL](doc/Introduction/SH.png)

### 分布式光线追踪 ![IBL](doc/Introduction/DistributionRayTracing.png)

### 可视化场景材质ID ![IBL](doc/Introduction/MaterialId.png)

### 多材质路径追踪 ![IBL](doc/Introduction/PathTracing.png)

## Dependencies 安装CUDA Toolkit
部分模型如[Bistro](https://developer.nvidia.com/orca/amazon-lumberyard-bistro)酒馆未上传至仓库
... 之前通过nuget管理第三方库,但每项目需要独立配置过于繁琐,现通过#pragma comment预编译导入lib,新项目只需添加包含目录
因为用到了C17 filesystem 提供的符号链接为GLSL扩展的语法补全提供支持。管理员打开VS运行一次该项目,即可让扩展找到Shader头文件

## Additional ### 为何要自己写? 为了**自由和简单**。直接用Godot,Unity,UE等游戏引擎难以直接操作图形API。而直接用其他渲染框架如[G3D](https://casual-effects.com/g3d/www/index.html),[Falcor](https://github.com/NVIDIAGameWorks/Falcor)文档复杂,修改困难。 ### 为什么用OpenGL和OptiX? Vulkan,DX12等现代API通过将部分驱动层的概念暴露给用户,来获得对硬件更细致的掌控,进而提高运行效率。但API复杂且**学习资料少**,不利于前期学习。光追支持可通过Vulkan扩展,DXR和OptiX获得,因为选择了最简单的OpenGL,对应的通过基于CUDA的OptiX来支持。 ### 为什么要做DDGI? 因为毕设准备做**探针**相关的全局光照算法。