# Tag Info

4

A texture that stores distance from the edge of the shape, like you described, is called a "distance field" (you'll find lots of results if you google that phrase). Distance fields can be calculated efficiently on the GPU using the jump flooding algorithm (JFA). This is a multi-pass algorithm that works by sampling pixels at a distance of first ½ ...

3

You might want to check matplotlib-cpp. You'll find a "funny-looking xkcd-styled example" in the README. I also saw xkcd related entries on matplotlib's Python documentation. So, it should be available in Python too. However, I did not use these libraries myself. I just stumbled upon matplotlib-cpp while I was looking for a plotting library for C++....

3

On current GPU architectures, at the machine level, compilation of a shader program can depend on which other pipeline stages are active, what the inputs/outputs to those shaders are, as well as what the inputs and outputs of the overall pipeline are (vertex inputs and fragment outputs, for example). There's a lot of complicated architectural reasons why ...

3

Does Vulkan have the equivalent of the OpenGL separable shader objects, or are there any plans for it? They seem just so much more flexible. It would be "so much more flexible". But Vulkan is a low-level rendering API. It's job is to give you access to the hardware as close to the metal as possible; user-convenience isn't even in the top-5 goals ...

2

In raymarching, it's typical to change the direction of the ray according to the fragment coordinates, but leave the origin at vec3(0,0,0). In you code you add r, which is equivalent to vec3(x,y,1) to ray_pos, which starts at vec3(x,y,0). You scale x and y properly to lie from 0 to 1. So lets consider the angle of the ray along the x coordinate. Lets say x=1 ...

2

The easiest way to deal with this would be to provide thickness for the edges in the continuous setting. That is, make your edges out of solid capsules/cylinders, then you would not have this issue. Technically, this is is neither a supersampling nor a filtering technique, but rather a reformulation of the problem in the continuous setting. Another ...

1

I typically like to define a "GPUData" struct containing the fields that are going to the shader, and keep the GPUDatas for all the particles in an array. Then, when it's time to update the GPU buffer, you can just memcpy out of that array to your mapped buffer (or you can pass the array to glBufferSubData, etc). For the CPU state, rather than ...

1

In accord with the GLSL extension, gl_Layer in a mesh shader is part of the predefined gl_MeshPerPrimitiveNV output interface block. It seems to have the expected definition. This is a per-primitive parameter, so you can set it to a different value for each primitive you output. Basically, yes: layered rendering is available in task/mesh shaders. And since ...

1

Some curvature artifacts are normal when doing raymarching or ray-tracing. And if you are careful, you can even find curvature artifacts in some rastered scenes if the triangles are small enough. It may be that your camera is too close with respect to the size of your cube. In the following render, which uses raymarching, the greatest dimension of the box is ...

1

Broadly speaking, the way to deal with this is to check the depth value for that position on the screen. If the value is the value you cleared the depth buffer to, then you didn't write anything to that fragment.

1

The two are different because they do different things. Clipping and culling aren't the same thing at all. If an edge crosses a clip plane, the primitive has to be clipped to be within that plane. This means generating new primitives from the old one. If all vertices of a primitive are outside of a cull plane, then the entire primitive is culled. You use the ...

1

Yes you can. There are basically two approaches: You draw everything to a framebuffer object. Then you apply image processing fragment shaders to resulting texture of the previous draw call, where the shaders take the pervious texture with a sampler. or if you have a particular image and you would like to have more control on the numeric precision, the ...

1

Here is a (mostly) minimal version of an SDF for a line segment using a signed distance field as suggested in the comments. I take no credit for this code, it is your function pieced together with IQ's SDF function done in the style you listed above. Be sure to go to IQ's website, it is one of the best learning resource out there for this material. Though it ...

1

Consider #include. We use the tools provided by Khronos to make our own compiler that is part of a larger tool providing lots of specific functionality. Like handing out binding numbers, compiling spirv into linkable objects (with the restriction noted above), and others to numerous to mention here. If linking smaller SPIRV code snippets into a larger SPIRV ...

1

What you want is generally not possible for OpenGL's SPIR-V support. SPIR-V compiles to shader objects, and shader objects theoretically allow you to link multiple objects of the same stage in a program. However, OpenGL's usage of SPIR-V requires that each SPIR-V shader be a complete shader stage with its entrypoint function. So the requirement of shaderc ...

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