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
0answers
170 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
227 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
60 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
129 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: ...
9
votes
2answers
779 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 ...
10
votes
1answer
2k 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.
7
votes
1answer
419 views

Shader uniform performance

I'd like to know if there's any performance impact based on how I struct my shader uniforms. For instance, is passing 4 floats worse than passing a single vec4?
11
votes
1answer
2k views

Do I need to rebind uniforms or attributes when changing shader programs?

Rendering the scene usually involves more than one shader program which, in my case, all use the same attributes and share at least some of the uniforms. To have them working properly, I currently ...
6
votes
2answers
236 views

What factors affect which shader language to learn?

I don't know any shader languages. I've heard of GLSL and HLSL, and I'm interested in learning one or both. Are there significant differences between them that would make one or other better in ...
7
votes
2answers
756 views

Multiple Lights Shading - One Pass vs Multiple Passes

I was looking into ways to implement multiple lights shading and I've noticed Unity uses multiple passes to achieve it. It performs a base pass to apply the brightest directional pixel light + 4 ...
13
votes
1answer
587 views

Is a constant condition more costly than switching shaders?

In general, branching in shaders is not a good idea. But now I have a shader with a condition that is constant with respect to the entire draw call. So the branch that is executed is always the same ...
18
votes
1answer
1k views

Why is this conditional in my fragment shader so slow?

I have set up some FPS-measuring code in WebGL (based on this SO answer) and have discovered some oddities with the performance of my fragment shader. The code just renders a single quad (or rather ...
10
votes
1answer
1k views

Efficient rendering with many light sources

To render a scene with a single light source using phong shading, one can calculate the final color of each fragment passed into the fragment shader based on the ambient/diffuse/specular components of ...