Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [shader]

For all questions related to shaders, i.e. the programmable part of the GPU pipeline. For language-specific shader questions, see also the [glsl] and [hlsl] tags.

2
votes
2answers
166 views

How to generate chaotic halftone pattern?

I'm trying to generate a random halftone like below image: this is a simple halftone that I tried, but I need a random halftone ...
1
vote
0answers
215 views

Depth aware blur - Kawase

I am using this Kawase Blur, to apply blur onto my buffer. But I would like to apply this blur in an uniform way, no matter the distance of the objects from the camera. I guess that I need to use the ...
3
votes
2answers
632 views

How to use the data manipulated in OpenGL Compute Shader

I'm working with OpenGL and facing some difficulties because I'm not familiar with OpenGL. I tried to search related example in Google, but I could not find some useful code. There are five arrays. ...
1
vote
1answer
86 views

Process of compute shader in OpenGL

I'am curious about compute shader in OpenGL. Let's assume the number of points (vec4) is 900 and the work group size(= the number of work items) is 256 Then, We would have four work groups because ...
6
votes
0answers
153 views

Avoiding Mach band effect when using multiple lights

I wrote a simple Phong shader with two directional lights for a project, and noticed an unpleasant artifact in the lighting. Where both lights are illuminating the same region, dark bands appear at ...
1
vote
1answer
102 views

Questions about Blur effect

I am working on a specific blur effect that implies several behaviours. But before I would like to know what you think about those blurring algorithms according to performances and quality : Kawase ...
1
vote
3answers
130 views

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

Here's an example of the flat shaded squares I want. But my squares are made of two triangles, and I'm getting flat shading of those triangles. In openGLES 3.1 (android), I'm turning off ...
1
vote
1answer
79 views

What's the difference between two code in shader?

I'm doing a project with assimp. I got confused with the weird situation for me. I think the both code are exactly same, but the result is different. Why the codes act differently? (vertex shader) ...
1
vote
1answer
326 views

Shader storage buffer indexing by 4 bytes instead of 3?

I am trying to send rendering information for an instancing rendering using shader buffer objects. My current problem is that I have 2 shader buffer objects, one which works just fine, and another ...
5
votes
1answer
50 views

Role of gl.vertexAttrib

I'm re-learning WebGL, and I stumbled upon gl.vertexAttribPointer and gl.vertexAttrib. To my knowledge, gl.vertexAttribPointer tells the GPU how the data in the currently binded buffer relates to the ...
5
votes
1answer
5k views

GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?

I'm new to shaders and know that you can color pixels with gl_FragColor but sometimes there is this thing: ...
4
votes
1answer
121 views

Creating a vanishing point perspective shader

I have done my due hour of research before asking this question, it's a simple question, but I have found no hint at an answer online. I want the ability to extend an object infinitely in one ...
5
votes
0answers
203 views

In Metal, what performance advantages are there, if any, to using vertex descriptors and the [[stage_in]] qualifier?

Metal seems to provide two very different ways to access vertex data in your vertex shader. You can: Create an MTLVertexDescriptor object, which describes vertex ...
1
vote
0answers
71 views

Round Box SDF scaling issue

I am using the Inigo Quilez SDF function to generate a round box shape. The aim is to be able to control the shape scale, smoothness and roundness. I've achieved a pretty good result but I am facing ...
2
votes
1answer
101 views

DX9 Shadow map PCF issue

I am trying to do simple PCF with Unity but I am facing some issues and I don't know where they come from. If anybody has an idea... Here are two examples ...
7
votes
1answer
637 views

Constant screen-space-width rim shading

As of lately I've been studying a bit of shaders (in Unity), and am trying to recreate the "light-based inline" that can be observed in the latest Legend of Zelda. But maybe the task is a bit above my ...
5
votes
1answer
170 views

What is better to use for real-time computing Mesh - Plane intersection points, GPU or CPU?

I want to write plugin (library) for Unity3d (it doesn't matter which framework I will choose for this, question is ), for cutting arbitrary mesh with plane (for simplicity it will be plane for ...
6
votes
0answers
152 views

Dual paraboloid shadow texture edge seams

I implemented dual paraboloid shadows for point lights. The goal was to reduce the number of shadow passes. Also the target is GLES3.0 so no layered rendering is available. The shadows work, and ...
8
votes
1answer
644 views

How can I offset/shrink a triangular polygon in GLSL?

I need to offset all (blue) triangles, each independently of the others, using the vertex-shader. In order to manipulate the triangle as a whole, I've created custom (vec3) attributes for each vertex (...
4
votes
1answer
696 views

Phong shading in OpenGL: line of light from the center of the world

I implemented a Phong shader in GLSL, but there is a bug. What you are (supposed) to see down below: A point light source rotating around the center of the world, with a radiance of (0, 100, 0) A ...
1
vote
0answers
48 views

Specular Highlight Gray When Behind Model

What would cause this grayscaled backside? When my camera is behind my model I see a grayscale specular highlight. However, in front of it is perfectly fine. Here's my shading code. (Software ...
1
vote
2answers
3k views

Send Texture to Shader

I've been following the LearnOpenGL tutorials and I've come across a piece of code I don't understand. ...
5
votes
2answers
152 views

Strange behaviour in vertex shader with divisions

This is the vertex shader code: ...
5
votes
1answer
216 views

Special Texture Stretching without deformation

I am trying to achieve a special texture stretching effect in my shader. Here is how I define my uv before sampling my texture, nothing really special. ...
12
votes
2answers
1k views

Derivative maps vs. Tangent Space Normal maps

I discovered that some engines use derivative maps instead of tangent space normal maps. After some reading, it seems to be a really awesome way to replace tangent space normals but are there some ...
3
votes
1answer
208 views

Easing curves on the GPU?

I was thinking that I could pass a timestamp in (from requestAnimationFrame) to the vert shader, and just have my easing curves in the GPU instead of using (for example) Tween.js from the outside. Is ...
1
vote
1answer
178 views

How to organize Lights and Models?

I'm interested in how to organize in code (I prefer C++) lighting. Problem is: I have Scene which contains Model where model ...
5
votes
1answer
1k views

Alpha blending between two overlapping semi-transparent shapes

I am working on a 2D lighting system for my game. My approach has been to: Create a transparency quad representing 'darkness'. Create a stencil shader for light sources to clip from the darkness quad....
7
votes
2answers
2k 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 ...
3
votes
1answer
334 views

GPU not reaching 100% usage when frame rate is dropping

I am making an iOS game using Unity. I am testing some shaders that I have made for the game, and in some cases the device will run at under 30 FPS but not have 100% device utilization. Sometimes a ...
4
votes
0answers
188 views

How to output a 32 floating value in a render buffer with fragment shader

I would like to downsample my depth buffer and my normals. For that, I take in input of my shader, the corresponding textures (depth, normal), and I write my new values in a multi render target. I ...
5
votes
1answer
1k views

What are Jittering and Dithering

I've heard a lot about jittering and dithering but I would like to know more about those techniques, especially when used to avoid visible sampling in a fragment shader. What are the differences ...
2
votes
0answers
114 views

If statements in shaders - implications and consequences [duplicate]

I've heard a lot that in shader development, you absolutely need to avoid branching and so if statements. But why? Does this have a real impact on performances on old and modern hardware or is it ...
6
votes
1answer
2k 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 ...
4
votes
1answer
765 views

Unable to pass custom Matrix4 to GLSL as a uniform

I am fairly new to graphics programming and I am trying to pass a custom Matrix4 (non-glm) to my vertex shader by using a uniform. ...
1
vote
0answers
44 views

Rounding rules for mip level with point sampling

In shaders, when using SampleLevel intrinsic, if we pass 0.5 in the mip level parameter, and the sampler is a ...
2
votes
0answers
121 views

How does this function calculate normals of a mesh? [closed]

I have trouble understanding the following Javascript code. It calculates, given a mesh described by its vertices vs and indices ...
4
votes
1answer
423 views

How to properly direct light sample GGX in path tracing

I have been trying to implement the GGX shader in my path tracer based on this paper: Microfacet Models for Refraction through Rough Surfaces It's pretty clear how the importance sampling works, but I ...
6
votes
1answer
176 views

Mix shader looks wrong on my path tracer

I apologize if my methods seem way off because this is my first time trying to build a path tracer and I'm struggling quite a bit. Currently, I am trying to mimic the "mix shader" node in Blender 3D ...
4
votes
1answer
321 views

Benchmark GLSL fragment shader

How can I benchmark a fragment shader? What my shader does is basically lots of floating point operations, since it's doing some procedural stuff.
5
votes
2answers
851 views

Is there a way to draw spherical objects without triangles?

It seems that in all existing graphics libraries, 3D objects are always described in terms of triangles. Drawing triangles can be implemented very efficiently on video hardware and since any 3D object ...
6
votes
1answer
1k views

Modern way of light sources in OpenGL?

In older versions of OpenGL there were things like: glLight(...) gl_LightSourceParameters The modern way of doing lighting is passing light source parameters manually to the shader in vao-s? Or ...
6
votes
1answer
973 views

What's the difference between Sample and tex2D

I am mainly using Unity but I think that it's not related to this engine, and I am wondering what's the difference between using tex2D and ...
6
votes
1answer
234 views

B-Spline patches on the tessellation shader. How to get the control points

I have a polygonal mesh with ngons in it. I want to make a tessellation shader to which I send only the regular quads in such a way that it can construct a B-Spline surfaces across it. I came across ...
6
votes
0answers
437 views

Percentage-closer Soft Shadows implementation

I am trying to implement the Percentage-closer Soft Shadows (PCSS) from NVidia inside Unity but I am facing some issue and I don't know where they come from and then, I do not know how to solve them......
6
votes
2answers
161 views

What is the correct way to put different textures on different parts of an object?

I tried passing a variable from the vertex shader to tell the fragment shader whether or not I wanted part of an object textured. That way I could write another shader for the other parts of the ...
6
votes
1answer
623 views

UV Coordinate Interpolation in Compute Shader

I am trying to get the screen space position of each pixel in a texture on a mesh and write it into a texture. I was hoping to use a compute shader to do this: ...
5
votes
1answer
806 views

Attribute Location in Multiple Shader Programs

I'm trying to switch between the rendering of two different scenes as fast as possible using OpenGL. For all my OpenGL related stuff I wrote a wrapper-class which provides a quite easy way of adding ...
5
votes
3answers
340 views

Texture coordinates projection

I have some classic texture coordinates and as a normal behaviour they follow the mesh's transformations. I am trying to use the same texture coordinates behaviour but without being affected by the ...
8
votes
2answers
649 views

Eye Parallax Refraction

I am trying to implement the Parallax Refraction effect explained by Jorge Jimenez on this presentation: http://www.iryoku.com/downloads/Next-Generation-Character-Rendering-v6.pptx and I am facing ...