Stack Exchange Network

Stack Exchange network consists of 174 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.

4
votes
1answer
190 views

What graphics techniques can be used to simulate a color nebula effect?

I've been playing around with more advanced graphics these days (beyond the basic 2D UI and image effects that the iOS platform offers), and I'm wanting to implement a visual effect similar to how iOS'...
5
votes
2answers
241 views

Special directional light type

I am currently trying to implement a specific directional light type. This light type has been used in the game INSIDE and is called orthogonal spotlight (aka local directional light). I assume that ...
4
votes
1answer
293 views

Rotating an Object Around an Axis

I have a circular shape object, which I want to rotate like a fan along it's own axis. I can change the rotation in any direction i.e. dx, dy, dz using my transformation matrix. The following it's ...
4
votes
1answer
115 views

Colorblending shader recompilation scenarios

Context As I was trying to learn more about Vulkan, I learned that certain fixed-function steps could be implemented with shader code from this video (at around the spot where he talks about the ...
4
votes
1answer
177 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 ...
2
votes
1answer
346 views

Transforming fragment-to-camera to tangent space for parallax occlusion mapping

I'm trying to implement POM using this tutorial. As stated, I need to transform fragment-to-camera to tangent space and then pass it to a function. tangent space is computed using Assimp. Well I ...
8
votes
2answers
157 views

Encode two R11G11B10F buffers into one using Y'CbCr?

We are trying to optimize Lighting in fillrate. Integrated graphics chips are very slow in memory access. There are two Light Buffers: one for Diffuse and one for Specular. Both use format R11G11B10F....
5
votes
1answer
227 views

Where is the best place for Tangent-bitangent calculation, in shader or in C/CPP code?

I have two methods of calculating tangent and cotengent (needed for normalMap lighting calculation). The one is doing it from CPP code (with assimp library for example) The second is doing it ...
4
votes
0answers
150 views

selectively setting stencil value based on vertex property in vertex shader

Just like the question says. Is it possible to selectively set the value of the stencil buffer based on a property of a vertex, like the value of its normal, during its vertex processing phase? ...
4
votes
1answer
204 views

I dont understand how a GPU computes and branches, could you please help me fix this shader preformance

I have been working on how the GPU does parellel processing, and branching. However I am not yet to the point where I know how to make this shader more efficent. Essentially I dont know enough about ...
5
votes
2answers
746 views

Screenspace Normals - Creation, Normal Maps, and Unpacking

I'm trying to condense my Deferred Rendering G-Buffer. So I have some questions about getting 2-component Screenspace Normals. I know Frostbite and Killzone (the only two AAA company's G-Buffers I ...
5
votes
1answer
102 views

What are the fConstX in Spherical Harmonics?

At page (slide in reality) 12/20 of this tutorial it is shown a function used to project lights into SH coefficients, however the value of those coefficients is not given, what are their values and ...
5
votes
2answers
115 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, ...
5
votes
2answers
211 views

Sharing calculation result between shader programs in OpenGL

Question Is there a way to compute something in a first shader program (eg. screen-space coordinates from word-space ones) and access those results in an another shader program? Possible solutions ...
7
votes
1answer
586 views

Label Placing for thousands of objects with OpenGL

Question How to manage data (GPU,CPU) for dynamic label placement in 3d for thousands of objects (OpenGL)? Details objects: count: 2k-10k type: points/quads labels: bilboarding data: text and ...
9
votes
3answers
218 views

What algorithm is used in the animation of the uTorrent 's “About window”?

In a recent version of uTorrent , if you open the About Window, you will see an animated background , which is kind of waves that go on forever. How can this be achieved? Is this kind of a well-known ...
5
votes
1answer
95 views

Uniform not set, despite valid location

I try to write a simple triangle mesh renderer with OpenGL. ...
4
votes
1answer
114 views

Fastest shader compilation strategy on windows dx9 and dx11?

To compile shaders, I currently spin up a thread per core where each thread pulls a shader from a list and calls D3DX11CompileFromFile for dx11 and D3DXCompileShaderFromFile for dx9. I've heard it ...
7
votes
1answer
413 views

Open GL Shader Storage Buffer Objects to replace Vertex Attributes

At first: I already posted this on the stackoverflow community. I'm new and didn't know about this community here. I apologize. I basically got the same question as the guy who asked here: https://...
6
votes
2answers
217 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 ...
5
votes
1answer
479 views

Controlling Sobel edge thickness

I'm using a Sobel filter to draw an outline in a shader. How do I control its thickness? Here's my outlining code: ...
9
votes
1answer
2k views

Correct form of the GGX geometry term

I'm trying to implement a microfacet BRDF in my raytracer but I'm running into some issues. A lot of the papers and articles I've read define the partial geometry term as a function of the view and ...
4
votes
1answer
129 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,...
9
votes
2answers
492 views

Can (and how so) shaders paint screen pixels beyond those that occupied by the shaded mesh?

I have some experience programming geometry and compute shaders - but never adventured myself in really playing with the fragment shaders. Currently, I am trying to better understand how they work and ...
4
votes
0answers
167 views

Linear gradient shader ( Photoshop-like)

I'm searching a way to implement a linear gradient shader that behaves as the linear gradient in Photoshop (only the vertical case is necessary). It will be applied to 2D sprites. Currently I'm ...
3
votes
1answer
612 views

How to blend World Space Normals

I am trying to blend two world space normals inside a shader. One comes from a tangent space normal map converted into world space using a classic TBN matrix and the other one is a mesh normal map in ...
5
votes
1answer
683 views

How could I use bent normal map

This might be a general question but I have some difficulties about understanding baked bent normal maps and how to use it inside a shader in Unity. From what I understand, bent normals are ...
6
votes
1answer
189 views

Sine-based Tiled Procedural Bump

I am trying to implement this formula to generate bump but I am facing some issue. The result doesn't look the same it's much darker. Here is my result (without same parameters) but it is much darker ...
4
votes
0answers
110 views

Strange behaviour of glDisableVertexAttribArray() on devices

In my graphics engine, based on OpenGL ES 2.0 I am using standardized name for shader attributes like it is done in libGDX (such as a_position, a_normal, etc.). When 'activating' my vertex buffer for ...
10
votes
2answers
3k views

Cause of shadow acne

I know how shadow mapping works but I am not getting the cause of shadow acne! Can anyone tell me cause of shadow acne in a simple way and how is it related to depth map resolution?
4
votes
1answer
623 views

Guidance with Sphere-Map calculation in GLSL

I'm trying to achieve the same effect in OpenGL/GLSL as what Blender does when you add a texture, set to "Reflection" This ultimately is a way to fake specularity, or "metallicness" if I get it right....
6
votes
1answer
453 views

SSAO artefacts on iPhone (OpenGL ES)

I've never written shaders before, and now I'm trying to implement SSAO with SceneKit on OS X and iOS. I'm trying different SSAO shaders that I find, e.g. from Three.js, this one, and this one. On OS ...
11
votes
1answer
2k views

Loop performance in a shader

I am wondering what's the best way to integrate a dynamic loop function in a shader? First, it seems that dynamic arrays are not possible. So, is it better to create a maximum size array and only ...
5
votes
1answer
89 views

Seamlessly transitioning between nearby environment maps

I'm wondering what is the best way to achieve an effect like here: https://matterport.com/try/ when the camera is traveling between points in space. Apart from simple color crossfade there seems to ...
6
votes
1answer
694 views

HLSL Deferred Rendering

I've recently made the switch to Visual 2015 and the .fx files have been depreciated. My project contained .fx files for the shaders so I've been switching over. Only during the switch have I changed ...
8
votes
1answer
301 views

Explicit vs Automatic Attribute Binding

I'm a beginner in OpenGL and I've been doing some research on the topic of shaders and attributes. Most places I go say that explicit attribute binding (whether it be in the shader itself with ...
2
votes
0answers
122 views

Shadow Mapping Errors

I recently started to create a shadow mapping system in OpenTK. I ran into a problem: The depthtexture is always completly white -> no depth. Even if the color from the shader is changed (I know it ...
3
votes
1answer
264 views

Why does my lighting look incorrect?

I have a problem with lighting calculations. I am rotating the camera around a cube which was supposed to be illuminated by the light but the resulting lighting is very weird. Check out the image ...
9
votes
2answers
225 views

How to create a patterned object with variable pattern density in real-time?

Assume there is some value p, calculated per-frame, that varies continuously over the surface of an object. The value of p ...
5
votes
1answer
159 views

Why is rotating this prism in iOS Metal not rendering correctly?

I've set up a test project for learning Metal on iOS to do some rendering, but I'm a bit stumped on how to get a prism rotating correctly about its y axis. Here is the prism rendered without depth ...
10
votes
1answer
140 views

Per Vertex Computation in OpenGL Tesselation

I try to implement a position based cloth simulation using hardware tesselation. This means I want to just upload a control quad to the graphics card and then use tesselation and geometry shading to ...
5
votes
1answer
198 views

Shadow map projection issue

I am using Unity but this question might not be proper to this engine. I have projected the shadow map onto this sphere but there are grazing shadows. Is it possible to avoid it or to correct it as I ...
4
votes
1answer
367 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 ...
5
votes
0answers
257 views

How to make double working in OpenGL 4.1 on OS X ( Intel HD Graphics 5000 )?

I've recently rebuild shaders for my program and it stopped "working" ( black screen ) on OS X ( El Capitan ), but it's ok on Linux on GTX 660. I've tested it on another Apple hardware and it worked ...
7
votes
1answer
495 views

Flat shading for non-planar polygons

I'm trying to figure out how to properly implement flat shading for meshes containing non-planar polygons (using OpenGL/GLSL). The aim is to obtain something similar to the result Blender gives (all ...
7
votes
1answer
491 views

How to implement a realtime 2D light renderer with fog/colored light on the GPU?

Since long ago I wanted to implement a 2D lightning algorithm based on an idea I saw on YouTube. The video is realtime, but it runs on the CPU and the resolution is pretty low. I'm curious if anyone ...
4
votes
2answers
349 views

OpenGL vertex color

Why do I need to specify the same name for color input in fragment shader and output color from vertex shader? ...
4
votes
1answer
131 views

Multiple light pixel Shader in GLSL

I have wirtten a fragment shader that works just fine with a single light. Now I am trying to adpat it to work with 8 lights, the implement it in Processing. Clearly I am doing something wrong in the ...
7
votes
2answers
493 views

Best technique to draw overlapping colored line segments that follow the same route

I'm not too versed in computer graphics so my question may be vague. I'm given a sequence of GPS coordinates which I draw on an iOS map, and they define bus routes. Some of the bus routes happen to ...
8
votes
1answer
159 views

There are many shading languages built on top of GLSL or HLSL - what problems do they typically solve, and what worthwhile advancements do they make?

Whew, that was a long title. Either way, I'm asking this question, since I like to think about various things, and it occurred to me that there isn't really any simple, open source layers on top of ...