47 votes
Accepted

Physically based shading - ambient/indirect lighting

Real-time graphics deploys a variety of approximations to deal with the computational expense of simulating indirect lighting, trading off between runtime performance and lighting fidelity. This is an ...
user avatar
  • 23.7k
12 votes
Accepted

Why can't I utilize multiple CPU cores with OpenGL like Vulkan?

Because the fundamental foundation of OpenGL makes multi-CPU-core submission impossible. OpenGL, at its core, is a synchronous API. Every OpenGL command behaves "as if" it were executed and completed ...
user avatar
  • 8,141
8 votes
Accepted

How to reduce the number of draw calls when rendering one object multiple times?

There are many, many ways to draw things in OpenGL, so this is naturally confusing sometimes. The first method you describe, setting the shader parameters and issuing one draw call per object is ...
user avatar
  • 1,389
7 votes
Accepted

Double buffering always necessary?

Indeed there are/were 'just in time' renderers. For example, Dreamcast (PowerVR CLX2) had a mode where the 'frame buffer' only had to be a few rows of tiles in size. The system would be rendering ...
user avatar
  • 3,986
6 votes
Accepted

SSAO artefacts on iPhone (OpenGL ES)

Resolved by adding precision highp sampler2D to my shaders. About default precision settings on ES - https://www.khronos.org/files/opengles_shading_language.pdf ...
user avatar
  • 221
6 votes

How to implement a realtime 2D light renderer with fog/colored light on the GPU?

If your wall geometry is vector graphics you can simply extrude the segment away from the light position. This means 2 triangles per draw call, all the extrusion offsets can can be handled in the ...
user avatar
  • 8,169
6 votes

Physically based shading - ambient/indirect lighting

This is the main 'hard' problem remaining in real-time CG, and there is a lot of research ongoing into solving it. The biggest hurdle is that in raster graphics, each component of the scene is ...
user avatar
  • 2,302
5 votes

How to take consistent screenshots across multiple machines?

Nicol Bolas explains why you can't expect pixel-accurate reproductions, but that doesn't mean you can't test with screenshots. Don't compare the screenshots byte-for-byte. Instead, use a perceptual ...
user avatar
  • 6,490
4 votes
Accepted

If I have more than enough memory, can it still be beneficial to use compressed textures?

Because memory bandwidth is not free. No matter how much RAM you have, it takes less time to read 1024 bytes than it does to read 1024 KB. Compressed textures, relative to 32-bpp, can offer ...
user avatar
  • 8,141
4 votes
Accepted

OpenGL ES 3 - Uniform buffer object with float array

Let's review what the specification says about std140 layout of arrays: If the member is an array of scalars or vectors, the base alignment and array stride are ...
user avatar
  • 8,141
4 votes

How to reduce the number of draw calls when rendering one object multiple times?

In OpenGL ES there is Instancing which provides allows for rendering one object multiple times. When using Instancing, you can use uniform arrays to provide different information, e.g. a ...
user avatar
  • 1,220
4 votes
Accepted

What is causing this odd scaling behavior?

Are you calling glViewport when switching drawing to FBO ? This should be called when switching into a different resolution render target. I say this because case #1 is a symptom of incorrect ...
user avatar
  • 2,244
3 votes
Accepted

Interlacing vertex buffer data with extra efficiency

Is it even possible to have opengl assume that the Z is always 0? Yes it is. Just set the component count to 2 in glVertexAttribPointer and the other 2 components (...
user avatar
3 votes

Loading compressed image to GPU and reading back decompressed on CPU

Desktop OpenGL requires implementations to convert pixel data between the internal format of the image and the format you specify in the pixel transfer command. OpenGL ES does not. Indeed, it is so ...
user avatar
  • 8,141
3 votes
Accepted

OpenGL ES Frag Shader - Branching

I think the most efficient way might be either return float(shadowValue > shadowTexZ); or ...
user avatar
  • 1,416
2 votes

Pixel density / color channel depth ratio for dithered gradients

There has been quite some research into this using Barten contrast sensitivity function. It is the current formula behind the Dolby Perceptual Quantizer as featured in SMPTE 2084 and HDR10. This, ...
user avatar
  • 283
2 votes
Accepted

Blending for Floating Point Texture

Section "17.3.8 Blending" of the OpenGL spec states: If the color buffer is fixed-point, the components of the source and destination values and blend factors are each clamped to [0, 1] or [-1, 1] ...
user avatar
  • 800
2 votes
Accepted

Any way to fake textureLod on GLES2?

One way would be to break out the mip levels of the cube into a bunch of separate textures, then implement the mip selection and trilinear filtering yourself, by branching based on the LOD value. ...
user avatar
  • 23.7k
2 votes
Accepted

Efficiently drawing multiple instances of 3D objects

What you are looking for here is instanced rendering. Instanced rendering coupled with attribute divisors is a very powerful tool to render multiple copies of the same object using only one drawing ...
user avatar
  • 967
2 votes
Accepted

Alpha component in color buffer affects RGB components?

It looks like you're drawing with pre-multiplied alpha. This means that the red, green, and blue channels have been multiplied by the alpha channel. So your shader should look more like this: ...
user avatar
  • 3,331
2 votes

How to take consistent screenshots across multiple machines?

What you want cannot reasonably be done. No graphics API defines byte-accurate results. Every implementation will have its own variances, which will be visible in the results. OpenGL provides no ...
user avatar
  • 8,141
2 votes
Accepted

When unsetting a VAO, should you also unbind the associated VBOs?

No, you do not need to unbind the VBO's. VBO's are only added to the state of the VAO when that VAO is bound. So any previously bound VBO's will not alter the state of the VAO that you are going to ...
user avatar
  • 967
2 votes

Best practice for managing many shaders and merging multiple shaders into one?

I target mobile/tablet devices with my product this is less of a concern with desktop GPUs. unity and unreal allowing full flexibility on adding shaders & materials at-will Well, Unity and ...
user avatar
  • 1,689
2 votes
Accepted

If a GPU supports OpenGL ES 3.2, does it also support OpenGl 3.0?

That looks like a typo. Most mobile GPUs don't support desktop GL of any version, so they probably meant OpenGL ES 3.0 (which is a valid version) And yes, ES 3.0 is backwards compatible with ES 3.2.
user avatar
  • 8,141
1 vote
Accepted

Tiling in GLSL creates unwanted seams

Using texelFetch gives the correct result. Here is a shaderToy that shows an animated version. ...
user avatar
  • 2,132
1 vote
Accepted

How to pass only the needed portion of the data calculated in a fragment shader to another fragment shader?

I'm assuming that you don't know how many objects there will be or have any way to index them until the image processing operations are completed, i.e. you have some final pass that determines for ...
user avatar
  • 23.7k
1 vote
Accepted

What is wrong with my glDrawElement code

glDrawElements specifies the second argument to be the number of elements to be taken from the buffer of indices, not the number of vertices. The correct number would be the number of triangles times ...
user avatar
  • 967
1 vote
Accepted

Same specular lighting on both tris in a quad (for "low-poly" "flat shading" look)?

If I understand you correctly, the problem is that the provoking vertex isn't the same vertex between the two triangles in a quad, due to using triangle strips. You could switch to using an indexed ...
user avatar
  • 23.7k

Only top scored, non community-wiki answers of a minimum length are eligible