Questions tagged [fragment-shader]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Question regarding Memory-Efficient Order-Independent Transparency with Dynamic Fragment Buffer

I am currently reading the pdf regarding Memory-Efficient Order-Independent Transparency with Dynamic Fragment Buffer. in there it is proposed to do two steps before sorting the fragments: First, for ...
0
votes
1answer
50 views

Tiling in GLSL creates unwanted seams

I'm writing a shader that creates a grid with coloured tiles. The color is derived from a pixel at that location on a texture. But around the tiles I get these unwanted seams. I can't seem to figure ...
1
vote
1answer
93 views

OpenGL transparency - object behind is not rendered

I'm trying to implement voxel world using OpenGL (Core 3.3). I've come across a problem with transparency. It looks like sometimes GPU decides to not render stuff that would be important. Can you help ...
0
votes
0answers
51 views

Examples of cases where you write depth value in Fragment Shader?

I've very less knowledge when it comes to rasterization and typical rendering in games and other applications. So I was reading up on the rendering pipeline and found that the hardware could do early ...
0
votes
1answer
61 views

Level of detail passed from vertex shader to fragment shader

I am looking at a sample code from a respected source and the mipmap level-of-detail parameter (float) is passed to the vertex shader as a uniform which then passes to the fragment shader without ...
1
vote
1answer
27 views

Is fragment shader run on fragments that are outside of rasterized geometry?

In deferred rendering, I first write world position to G-Buffer, and then in shading part, I want to use that information to reproject in the previous frame and then write the final color. However, ...
0
votes
0answers
39 views

Order Independent Transparency: How to approach sorting

In an "Order Independent Transparency" implementation, one faces sorting a large amount of (as many as the number of pixels in the viewport) sets of data with relatively small number of ...
0
votes
1answer
152 views

gl_ClipDistance vs gl_CullDistance

Why are there very similar yet distinct arrays: gl_ClipDistance[] vs gl_CullDistance[]? What would be some use cases where the ...
1
vote
1answer
726 views

Understanding fragment shader coordinate system

I'm trying to create an infinitely panable grid using fragment shaders (C++/OpenGL/GLSL), and I'm having a bit of difficulty understanding the coordinate system. This is my fragment shader code, ...
0
votes
1answer
230 views

What is the most efficient line algorithm using a shader program

I'm new to shaders and I have been experimenting with them in shadertoy. I'm trying to get a deeper understanding of the graphics pipeline and I want to implement some features using shaders. I want ...
0
votes
0answers
13 views

Calculating Bounding Boxes from JFA

I am working on getting bounding boxes from images using the GPU, I am using as an example this article by demofox which has included some shadertoy examples. The JFA algorithm is like this: ...
0
votes
0answers
18 views

Rendering different array types in the same vertex/fragment shader?

I have a pretty basic widget rendering, largely based upon the learnopengl.com "hello triangle." I'm actually using a tristrip to create two triangles, forming a semi-opaque square over the ...
1
vote
1answer
64 views

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

I have an image and I want to draw an arbitrary number of objects on that image. The center coordinates of those objects are calculated inside a fragment shader after series of image processing ...
1
vote
0answers
134 views

How could I remove this colour interpolation artefact across a quad?

I've been reading up on a vulkan tutorial online, here: https://vulkan-tutorial.com. This question should apply to any 3D rendering API however. In this lesson https://vulkan-tutorial.com/...
0
votes
0answers
46 views

GPU accelerated 2D graphics library with signed distance functions

I want to create my own 2D graphics library using signed distance functions where everything is drawn on the GPU. Browsing the web I quickly found Inigo Quilez website that describes how to draw basic ...
7
votes
1answer
2k views

Performance of Compute Shaders vs. Fragment Shaders for Deferred Rendering

I have written a deferred renderer that can use either a fragment shader or a compute shader to execute the shading pass. Unfortunately, the compute shader implementation runs slower. I'm trying to ...
1
vote
1answer
99 views

Help me understand the voronoi shader

I am trying to understand the voronoi shader implemented in the Book of Shaders in the Tiling and iteration section: https://thebookofshaders.com/12/ Specifically how do these lines calculate the ...
3
votes
1answer
400 views

Interpolation in Graphics Pipeline

I am trying to program my own version of WEBGL graphics pipeline in python, however, I am confused as to where the color interpolation takes place in the pipeline. According to my research, it happens ...
2
votes
1answer
365 views

SDF rendering for large world

There are lots of cool things you can do with SDFs to render implicit surfaces. Most of the examples I've seen have been “all in the shader”, where the entire distance function is encoded in the ...
2
votes
0answers
112 views

Calculate the distance between two 3d points in screen coordinates

Given the Point A with the coordinates gl_FragCoord.xy, I have to find the distance to the Center of the cube face to which it belongs in screen coordinates. ...
3
votes
1answer
1k views

gl_FragCoord and glViewport

I've been scanning the specifications for both OpenGL and GLSL, and I can't find a definitive answer as to how exactly are gl_FragCoord's ...
1
vote
0answers
56 views

Anti aliasing thin features in textures

Assume I have a texture with a repeating line pattern. The lines are exactly 2 texels wide (really thin). Ans very spaced out (50 texels in between each line). I am now struggling with the ...
3
votes
0answers
82 views

Trying to optimize texture mapping

We are developing a PPI plot for a radar system, similar to the following: NOTE: 1 radial is defined as a single slice of data within the circle, and 1 range gate is defined as a single point along a ...
2
votes
0answers
73 views

Show the edges between the clipping plane and clipped objects [closed]

I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection. My fragment shader currently does something ...
2
votes
1answer
140 views

Alpha component in color buffer affects RGB components?

I'm looking for a way to make my surface semitransparent, and for now i ended up using this configuration: ...
1
vote
2answers
494 views

Writing data to a shader resource at runtime in DX12

I'm hoping to port my existing toy raytracer to a window so that I can see samples accumulate over time. And then port over to Pixar's pmj02: https://graphics.pixar.com/library/...
5
votes
1answer
453 views

How to match Blenders polynomial lens distortion model with GLSL?

I'm trying to re-implement Blenders (libmv) polynomial lens distortion model using shadertoy, in order to apply the lens distortion in another application ideally by generating a STMap for that. I ...
1
vote
0answers
118 views

Veldrid: Only execute fragment shader

Having an HLSL shader like this: ...
1
vote
1answer
564 views

Curve rotation in GLSL fragment shader

I'm trying to figure out the correct math to rotate and translate a curve displayed in a fragment shader. What I try to accomplish is to define a curve, for example a sine curve, in a local ...
5
votes
1answer
1k views

Manually fetching 8 neighboring texels from 3D texture greatly decreases performance

I'm implementing manual interpolation between texels in a 3D texture to be able to discard some of them when needed. Compared to hardware interpolation, this process takes a lot of time. If I simply ...
2
votes
2answers
98 views

Shader cannot move texture x, y location

Crossposted https://forum.openframeworks.cc/t/shader-cannot-move-texture-x-y-location/29395 Hello I am trying to move the x y location of the texture using this code but it doest not work. ...
-2
votes
1answer
116 views

gaussFactorForOffset cannot call a non-function how to fixed this code?

Crossposted here http://forum.lwjgl.org/index.php?topic=6724 Hello guys I am trying to blur image using fragment shader but it is not smooth.. I search the internet and I found similar problem... ...
1
vote
1answer
1k views

Is it possible to override or disable blending per pixel

I'm rendering transparent objects in separate framebuffer then compositing it with opaque one to get final image. The transparent pass has additive blending: ...
7
votes
1answer
1k views

Ray tracing - partial derivatives for texture lookup

I'm doing some ray tracing on GPU using a fragment shader... How can I calculate texture coordinates partial derivatives with respect to screen coordinates so I could perform filtered texture lookup ...
2
votes
0answers
76 views

How can I draw a line whose position is given in UV space and its width in screen space?

In a fragment shader, I need to draw a line at a given value of u. The shader is applied to a planar polygon mesh that's being drawn in the scene with a perspective camera. (It isn't a full-screen ...
4
votes
1answer
379 views

Z buffer working in OpenGL

After Z-Buffer Testing does the fragment shader run on the discarded fragments? Does the Z-Test happen after the fragment shader runs? Please, tell me the step by step events that occur in the Z-Test....
6
votes
2answers
5k views

Advice on how to create GLSL 2D soft smoke/cloud shader

I want to recreate this smoke/cloud effect which is used in the Arrival (2016) movie end credits. I uploaded a sped up version of the credits to see the smoke dynamics. http://streamable.com/n3309 ...
5
votes
1answer
4k views

Fragment shader's output variables

EDIT: This is a duplicate of a question from stack overflow: https://stackoverflow.com/questions/9222217/how-does-the-fragment-shader-know-what-variable-to-use-for-the-color-of-a-pixel If you want to ...
6
votes
0answers
891 views

OpenGL texelFetch causes black stripes

THE SHORT VERSION In my fragment shader I'm reading (using texelFetch) multiple times the same texel from a texture (created by another fragment shader) and write it to the output render buffer. ...
3
votes
1answer
228 views

OpenGL ES Frag Shader - Branching

Working on optimizing a fragment shader which is slowing down my OpenGL ES 2.0 shader based game. This is used with a shadow buffer to determine if the fragment/pixel is inside a shadow volume. The ...
5
votes
2answers
134 views

Will the gaussian kernels in this fragment shader be computed for every fragment?

I am running this fragment shader on every pixel on screen. I am trying to make it as efficient as possible. BTW I am running open gl es 2.0. The code segment below is only a sample from the code, ...
12
votes
1answer
1k views

Using a LUT to speed up a trig heavy shader for mobile devices

I am trying to get this shader to run on a really old iDevice, as well as eventually Androids. Even when I reduce the code down to 2 sine functions per fragment the shader runs at about 20fps. I ...
4
votes
1answer
710 views

How to correctly implement Lambertian BRDF with point light

I'm implementing a simple Lamberitan BRDF in GLSL, using a point light source. My fragment shader simply returns light_colour * 1.0/PI * cosine, which should model ...
1
vote
1answer
203 views

How to ensure a fragment shader only runs once

I am trying to programmatically figure out how many "texture2d " calls the gpu can make before the fps drops below 60fps. My current way of doing this is to have a fragment shader with a for loop ...
1
vote
1answer
389 views

Why does substracting -1 in shader fail for a float data type?

I am loading a texture in a WebGL fragment shader (GLSL version 1.00). This is my working code: ...
5
votes
2answers
361 views

In a shader, how to store fragment coordinates in a spatial partitioning from one pass to the next?

I have a post-effect camera-shader in which I want to implement a simple spatial partitioning of the screen between two passes of the fragment shader. The first pass should divide the screen into ...
2
votes
1answer
180 views

Count number of green fragments that are within a given distance from each screen fragment

First of all, let me explain what I am really trying to achieve. In a post-effect shader acting on a camera-renderer, I want to change the color of each fragment depending on how many green (RGBA = 0,...
3
votes
1answer
516 views

Shader won't work

I have managed to implement a garoud shader with specular lighting efects in Processing 3.0 . Now I am trying with a fragment Phong shader but cannot make it work. I can´t find where is the error. It ...
11
votes
1answer
8k views

Why is accessing textures much slower when calculating the texture coordinate in the fragment shader?

When using textures in GLSL, it is best to calculate the final texture coordinates in the vertex shader and hand them over to the fragment shader using varyings. ...