Questions tagged [vertex-shader]

Vertex shaders are executable programs that execute as part of the programmable geometry pipeline in modern graphics APIs such as e.g. Direct3D or OpenGL. Vertex shaders are usually hardware accelerated on consumer hardware nowadays. The vertex shader processes one vertex at a time, followed by primitive assembly, optionally geometry shader and transform feedback, clipping, and finally rasterization and fragment processing.

Vertex shaders were introduced as an extension to OpenGL 1.3 and as a feature of Direct3D 8.0 around 2001. They were the first step in making part of the render pipeline on consumer hardware freely programmable as opposed to hardwired functionality like the TnL stage or register combiners which until then were at best configurable in some limited way.

The vertex shader is typically the first programmable part of the pipeline. The scope of a vertex shader is a single vertex without any information about the connectivity between vertices or any other vertices and any state set as "uniform", i.e. data that is constant across everything in the current draw call. A vertex shader cannot create vertices nor discard them, and a vertex shader has no local memory or other way that can be used to communicate data from one vertex to another.

After vertices have been transformed by the vertex shader, they are assembled into primitives and optionally processed by a geometry shader, which runs on the scope of all vertices within a single primitive (such as a triangle) and optionally the surrounding vertices.

Resources:

911 questions
11
votes
2 answers

Combining quaternions with different pivot point

Background: I am currently implementing a skeletal animation shader in GLSL, and to save space and complexity I am using Quaternions for the bone rotations, using weighted quaternion multiplication (of each bone) to accumulate a "final rotation" for…
StrangeQuark
  • 143
  • 8
10
votes
2 answers

GLSL per vertex fixed size array

Is it possible in desktop GLSL to pass a fixed size array of floats to the vertex shader as an attribute? If yes, how? I want to have per vertex weights for character animation so I would like to have something like the following in my vertex…
Nicholas
  • 391
  • 2
  • 13
10
votes
2 answers

DirectX 11 Pixel Shader What Is SV_POSITION?

I am learning HLSL for DirectX 11, and I was wondering what exactly is the SV_POSITION that is the output for a Vertex Shader, and the input for a Pixel Shader. 1: Is this x,y,z of every pixel on your screen, or of the object? 2: Why is it 4 32bit…
Mike5050
  • 625
  • 1
  • 7
  • 22
10
votes
1 answer

GLSL webgl lerp normals from uv offset

I have a displacement map on a plane 512px* 512px (100x100 segments) , as the image for the displacement map scrolls left the vertices snap to position of height not blend smoothly, I have been looking at the mix() function and smooth-step() to…
Careen
  • 567
  • 1
  • 6
  • 26
10
votes
2 answers

GLSL - Using custom output attribute instead of gl_Position

I am currently learning OpenGL with shaders (3.3). There is one thing i can't seem to work out though. I have read that using built-in variables like gl_Position and gl_FragCoords is deprecated in OpenGL 3+, therefore I wanted to use my own output…
michy04
  • 317
  • 3
  • 11
9
votes
4 answers

cylinder impostor in GLSL

I am developing a small tool for 3D visualization of molecules. For my project i choose to make a thing in the way of what Mr "Brad Larson" did with his Apple software "Molecules". A link where you can find a small presentation of the technique used…
nadir
  • 91
  • 1
  • 3
9
votes
1 answer

OpenGL ES 2.0: Attribute vs Layout?

I'm using 'attribute' in a vertex shader to define a couple of variables like so: attribute mediump vec4 Position; attribute lowp vec4 SourceColor; Looking around, I found something called 'layout' which seems to do the same task. For example I…
MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
9
votes
1 answer

Why is the geometry shader processed after the vertex shader?

In both the OpenGL and Direct3D rendering pipelines, the geometry shader is processed after the vertex shader and before the fragment/pixel shader. Now obviously processing the geometry shader after the fragment/pixel shader makes no sense, but…
9
votes
1 answer

OpenGL - Water waves (with noise)

I am currently in the process of making water waves, so basically I am starting from the beginning. I have created a mesh which is basically a flat square and have animated it in the vertex shader (below is the code which achieves that) vtx.y =…
suphug22
  • 181
  • 1
  • 8
9
votes
1 answer

How to write pass-through vertex and fragment shaders for a framebuffer with attached texture?

I'm attempting to use shaders to modify a texture that is bound to a framebuffer, but I'm confused as to how the shaders get the "original" input values. I'm doing the following: GLuint textureId = 0; glGenTextures(1,…
Mark Ingram
  • 71,849
  • 51
  • 176
  • 230
9
votes
1 answer

Rendering rectangle texture with GLSL

I created a class that renders videoframes (on Mac) to a custom framebuffer object. As input I have a YUV texture, and I successfully created a fragment shader, which takes as input 3 rectangle textures (one for Y, U, and V planes each, the data for…
Bjoern
  • 633
  • 6
  • 16
8
votes
2 answers

Can you tell if a vertex attribute is enabled from within a vertex shader?

I was wondering if there was a way to tell if a vertex attribute is enabled from within a vertex shader? I know that if the vertex attribute is disabled all the values will be treated as 0.0, so I could do a test like the following: if (attribute ==…
James Bedford
  • 28,702
  • 8
  • 57
  • 64
8
votes
3 answers

ThreeJS [r85]: Custom Shader with Shadowmap

I've created a custom shader to be able to use a BlendMap with 4 different textures but I'm unable to get the shadows/lightning effects to work with it. What am I missing here? Or is there some other way I can achieve same functionality? Mesh…
8
votes
1 answer

Efficient way to manage matrices within a graphic application using Texture Buffer Object(s) (OpenGL)

I'm developping a little 3D Engine using OpenGL and GLSL. I currently use Texture Buffer Objects (TBOs) to store all my matrices (Proj, View, Model and Shadow Matrices). But I did some researches on what is the best way to handle matrices (I mean…
user1364743
  • 5,283
  • 6
  • 51
  • 90
8
votes
3 answers

Compute bounding quad of a sphere with vertex shader

I'm trying to implement an algorithm from a graphics paper and part of the algorithm is rendering spheres of known radius to a buffer. They say that they render the spheres by computing the location and size in a vertex shader and then doing…
Ben Jones
  • 919
  • 1
  • 8
  • 22
1
2
3
60 61