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.

Filter by
Sorted by
Tagged with
5
votes
1answer
323 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
175 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? ...
5
votes
1answer
228 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
1k 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 ...
4
votes
1answer
112 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
131 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
497 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 ...
6
votes
1answer
864 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 ...
8
votes
3answers
245 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 ...
4
votes
1answer
121 views

Uniform not set, despite valid location

I try to write a simple triangle mesh renderer with OpenGL. ...
3
votes
1answer
129 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 ...
6
votes
1answer
571 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://...
5
votes
2answers
277 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 ...
4
votes
1answer
838 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: ...
10
votes
1answer
4k 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 ...
3
votes
1answer
168 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,...
8
votes
2answers
619 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 ...
3
votes
0answers
209 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
928 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 ...
4
votes
1answer
2k 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 ...
5
votes
1answer
219 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
143 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
6k 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
898 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
538 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
4k 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 ...
4
votes
1answer
109 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
779 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 ...
7
votes
1answer
490 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
135 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
496 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 ...
8
votes
2answers
256 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
199 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 ...
9
votes
1answer
185 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 ...
6
votes
1answer
219 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
502 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 ...
4
votes
0answers
310 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 ...
6
votes
1answer
616 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
657 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
492 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
155 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 ...
6
votes
2answers
565 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
189 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 ...
4
votes
0answers
251 views

Indexing gl_TessLevelOuter[] with gl_InvocationID on a tessellation control shader

I'm using hardware tessellation to render a terrain mesh with variable LOD. I have this snippet on my tessellation control shader: ...
5
votes
1answer
328 views

Can't get output from a GLSL code

I'm trying to learn GLSL, I'm following this tutorial. I've done everything according to the tutorials but I can't get any output from my code. As you see I'm checking for both compile errors and ...
5
votes
1answer
65 views

Can the uniform id be changed from run to run on the same machine?

I have a shader which has several uniform variables: uniform vec4 a; uniform vec4 b; uniform vec4 c; I'm getting these handles using ...
4
votes
0answers
130 views

How to extract a BRDF from a shader [closed]

For normalization purposes, how to "extract" a BRDF function from an ad-hoc piece of pixel shading code ? If we have a shader function like: ...
10
votes
2answers
1k views

Is using many texture maps bad for caching?

If I have many textures (say 5+ maps) bound to the same texture unit, does it work worse for cache than if I had only 2 or 3 textures?
9
votes
1answer
1k views

How does Texture Cache work in Tile Based Rendering GPU

How does cache work with tile based rendering? Are there any tips on how to improve cache hit ratio for it? (for instance, if tiles are processed horizontally and I have vertical segments of ...
11
votes
1answer
4k views

How does Texture Cache work considering multiple shader units

Modern GPUs have many parallel shading units. I'd like to know how texture cache is managed in that scenario.