Questions tagged [shader]

A shader is a program to perform calculations on geometry or pixel data in computer graphics.

A shader is a program to perform calculations on geometry or pixel data in computer graphics. With the rapid progress and availability of consumer GPUs during the last decade, an initially software-only solution for high-end RenderMan workstations became widely available. Today, the term is mostly associated with , , , or , which allow convenient, hardware agnostic high-level programmability on consumer GPUs.

6931 questions
28
votes
4 answers

ThreeJS predefined shader attributes / uniforms

I have started with ThreeJS's WebGL renderer after doing some "regular" WebGL with no additional libraries + GLSL shaders. I am trying to write custom shaders now in my ThreeJS program and I noticed that ThreeJS takes care of a lot of the standard…
Grüse
  • 1,096
  • 2
  • 11
  • 24
26
votes
3 answers

glLineStipple deprecated in OpenGL 3.1

glLineStipple has been deprecated in the latest OpenGL APIs. What is it replaced with? If not replaced, how can I get a similar effect? (I don't want to use a compatibility profile of course...)
Vincent
  • 289
  • 1
  • 3
  • 9
26
votes
2 answers

Why it is necessary to set precision for the fragment shader?

I learn WebGL. Next shaders work fine: // vertex.shader // precision mediump float; attribute vec4 a_Position; attribute float a_PointSize; void main(){ gl_Position = a_Position; gl_PointSize = a_PointSize; } and // fragment.shader precision…
Andrey Bushman
  • 11,712
  • 17
  • 87
  • 182
26
votes
3 answers

What does the GL_ARRAY_BUFFER target mean in glBindBuffer?

I was confused about the VBO, glGenBuffers(1, &positionBufferObject); glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject); Besides GL_ARRAY_BUFFER, there are other target types: GL_ATOMIC_COUNTER_BUFFER, GL_COPY_READ_BUFFER... However, the Opengl…
lightrek
  • 951
  • 3
  • 14
  • 30
26
votes
2 answers

GLSL gl_FragCoord.z Calculation and Setting gl_FragDepth

So, I've got an imposter (the real geometry is a cube, possibly clipped, and the imposter geometry is a Menger sponge) and I need to calculate its depth. I can calculate the amount to offset in world space fairly easily. Unfortunately, I've spent…
geometrian
  • 14,775
  • 10
  • 56
  • 132
25
votes
1 answer

How does the default GLSL shaders look like? for version 330

What do the default vertex, fragment and geometry GLSL shaders look like for version #330? I'll be using #version 330 GLSL Version 3.30 NVIDIA via Cg compiler, because that is what my graphics card supports. With default shaders, I mean shaders that…
ColacX
  • 3,928
  • 6
  • 34
  • 36
25
votes
2 answers

Using gl_FragColor vs. out vec4 color?

There seems to be a lot of ambiguity about gl_FragColor being deprecated. For example, it is missing in the GLSL 4.40 specification, but it is included in the GLSL 4.60 specification. What is the safest, most compatible, most supported strategy? …
IntellectualKitty
  • 523
  • 1
  • 6
  • 12
25
votes
4 answers

What does glUseProgram(0) do?

The OpenGL docs for glUseProgram claim that calling it with an argument of zero will cause the results of shader execution to be undefined. However, after a little searching I've seen a couple examples of people using glUseProgram to uninstall the…
user11171
  • 3,821
  • 5
  • 26
  • 35
24
votes
2 answers

Why do I need to define a precision value in webgl shaders?

I'm trying to get this tutorial to work but I ran into two issues, one of which is the following. When I run the code as is I get an error in the fragment shader saying: THREE.WebGLShader: gl.getShaderInfoLog() ERROR: 0:2: '' : No precision…
Flavio
  • 1,507
  • 5
  • 17
  • 30
24
votes
0 answers

Unity Camera Patch

I've been struggling to get the camera patch sample to work in unity. I finally succeeded to make it work in the editor but for the life of me can't make it work on my samsung galaxy s3(android). The only difference I can see is cameraTextureRatio …
Abhay Shankar
  • 241
  • 1
  • 5
24
votes
2 answers

How to render Android's YUV-NV21 camera image on the background in libgdx with OpenGLES 2.0 in real-time?

Unlike Android, I'm relatively new to GL/libgdx. The task I need to solve, namely rendering the Android camera's YUV-NV21 preview image to the screen background inside libgdx in real time is multi-faceted. Here are the main concerns: Android…
Ayberk Özgür
  • 4,986
  • 4
  • 38
  • 58
24
votes
2 answers

How does vertex shader pass color information to fragment shader?

In a simple hello-world OpenGL program, which simply draws a static triangle on the window, when I set the 3 vertex of the triangle to red, green and blue color, the triangle is filled with gradient. But when I use shaders like this: Vertex…
RnMss
  • 3,696
  • 3
  • 28
  • 37
23
votes
3 answers

Using HTML5 WebGL Shaders for Computation

It seems to me like one could theoretically use WebGL for computation--such as computing primes or π or something along those lines. However, from what little I've seen, the shader itself isn't written in Javascript, so I have a few…
skeggse
  • 6,103
  • 11
  • 57
  • 81
23
votes
3 answers

Clipping-planes in OpenGL ES 2.0

I need to clip a few hundred objects under a clipping plane in OpenGL ES 2.0 and would appreciate ideas from people more experienced with this subset of OpenGL. In OpenGL ES 1.x there is glClipPlane. On the desktop you have glClipPlane, or…
Emil Romanus
  • 794
  • 1
  • 4
  • 8
23
votes
2 answers

"flat" qualifier in glsl?

So I was reading "The Official OpenGL Guide" and in a section where they taught material lighting, they suddenly used the "flat" qualifier for an input variable in the fragment shader. I google'd the matter and all I came up with was "flat shading"…
McLovin
  • 3,295
  • 7
  • 32
  • 67