39

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 area of active research, with new techniques appearing every year. Ambient lighting At the very simplest end of the range, you can use ambient lighting: a ...


11

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 immediately. Sure, glFlush and glFinish are provided, so that implementations can have some asynchronous execution of commands. But these are essentially fig ...


8

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 usually the most inefficient, due to the high API overhead. The second one, using instanced drawing is a much smarter approach for objects with the same parameters. ...


6

Resolved by adding precision highp sampler2D to my shaders. About default precision settings on ES - https://www.khronos.org/files/opengles_shading_language.pdf page 36.


6

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 vertex shader. Image 1: For each wall generate a shadow volume extrusion. Quick and extremely dirty sample implementation of shadow volumes here: http://...


6

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 into one row while the display was reading out of some subset of the others. It would then cycle through the buffers. In order to do this, however, you do need ...


5

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 diff to quantify how different the renders are. You can then set a threshold in your test and have the test fail if the renders are too different. A harsh ...


5

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 rendered 'in a vacuum' - each triangle is rendered without reference to any other triangles in the scene, and the same goes for pixels, as opposed to ray-tracing ...


4

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 transformation matrix, for each of the particles. In the shader you can then use gl_InstanceID to distinguish between the individual particles and pick the appropriate ...


4

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 compression ratios of 4:1 or better. That's at least one quarter of the memory bandwidth costs of fetching the texture. If your rendering uses lots of textures, ...


3

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 call. Using instanced rendering you only have to specify the geometry of an object once on the GPU. Then, you could pass along an additional buffer of matrices, ...


3

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


3

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 (z and w) will be auto filled with 0 and 1 resp. Is it possible to reuse the color like to hat? No it is not. Opengl (and most other graphics apis) require that each vertex is referenced by ...


3

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 serious about not allowing this that it actually changes the meaning of the parameters to functions like glTexImage*d. In ES, you cannot use sized internal ...


3

I think the most efficient way might be either return float(shadowValue > shadowTexZ); or return step(shadowTexZ, shadowValue);


2

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, coupled with a colour appearance model such as the work behind Dr. Mark Fairchild's CIECAM02, can result in very accurate predictions of quantization depth.


2

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] respectively for an unsigned normalized or signed normalized color buffer prior to evaluating the blend equation. If the color buffer is floating-point, no ...


2

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 set to match the base alignment of a single array element, according to rules (1), (2), and (3), and rounded up to the base alignment of a vec4. The array may have padding at the end; the base ...


2

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. That doesn't sound fast, though, given you're targeting older devices. You could speed it up by forgoing trilinear filtering and just using the nearest-neighbor ...


2

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: precision mediump float; uniform sampler2D uSampler; varying vec2 vTextureCoord; void main() { vec4 originalColor = texture2D(uSampler, vTextureCoord); vec4 ...


2

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 insurance that you will get invariant results across implementations. At the end of the day, you can't do testing in this fashion.


1

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


1

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 triangle list, and set up indices in such a way that the provoking vertex is the same in each quad. For instance, if one quad is vertices {0, 1, 2, 3} (CCW) then ...


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