# Tag Info

30

An architectural advantage of compute shaders for image processing is that they skip the ROP step. It's very likely that writes from pixel shaders go through all the regular blending hardware even if you don't use it. Generally speaking compute shaders go through a different (and often more direct) path to memory, so you may avoid a bottleneck that you would ...

23

Speed is the most common reason why this is not done. In fact you can do what you propose, if you make your own operating system, its just going to be very slow for architectural reasons. So the assumption that its faster is a bit flawed. Even if it would be faster, it would be less efficient in terms of development (like 1% speed increase for 10 times the ...

15

John has already written a great answer so consider this answer an extension of his. I'm currently working a lot with compute shaders for different algorithms. In general, I've found that compute shaders can be much faster than their equivalent pixel shader or transform feedback based alternatives. Once you wrap your head around how compute shaders work, ...

15

work on any 32-bit color GPU (even old ones)? Bit of history here: this is how games were done on PC up until graphical accelerators started to become available in the mid-90s. It did indeed work on all hardware, because the hardware wasn't doing much. A graphical accelerator allows the drawing of pixels considerably faster than a CPU can, by using ...

14

Just to add to joojaa's answer, things are still being drawn pixel by pixel. You're just generating the pixels using a vertex shader/assembler/rasterizer, then texturing and lighting them using a fragment shader. This was all done in software in the 90's when your video card wasn't much more than a blitter and a frame buffer, but it was slow as hell. Hence ...

13

(XYZ) can be the RGB colour you want to tint your scene by. For the above scene it can be a red colour (1.0, 0.0, 0.0) or something similar with a strong red component. Bear in mind that since you are applying the colour in a multiplicative way it will act as a filter suppressing original colour components. So if your scene is mostly green but you apply (i....

8

Sigma and kernel size of Gaussian filter Regarding how to choose the sigma and the kernel size (pixels) of the Gaussian: you set the sigma based on how wide of a blur you want (judging it visually) and then choose the kernel size based on the sigma. It's a game of finding a kernel size that captures enough of the (mathematically infinite) bell curve to look ...

6

My experience working with shader compiler stacks a few years back is that they are extremely aggressive, and I doubt you will see any perf difference, but I would suggest testing as much as you can. I would generally recommend providing the compiler (and human readers) with more information where the language allows it, marking parameters according to ...

6

Extending Kostas Anagnostou's answer, a commonly used formula for desaturation is float value = 0.3 * InputR + 0.59 * InputG + 0.11 * InputB; This accomodates the fact that different color hues are perceived with a different intensity by a human observer. Further following the example, you would then define some tint color that is multiplied with the ...

6

When you use linewidth or line antialiasing or pointwidth or pointsprites, OpenGL creates for you a small rectangle instead of the line or point, with texture coordinates. Nowadays you can even program this yourself using geometry shaders ot even the tesselator. A totally different approach is to use defered shading, using one geometric pass just to store ...

6

In Vulkan the shader only looks at each 2x2 and won't attempt to look beyond the neighbourhood: http://vulkan-spec-chunked.ahcox.com/ch15s05.html $$dPdx_{0,0}=dPdx_{1, 0} = P_{1,0}−P_{0,0}\\ dPdx_{2,0}=dPdx_{3, 0} = P_{3,0}−P_{2,0}$$ For times when a pixel would fall off the geometry the shader is invoked for the values it would have if the triangle ...

5

Noise functions are definitely your friend here—FBM would be one good candidate. You’re right that it can look too uniform on its own, but if you blend multiple layers of it together, using different speeds / directions for each and maybe distorting their domains a bit, you should be able to get very close to the look of that footage. There’s lots of clever ...

5

Two things come to mind: When generating your smaller mip map levels try to avoid using a simple 2x2 box filter because, though cheap and cheerful, they do a really poor job of removing high frequency information (that exceeds the Nyquist limit) as well as over filtering some of the lower frequency information you need to keep. (Also, as an aside, you need ...

5

So I followed Alan Wolfe suggestion (in comment to my question) And turned out he was right. I was using SamplerState.LinearWrap and that was the issue. When I changed this to AnisotropicWrap it looked much better. Below are some examples of different sampling types and how they affect texture: graphicsDevice.SamplerStates[0] = SamplerState.PointWrap; ...

4

I stumbled on this blog: Compute Shader Optimizations for AMD Given what tricks can be done in compute shader (that are specific only to compute shaders) I was curious if parallel reduction on compute shader was faster than on pixel shader. I e-mail'ed the author, Wolf Engel, to ask if he had tried pixel shader. He replied that yes and back when he wrote ...

4

There is good glsl source of noise (simplex noise) online to make real time noise. In addition to this, to make effect of moving fog/smoke like in this video you can make 3D FBM function. This is my function: float default3DFbm(vec3 P, float frequency, float lacunarity, int octaves, float addition) { float t = 0.0f; float amplitude = 1.0; float ...

3

One good way you can arrange for a circle (or other shape) to be drawn for each vertex in a mesh is to use geometry instancing. This is a GPU feature that allows multiple instances (copies) of a mesh to be drawn at once, with the vertices/indices of the mesh given by one set of buffers, and another vertex buffer that can give additional data per-instance. ...

3

Choose the color RGB of your colorful glasses and choose how transparent they are by choosing an alpha value A. Then alpha composite the glasses on top of the input image: OutputR = R * A + InputR * (1-A) OutputG = G * A + InputG * (1-A) OutputB = B * A + InputB * (1-A)

3

You have not set a viewport with RSSetViewports. You need to set this to the pixel dimensions of your render target. Without this the viewport will be set to 0,0,0,0 meaning no pixels will be touched. Additionally you have not set a raster state or blend state. It is good practice to set these and can be helpful early on to set the winding order in the ...

3

A very novice mistake, I was compiling with the old HLSL compiler. But why would that be the default? Very strange. For anybody wondering, just right click the HLSL file in the solution explorer and go to properties -> HLSL Compiler -> General, and switch Shader Model to the one you want which was newest one for me (5.0)

2

SOLUTION I managed to solve my problem by increacing size of texture 2048x2048px so there would be generated more mipmaps. Also it seems like changing my SamplerState form anisotropic to something like that helped: SamplerState MirrorTexCoord = new SamplerState() { AddressU = TextureAddressMode.Mirror, AddressV = ...

2

I can't believe it has taken me this long to find this... So the array I was giving the Index Buffer Desc that contains the data was the wrong one... It was a blank one that I forgot I didn't need, the vector if you look at the code. Look at that garbage. Those are supposed to be the indices... Well at least I know how to use the debugger now, thanks guys ...

1

Most 2D graphics programs are able to do linear gradients with arbitrary orientations. If you don't mind a little work, it is possible to set this up to imitate the 2D linear interpolation across a triangle. Set up two layers: Pick two of the colors, say red and green, and set up a linear gradient between those two colors along the red-green edge. In a ...

1

A vertex consists of not just the position, but all of the values passed from the vertex processing stage to the rasterizer. So if a vertex gets clipped, the new vertices generated in that process must generate new values for those vertex processing outputs. It does this using the same math that it uses to generate the new vertex position.

1

The problem here is that you're not storing the YUV values of a pixel at the same place in the result image. What you seem to be doing is first storing the full size Y image and after that the quarter-sized U image and then the quarter-sized V image after that (also with a strange gap of half the image size between the Y and the UV data). This doesn't work ...

1

It appears to me that in the image, the saturation of the original image is 0 since it is grayscale. (Unless I've misunderstood the question.) When the saturation is 0, the hue is undefined, but it appears that the GIMP is setting the hue to 0. It is then using the sliders from the dialog to modify the HSL. It adds 180° to the hue (so from 0 to 180 which ...

1

Your indices are wrong, they should start at 0. Correct indices: unsigned int quadIndices[] = { 0, 1, 2, 2, 1, 3 };

1

why not building a bounding box (or spheres) hierarchy ? (but for a shadertoy implementation, the lack of dynamic loop length might spoil the gain ).

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