All Projects → msqrt → Shader Printf

msqrt / Shader Printf

Licence: mit
Simple printf functionality for GLSL.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Shader Printf

Bonzomatic
Live shader coding tool and Shader Showdown workhorse
Stars: ✭ 829 (+387.65%)
Mutual labels:  graphics, glsl, shader
Spirv Vm
Virtual machine for executing SPIR-V
Stars: ✭ 173 (+1.76%)
Mutual labels:  glsl, shader, debugging
Shaderconductor
ShaderConductor is a tool designed for cross-compiling HLSL to other shading languages
Stars: ✭ 1,146 (+574.12%)
Mutual labels:  graphics, glsl, shader
Gpu Gems Book Source Code
💿 CD Content ( Source Code ) Collection of Book <GPU Gems > 1~ 3 | 《GPU精粹》 1~ 3 随书CD(源代码)珍藏
Stars: ✭ 567 (+233.53%)
Mutual labels:  graphics, glsl, shader
3d Game Shaders For Beginners
🎮 A step-by-step guide to implementing SSAO, depth of field, lighting, normal mapping, and more for your 3D game.
Stars: ✭ 11,698 (+6781.18%)
Mutual labels:  graphics, glsl, shader
2d Unity Experiments
A collection of visual Unity experiments with latest packages (URP, Shader Graph, Cinemachine, etc).
Stars: ✭ 107 (-37.06%)
Mutual labels:  graphics, shader
Unlitclouds
A unity cloud shader, using vertex colors and tessellation for a simple stylized look.
Stars: ✭ 110 (-35.29%)
Mutual labels:  glsl, shader
Lwrpshaders
A collection of high customizable unlit shaders for Lightweight Render Pipeline
Stars: ✭ 125 (-26.47%)
Mutual labels:  graphics, shader
Glslang
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Stars: ✭ 2,034 (+1096.47%)
Mutual labels:  glsl, shader
Godot Hair Shader
My attempt at a hair shader in Godot
Stars: ✭ 91 (-46.47%)
Mutual labels:  graphics, shader
Shaderc Rs
Rust bindings for the shaderc library.
Stars: ✭ 143 (-15.88%)
Mutual labels:  graphics, glsl
Noiseball3
A Unity example that shows how to use the new implementation of DrawProcedural.
Stars: ✭ 147 (-13.53%)
Mutual labels:  graphics, shader
Three.meshline
Mesh replacement for THREE.Line
Stars: ✭ 1,644 (+867.06%)
Mutual labels:  glsl, shader
Physics3d
A 3D physics engine
Stars: ✭ 101 (-40.59%)
Mutual labels:  graphics, shader
Unity Lowpoly Shader
Unity Shader for mesh rendering in lowpoly style
Stars: ✭ 116 (-31.76%)
Mutual labels:  glsl, shader
Gpu Planetary Rendering
GPU atmosphertic scattering and planet generation in Unity 3D
Stars: ✭ 92 (-45.88%)
Mutual labels:  graphics, shader
Godot Cel Shader
A Cel Shader for the Godot Engine
Stars: ✭ 145 (-14.71%)
Mutual labels:  glsl, shader
Glsl Godrays
This module implements a volumetric light scattering effect(godrays)
Stars: ✭ 155 (-8.82%)
Mutual labels:  glsl, shader
Processingstuff
Various pretty-ish Processing sketches by Blokatt. About 50% shaders.
Stars: ✭ 153 (-10%)
Mutual labels:  glsl, shader
Soicbite
A compact PCB footprint which allows SOIC test clips to be used as a space-efficient programming and debugging connector
Stars: ✭ 161 (-5.29%)
Mutual labels:  glsl, debugging

Simple printf functionality for GLSL.

This library is a simple proof of concept of using printf directly from a shader. The main point of being able to do this is to ease the debugging of complicated shader programs. This is invaluable for example when it's essential to see the evolution of the value of a variable in a loop and simply outputting the final value will not give enough information of how the program works.

Currently the library is a single header file, shaderprintf.h. This file contains a function called glShaderSourcePrint that simply acts as a replacement for glShaderSource for any shaders where the printing functionality is desired. It also contains a final parser called getPrintBufferString that returns all of the printed content as a C++ std::string. In addition to these two it contains helpers to create, bind and delete a necessary temporary buffer that should be somewhat simple to understand by looking at the example main loop in main.cpp.

Note that on the GLSL side you need to call enablePrintf() before calling printf. This is simply because most of the time you'll have thousands of threads and no interest in seeing the values for all of them; instead you most often want to enable the prints for a certain small-ish subset (like a region on the screen or certain problematic vertices) so you don't need to do if("I should be writing") printf(...) all the time. There's also a corresponding disablePrintf() function -- these just set a hidden boolean variable to true or false and each printf tests against it.

Also note that GLSL doesn't support characters, strings or pointers so %c, %s and %p are out. As is %n since there's no dynamic memory handling anyway. As a consequence, this implementation of printf -- in contrast to C printf -- returns void.

Due to the native vector types of GLSL, the format specifier definition of printf is enhanced to contain dimensionality and is as follows : %[flags][width][.precision][length][^dimensions]specifier. dimensions is a number between 1 and 4. All elements will be printed with the same format specifier (which matches the standard if we omit the [^dimensions] part), surrounded by parentheses and separated with commas and spaces. They're written in the order xyzw and a subset can be printed (i.e. printf("%.1^3f", vec4(1.0)); is completely legal and will print "(1.0, 1.0, 1.0)")

The example program should work directly from the repository with Visual Studio, select shader-printf as the startup project and run. Everything here is written in VS2017 but at least VS2015 should be fine as well. OpenGL version 4.3 (or the shader storage buffer object extension) is required.

The repository also comes with a minimal OpenGL extension handler/windowing system that's aimed at targeting a single core version with all of the nice debug features that modern OpenGL comes with. It's probably not much of use as is but it's a nice reference and you might find features you didn't know about.

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].