A program that runs on the GPU to determine output colors for pixels. Also known as a fragment shader.
0
votes
1answer
10 views
Fragment shader coordinates: Displacing pixels and texCoord problems
I'm trying to create a shader that creates a displacement on an object, slicing horizontally the sprite.
These is an example of the atlas I'm using and the effect I'm trying to achieve:
I tried to ...
1
vote
1answer
27 views
alpha test shader 'discard' operation not working - GLES2
I wrote this shader to illustare alpha test action in GLES2 (Galaxy S6).
I think is not working at all cause I don't see any change with or without it.
Is there anything Im missing?
Any syntax error?
...
1
vote
1answer
80 views
how to make a fast fragment shader that converts intensity to saturation?
I have a simple fragment shader that looks like this:
#ifdef GL_ES
precision lowp float;
#endif
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform vec4 u_desiredColor;
uniform sampler2D ...
3
votes
1answer
138 views
Procedural Hatching
I know that it is possible to make a shader that uses procedural hatching instead of pre-designed tonal art maps. But is it possible to make that procedural hatching in the fragment shader? I would ...
0
votes
2answers
36 views
Difference in Shading Using Eye Space or Model Space Coordinates
While reading on shading, I came across a section in which the artist provides 2 different kinds of fragment shading:
Coloring using model space and eye space.
The result is as illustrated in the ...
3
votes
1answer
90 views
Would it perform faster to split calculation between vertex and fragment shaders?
Assuming the total amount of computation would be the same (at least as far as my code goes), would there be any performance increase in splitting the calculation and using separate vertex and ...
0
votes
0answers
42 views
Shadows not rendering on custom shader
In the custom shader I've written I've implemented the 'standard way'. However, it doesn't seem to achieve anything at all.
I'm new to shaders, and quite frankly, the whole thing has been a bit of a ...
0
votes
1answer
67 views
game maker - how to change color palette using shader and texture
how to change the color of the application surface, using the texture??
https://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes
https://en.wikipedia.org/wiki/List_of_8-...
1
vote
3answers
75 views
How do I calculate NDC coordinates in a fragment shader?
I have some weird problem going on in my openGL shader.
First,, I pass the viewspace position from the vertex shader to the fragment shader like this:
vec4 view_pos = V * M * vec4(world_position.xyz,...
1
vote
0answers
32 views
Game Maker - Shader CGA - how to swap the palette
I created a shader that get the actual color of the surface and render it to the closer of a cga palette
I have to change it to swap the palette in 4 colors but I don't know how
secondary, I have to ...
1
vote
1answer
54 views
Problems with BlendOp Max
I'm trying to write a shader that doesn't blend additively etc etc. I'd like to take whichever of the source or destination colours is brighter and use that and BlendOp Max seemed like the tool for ...
1
vote
1answer
21 views
Fragment shader operations before vector transformations
I feel like I'm misunderstanding how to work with vector/fragment shaders. My vector shader is as follows:
uniform mat4 uVMatrix; // view (camera transformations)
uniform mat4 uMMatrix; // ...
1
vote
1answer
71 views
HLSL texture sampler always returns white
I'm facing in problem in HLSL with Monogame that I can't figure out. The gist is that sampling from a texture seems to always return white rather than the texture's actual color. My pixel shader code ...
3
votes
2answers
60 views
How do I get a Light's Range value in Shader?
I'm trying to write a simple frag/vert shader that, depending on whether it is in the range of a light, will paint the appropriate colour from either the 'lit' texture or from the 'unlit' texture.
...
0
votes
0answers
77 views
Opengl 4.3 - GLSL Bump mapping problem (Normal mapping)
I'm pretty new to advanced GLSL / OpenGL.
I was able to make a small engine, load an object, render it, etc.
I recently added the Phong-Reflection model for lighting (and it's working well).
I ...
1
vote
1answer
281 views
How do I calculate UV space from world space in the fragment shader?
In my vertex shader I have calculated the world space
o.worldSpacePosition = mul(unity_ObjectToWorld, vertIn.vertex);
How do I convert that world space into uv space coordinates in my fragment ...
1
vote
1answer
48 views
Transform luminosity (Watt) to be usable in shader
I'm studying the color and the Luminosity of Stars.
I'm trying to figure how to transform information of Luminosity i perceive at a given distance to something usable into a shader.
For instance , ...
0
votes
2answers
88 views
GLSL: Issue replacing ternary operator with mix
I was expecting these two code snippets to do the same thing:
return vec3( 1.0-b.r>=a.r ? 0.0 : 1.0-((1.0-b.r)/a.r),
1.0-b.g>=a.g ? 0.0 : 1.0-((1.0-b.g)/a.g),
1....
3
votes
1answer
77 views
Per-Texel lighting? (not per-vertex or per-pixel)
In my game, I have a 3D shader that does lighting using color ramps on models with very low resolution textures. Basically, the vertex shader calculates color values for direct light and ambient ...
3
votes
1answer
80 views
OpenglGL Render two scenes with one draw call
I need to draw a normal-vector scene and default scene.
I could achieve this my having two programs with different fragment shader to produce the following images. It will require me to draw twice.
/...
1
vote
2answers
257 views
How can I use an HLSL pixel shader to peek at other pixels?
I think this is like a pixilation shader but I had a hard time trying to find one online, and one that I could manipulate specifically.
I want to create a pixel shader for my monogame project that ...
0
votes
1answer
278 views
GLSL - Only draw arond point / flashlight effect
I'm currently trying to achieve a sort of flashlight effect in GLSL. I only want to draw textures within a certain distance of a specified point (the mouse position, for example). Here's a quick ...
0
votes
0answers
27 views
How to apply individual colours in a fragment shader?
I'm trying to write my own shader. Within the target mesh I have assigned the following attributes in a script:
mesh.vertices = points;
mesh.colors = colours; //Each element of the array hold a ...
0
votes
0answers
38 views
Fragment Shader Light Sim
In the game Clash Royale, when you have the ability to upgrade a card, the green part has a light sheen to it an this sheen animates from left to right. How can this be done with a shader? I'm quite ...
0
votes
1answer
31 views
Choosing between multiple shaders based on uniform variable
I want to choose from 2 fragment shaders based on the value of an uniform variable.
I want to know how to do that.
I have onSurfaceCreated function which does compile and link to create program1 and ...
0
votes
1answer
62 views
Luminance 'y' value of surface texture
For my opengl video player app, I am using surface texture bound to GL_TEXTURE_EXTERNAL_OES
source : https://github.com/crossle/MediaPlayerSurface/blob/master/src/me/crossle/demo/surfacetexture/...
0
votes
0answers
40 views
Convolution of luminance values in shader
For my fragment shader, I need to take the convolution of luminance values of a square block of pixels.
I tried with 3x3 block and took luminance and convolution.
But it ended up in huge performance ...
2
votes
1answer
743 views
Schlick Fresnel Shader
I hope you are all doing ok. I have an issue with my Fresnel shader that doesn't allow the Fresnel to change as my camera moves around. I'm not sure what i'm doing wrong. I'm using glsl with the ...
0
votes
0answers
206 views
vert/frag custom shader - Shadow is not correct, showing strange artifacts
I am new to shader writing, I want to drop shadows in my own shader, but unluckily I am getting a strange behaviour. When I apply a simple surface shader (Lambert, written in unity shader lab) it ...
0
votes
2answers
265 views
How do I draw individual pixels in the distance?
Hello everyone I am working with unity3d and I am faced with a task. I have a list of 3D points and I want to draw a pixel for every point on the list that exists after my cameras frustums far-plane. ...
3
votes
1answer
87 views
Super formula on shader
I'm using Shader-toy to experiment and try to learn a bit the shader science.
As exercise I wan to replicate some of the wikipedia math plots. I've started with a Super Formula.
What I want to ...
0
votes
1answer
170 views
Fragment shader, tint color problem
I am new to shaders, and I am trying to tint a texture to mark status of a enemy.
I am implementing shaders on OpenGL ES 2.0 (Mobile)
The problem is that with this shaders, I see the enemy without ...
0
votes
1answer
31 views
FXAA Parameter Confusion
I have a question about the popular FXAA shaders that are out there written using HLSL or GLSL, and they all mainly feature these three parameters:
#define FXAA_REDUCE_MIN (1.0 / 128.0) //0.0078125
#...
-1
votes
0answers
31 views
Create overlapping transparent images [duplicate]
I want to achieve this effect in the image.
To make this I don't think a single pass to a stencil buffer would be enough because stencil buffers can't mask out the actual alpha inside of the ...
0
votes
0answers
53 views
Shader - Directional Lights Depth
Is there a way to retrieve the deph from directional lights ? I can access the _ShadowMapTexture but this is not the depth.
I found how to access the shadow map of, I think, every light type by using ...
3
votes
1answer
86 views
Libgdx - GLSL shader which uses mod doesn't seem to work properly on android
Through trial and error I've managed to come up with a scanline-ish shader I'm satisfied with. On my desktop testbed it looks like this:
Basically, every 2nd(vertical) pixel is darkened.
However, ...
3
votes
0answers
249 views
Unity - reconstruct position from depth
I am using Unity and I want to reconstruct position from depth and frustum corners in pixel shader.
I am doing this:
In my App, I calculate view-space corners of the far frustum plane and pass them ...
4
votes
1answer
131 views
Getting rid of texture bleeding
Edit: I figured out what problem I was facing, it's called Texture/Pixel bleeding, which I was not aware of yet. I posted an answer below consisting of a small description of the problem and a link to ...
1
vote
3answers
136 views
Is there a way to get what pixel is being processed within the fragment shader?
In OpenGL, a fragment shader goes through each pixel, right? So is it possible (within the shader itself) to get what pixel it is processing and color each specific pixel?
1
vote
1answer
30 views
Is it necessary to use texture filtering if I use texture coordinate system?
I have one question about using texture filtering.
It's clear when I used normalized texuture coordinates (in any API) for example from (0,0) to (1,1) it is necessary to use texture filtering because ...
14
votes
3answers
1k views
How do I write a shader that lights up when objects are near a surface?
In this Overwatch gameplay video, the character's shield lights up white in areas that are near other objects' geometry.
Note the white edges on the blue shield, near the floor, walls and pillar.
I ...
1
vote
1answer
675 views
Pixelation shader explanation?
I was looking for a pixelation shader for my postprocessing and came across this shader snippet - Works pretty well! - Not a whole lot of explanations on how it works except for "Pixelation is process ...
0
votes
0answers
106 views
Offscreen frame buffer lwjgl
I want to create simple 2d lighting. So my idea is to render everything on the default buffer and then apply light mask. For the light mask i want to use frame buffer which later i will apply on the ...
0
votes
1answer
511 views
Shadertoy getting help moving to glsl
I spent some time writing a shader on shadertoy but now, when I try to translate my code to opengl I don't know how to calculate the uv that they describe as like this:
vec2 uv = fragCoord.xy / ...
3
votes
1answer
226 views
Underwater Shader Animation Help
I found an underwater (distort) effect and I got it to work but somehow I cannot make it animate given the offset here:
Fragment Shader code:
uniform sampler2D fbo_texture;
uniform float offset;
...
0
votes
2answers
486 views
How to wrap textures inside shader GLSL
I'm trying out GLSL and one of the problems I'm facing is wrapping a random texture sampler in the shader. Searching for answers on the web first, this leads me to using these commands:
...
1
vote
3answers
438 views
OpenGL, GLSL, Modify Background Fill via Fragment Shader
I have noticed that fragments rendered by the glClearColor() method do not pass through shaders. However, I'd like to modify these fragments using my fragment shader. Is there any way of forcing them ...
3
votes
1answer
463 views
equirectangular panorama rendering?
I want to render my scenes as equirectangular panorama frames.
I can get the angular fisheye which is what I actually need by applying the rendered frame as a texture to a correctly UV mapped circle.
...
1
vote
1answer
189 views
How to pass a big (60+) amount of variables to an HLSL pixel shader?
I am in trouble at trying to pass a big amount of variables needed for my pixel shader computations.
After trying and failing to link my struct to a cbuffer (data alignement mismatch) I tried passing ...
4
votes
1answer
420 views
Stencil buffer VS conditional discard in fragment shader
I have a continuous height-mapped mesh to represent landscape. I also have 1 to let's say 10 wells on this landscape represented by additional models. What I want to achieve is to create an illusion ...