Questions tagged [fragment-shader]

A GPU program used in rendering. It is executed for each sample taken from a rasterized primitive. The output of this process is a number of values and a floating-point depth.

Resources

1506 questions
13
votes
1 answer

Custom Shader SCNProgram iOS 9 Scenekit

I am trying to mess around in SceneKit and teach myself it. Basically, I am creating a quad with 3 rectangular sides and 1 sloping slide. I want my texture on it to stretch and warp/deform across the surface. Reading some stuff online, it seems…
AdiTheExplorer
  • 259
  • 4
  • 13
13
votes
1 answer

Simulating palette swaps with OpenGL Shaders (in LibGDX)

I'm trying to use LibGDX to make a retro-style little game, and I'd like to let the players to choose the colors of several characters, so I thought about loading png indexed images and then updating palettes programatically... How wrong I was ^^U…
hcito
  • 153
  • 1
  • 5
13
votes
1 answer

Three.js use framebuffer as texture

I'm using an image in a canvas element as a texture in Three.js, performing image manipulations on the canvas using JavaScript, and then calling needsUpdate() on the texture. This works, but it's quite slow. I'd like to perform the image…
meetar
  • 7,443
  • 8
  • 42
  • 73
12
votes
3 answers

Render an SCNGeometry as a wireframe

I'm using SceneKit on iOS and I have a geometry I want to render as a wireframe. So basically I want to draw only the lines, so no textures. I figured out that I could use the shaderModifiers property of the used SCNMaterial to accomplish this.…
Tom van Zummeren
  • 9,130
  • 12
  • 52
  • 63
11
votes
1 answer

WebGL. Full screen quad or triangle for invoking fragment shader for every pixel?

In many examples over internet (such as webglfundamentals or webgl-bolerplate) authors used two triangles to cover full screen and invoke pixel shader for every pixel on canvas. var canvas, gl, buffer, vertex_shader, fragment_shader, …
Stranger in the Q
  • 3,668
  • 2
  • 21
  • 26
11
votes
2 answers

Depth of Field: combining a point shader with a blur shader (Processing 3)

I would like to display thousands of points on a 3D canvas (in Processing) with a Depth of Field effect. More specifically, I would like to use a z-buffer (depth buffering) to adjust the level of blur of a point based on its distance from the…
solub
  • 1,291
  • 17
  • 40
11
votes
2 answers

Texture and color together in GLSL?

I cant figure out, how to get with OpenGL ES 2.0 similiar Results to OpenGL ES 1.1. I want to use actually a Sampler2D (to blend my texture with Alpha Channel to the Framebuffer) and also set an Color. The texture should be painted in the color -…
Constantin
  • 8,721
  • 13
  • 75
  • 126
10
votes
1 answer

Concept: what is the use of glDrawBuffer and glDrawBuffers?

I am reading the red book OpenGL programming guide when I come across these two methods, which strikes me as unnecessary since we already can specify which color buffer the output is going to go to with layout (location = ) or…
Manh Nguyen
  • 373
  • 3
  • 12
10
votes
1 answer

How to implement Shadertoy buffers in WebGL Javascript when trying to convert to JS?

I'm attempting to convert a Shadertoy to Javascript and WebGL so that it can run independently from Shadertoy. Shadertoy has the concept of a buffer, in this example it re-cycles the buffer and improves the output image. It does this on the Buf A…
Phil
  • 46,436
  • 33
  • 110
  • 175
10
votes
1 answer

GLSL: Replace large uniform int array with buffer or texture

Right now I am trying to pass an array of ints into the fragment shader, and am doing this through a uniform array: uniform int myArray[300]; And filling it outside the shader with glUniform1iv. Unfortunately, uniform arrays larger than ~400 fail.…
nbubis
  • 2,304
  • 5
  • 31
  • 46
10
votes
5 answers

YUV to RGB conversion by fragment shader

I've a problem with convertion of camera preview in Android from YUV format to RGB. The purpose of conversion is to apply some effects. I try to convert by fragment shader because convertion by native code is slow (about 14fps). The reference which…
anyoneguy
  • 154
  • 1
  • 2
  • 8
10
votes
1 answer

GLSL reusable/shared functions, shared constants (OpenGL ES 2.0)?

Short: Can I define a function that every shader can use? Or I have to define it per shader? The whole story: I want to create numerous shaders intended to colorize the input fragments with predefined gradient ramps (something like this -…
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
9
votes
2 answers

Convert ShaderToy to fragment shader

I came across several shaders on ShaderToy and I have not had success converting them into a format that can be used on a mobile device, such as a .fsh. I have this Shader, and I want to be able to use it on a mobile device. I know that I need to…
Clip
  • 3,018
  • 8
  • 42
  • 77
9
votes
3 answers

Get accurate integer modulo in WebGL shader

I want to get an accurate modulo of x and y in a WebGL fragment shader. x and y are integers. Graphing mod(x,y), we get the following: The actual code used to generate the red-and-black rectangle is: gl_FragColor = vec4(mod( …
DDR
  • 392
  • 1
  • 4
  • 14
9
votes
1 answer

LookAt function: I'm going crazy

I must do a homework and I try to implement a lookAt function. I tried in many ways but the only result I got is a blue screen. The rest of my program works greatly, infact if I use glm::lookAt all is good. This is my code: mat4…
Domenico Maiuri
  • 191
  • 1
  • 1
  • 10