Questions tagged [shaders]

a computer program that runs on graphics hardware and provides a high degree of control over how scenes are rendered

Definition

In the field of computer graphics, a shader is a computer program that is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility. Shaders are used to program the graphics processing unit (GPU) programmable rendering pipeline, which has mostly superseded the fixed-function pipeline that allowed only common geometry transformation and pixel-shading functions; with shaders, customized effects can be used.

Types of Shaders

  • Vertex Shaders - Manipulates vertex data.
  • Pixel Shaders - Determines the color that each pixel should have.
  • Geometry Shaders - Generate new graphical primitives based on the ones it receives.
  • Compute Shaders - Computes arbitrary information. Supported from OpenGL 4.3 and Direct3D 10.
  • Mesh and Task Shaders - Brings the compute programming model to the geometry pipeline, replacing vertex and tessellation shaders.

Popular Languages

  • HLSL
  • GLSL
  • Metal Shading Language
  • Cg

Getting Started

1981 questions
20
votes
2 answers

How would one construct a realistic "infrared vision" effect?

How would you go about constructing a realistic infrared vision effect with shaders? By realistic I mean one that looks realistic, like this example. I have an idea about making a texture to determine how much heat a material emits and then…
Mikael Högström
  • 1,705
  • 13
  • 21
11
votes
3 answers

Is there an alternative to decals that will let me put bullet holes on a complicated object?

I'm trying to figure out a way to do "bullet holes" but actually apply the texture at the shader level? If I'm dealing with a model which doesn't have a "flat" face I'd like to be able to wrap the "decal" across the model. Anyone point me at a…
Bob dole
  • 111
  • 3
9
votes
1 answer

What is a rim shader used for?

What does a rim shader do and what is it used for? In what cases would it make sense to utilize a rim shader?
user4474
5
votes
3 answers

Vertex Shader Fundamental Workings

I understand that water ripples (e.g. stone thrown into a pond) are often handled with vertex shaders. My first question is: are the ripples nothing more than an algorithm that is the function of time? If yes, it means that the size and diameter of…
Mystagogue
  • 175
  • 6
4
votes
1 answer

How to draw a Bezier line with shaders?

I found a shader code to draw a filled Quadratic Bezier in https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch25.html How can I use something similar to draw a Bezier line that follows the same path?
Zhen
  • 1,316
  • 1
  • 13
  • 30
2
votes
1 answer

How does the GPU know how to form triangles for a given mesh?

I have just begun learning shader programing. What I learned is that the rasteriser groups three vertices to form a triangle for doing further operations. If that's true how does the rasteriser determines appropriate vertices which form a triangle…
2
votes
2 answers

vertex/pixel shaders and "materials"

What relationship is there, if any, of "materials" and vertex/pixel shaders (or the "effects" that combine the latter two)? I have the impression that before the advent of HLSL, materials were explicitly handled by Direct3D or OpenGL. I also have…
Mystagogue
  • 175
  • 6
2
votes
2 answers

Which part of the rendering pipeline compiles shaders?

Generally, video games and other graphical software that use vertex and fragment shaders will have said shaders in the form of actual shader source code (typically in glsl or hlsl), and will compile them for use with the display hardware at runtime.…
Warp
  • 171
  • 3
2
votes
2 answers

In a shader, what is the meaning of ".xy?"

I'm trying to research this in Unity manuals online, and I'm finding plenty of references to .xy but not sure what it is. While this is for Unity, I'm assuming this principal is more generic across all shader systems. When we have a float3 variable…
1
vote
0 answers

Compute min/max position of tile in compute shader

I'm trying to implement tiled deferred lighting with OpenGL compute shaders. For that, I need to compute the minimum and maximum position of each tile. My first approach was to use atomicCounters for the computation, like that: shared int…
tobspr
  • 410
  • 2
  • 13
1
vote
1 answer

How does one multiply by a constant in a VS1.1 assembly vertex shader?

I'd like to multiply a vector by -1 e.g. mul r0, r0, -1 When I try this, I get this error message: SimpleShaderA.vsh(20,17): error X2000: syntax error : unexpected integer '1l' How can I specify -1 in my (first) shader program?
user3643
1
vote
1 answer

Differences between Unity/UE shaders and Opengl Shaders

At first, I thought that they are the same, shaders in game editor write by programmers(or use some graph flow tools nowadays) just get compiled into opengl shaders. But now I'm writing my own render engine, and found that my engine's shader should…
ravenisadesk
  • 660
  • 1
  • 5
  • 14
1
vote
0 answers

What's the most efficient way to implement low poly flat shading style?

I want to know what's the most efficient way to implement low poly style flat shading. I have checked this post, however the options listed in the page don't feel perfect to me. I list them below for reference. Duplicate each vertex so that same…
Rui Liu
  • 143
  • 2
1
vote
0 answers

GLSL: sphere galaxy

I'm trying to draw sphere galaxy mentioned in this tutorial: http://martindevans.me/game-development/2016/01/14/Procedural-Generation-For-Dummies-Galaxies/ Here is an image for reference: Basically, it is just a (3D normally-distributed) set of…
despero
  • 33
  • 1
  • 4
1
vote
1 answer

Different ways to mark the status of an enemy

I have a 3D game with a "eagle view", I have enemies and I have magics that will affect the status of the enemies. I want to show the status of the enemies( frozen, on fire(dot damage), slowed...etc) I think about two possibilities Put a 2D image…
D4rWiNS
  • 293
  • 1
  • 17
1
2