Most Popular
1500 questions
72
votes
6 answers
How can I debug GLSL shaders?
When writing non-trivial shaders (just as when writing any other piece of non-trivial code), people make mistakes.[citation needed] However, I can't just debug it like any other code - you can't just attach gdb or the Visual Studio debugger after…

Martin Ender
- 2,730
- 4
- 23
- 45
65
votes
10 answers
Should new graphics programmers be learning Vulkan instead of OpenGL?
From the wiki: "the Vulkan API was initially referred to as the 'next generation OpenGL initiative' by Khrono", and that it is "a grounds-up redesign effort to unify OpenGL and OpenGL ES into one common API that will not be backwards compatible with…

galois
- 885
- 1
- 6
- 8
62
votes
3 answers
When is a compute shader more efficient than a pixel shader for image filtering?
Image filtering operations such as blurs, SSAO, bloom and so forth are usually done using pixel shaders and "gather" operations, where each pixel shader invocation issues a number of texture fetches to access the neighboring pixel values, and…

Nathan Reed
- 25,002
- 2
- 68
- 107
55
votes
5 answers
Albedo vs Diffuse
Every time I think I understand the relationship between the two terms, I get more information that confuses me. I thought they were synonymous, but now I'm not sure.
What is the difference between "diffuse" and "albedo"? Are they interchangeable…

hmind
- 653
- 1
- 5
- 5
54
votes
5 answers
Sharp Corners with Signed Distance Fields Fonts
Signed Distance Fields (SDFs) was presented as a fast solution to achieve resolution independent font rendering by Valve in this paper.
I already have the Valve solution working but I'd like to preserve sharpness around corners. Valve states that…

Felipe Lira
- 1,246
- 1
- 11
- 16
52
votes
5 answers
How is Gaussian Blur Implemented?
I've read that blur is done in real time graphics by doing it on one axis and then the other.
I've done a bit of convolution in 1D in the past but I am not super comfortable with it, nor know what to convolve in this case exactly.
Can anyone explain…

Alan Wolfe
- 7,801
- 3
- 30
- 76
44
votes
2 answers
What is Importance Sampling?
What is importance sampling? Every article I read about it mentions 'PDF' what is that as well?
From what I gather, importance sampling is a technique to only sample areas on a hemisphere that matter more than others. So, ideally, I should sample…

Arjan Singh
- 2,511
- 3
- 22
- 38
43
votes
2 answers
What is Ray Marching? Is Sphere Tracing the same thing?
A lot of ShaderToy demos share the Ray Marching algorithm to render the scene, but they are often written with a very compact style and i can't find any straightforward examples or explanation.
So what is Ray Marching? Some comments suggests that it…

psicomante
- 610
- 1
- 5
- 11
40
votes
2 answers
How can virtual texturing actually be efficient?
For reference, what I'm referring to is the "generic name" for the technique first(I believe) introduced with idTech 5's MegaTexture technology. See the video here for a quick glance on how it works.
I've been skimming some papers and publications…

Llamageddon
- 931
- 2
- 7
- 13
40
votes
4 answers
Sharing code between multiple GLSL shaders
I often find myself copy-pasting code between several shaders. This includes both certain computations or data shared between all shaders in a single pipeline, and common computations which all of my vertex shaders need (or any other stage).
Of…

Martin Ender
- 2,730
- 4
- 23
- 45
37
votes
2 answers
What is the cost of changing state?
Programmers are supposed to have a fairly good idea of the cost of certain operations: for example the cost of an instruction on CPU, the cost of a L1, L2, or L3 cache miss, the cost of a LHS.
When it comes to graphics, I realize I have little to no…

Julien Guertault
- 4,420
- 2
- 23
- 47
37
votes
4 answers
Are there common materials that aren't represented well by RGB?
In graphics we use RGB and other color spaces as an approximation to the full spectrum of light wavelengths. This evidently works pretty well in general, but are there any reasonably common objects/materials/phenomena, things you might encounter in…

trichoplax is on Codidact now
- 6,292
- 3
- 23
- 69
37
votes
3 answers
What is a stencil buffer?
Wikipedia states that a stencil buffer is some arbitrary buffer a shader can use.
However, it hints that it's used for clipping, or otherwise "tightly binding" the depth and pixel buffers, slightly contradicting itself.
What does the stencil buffer…

Qix - MONICA WAS MISTREATED
- 629
- 1
- 5
- 14
36
votes
3 answers
Why does monte carlo ray tracing perform better than distributed ray tracing?
I've heard that the quality of a monte carlo ray tracer (based on path tracing algorithms) is much more realistic than a distributed (stochastic) engine. I try to understand why, but I'm just at the beginning.
In order to dive into this topic and…

p2or
- 596
- 1
- 7
- 15
36
votes
2 answers
How physically-based is the diffuse and specular distinction?
The classical way of shading surfaces in real-time computer graphics is a combination of a (Lambertian) diffuse term and a specular term, most likely Phong or Blinn-Phong.
Now with the trend going towards physically-based rendering and thus…

David Kuri
- 2,293
- 13
- 32