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
0
votes
1 answer

Android OpenGL es 2.0 specular light

I'm trying to add specular lightning to my android OpenGL project, but the light is only projected on a part of my object, as you can see in my example: In my fragment shader, I calculate the color as following: float dot(vec3 v1, vec3 v2) { …
Michiel van Vaardegem
  • 2,260
  • 20
  • 35
0
votes
1 answer

When I don't access one of my textures, the other texture lookup appears black

I have the following CG pixel shader: float4 main( float2 texCoord : TEXCOORD0, float4 position : TEXCOORD2, float4 color : COLOR, uniform sampler2D texture_sample : TEX1, uniform sampler2D stipple_sample : TEX2, uniform…
0
votes
1 answer

GLSL - Trying to add multiple lights?

I have a simple fragment shader that simulates 2D lighting, like so: struct Light { vec2 pos; // Light position float spread; // Light spread float size; // Light bulb size }; void main(void) { Light light0; // Define…
user569322
0
votes
2 answers

will this sinus approximation be faster than a shader CG sinus function?

I have some functions that are not really sines but they are a lot quicker than conventional processing, they are simple parabole functions. Will this be faster on a graphics processor than the built-in graphics sinus function: float par (float…
bandybabboon
  • 2,210
  • 1
  • 23
  • 33
0
votes
1 answer

Using a uniform in an "if" instruction inside a fragment shader don't work since recent chrome update

I'm using GLSL shaders in my WebGL project, a recent Chrome update made my shaders not linking without error message. The problem occur when i use a uniform as a condition of a "if" in a fragment shader, like this example : uniform int…
0
votes
1 answer

Why is drawing a circle procedurally slower than reading from a texture?

I am making a app where i need to draw a lot of circles in the screen, so i had the idea of replacing the texture of the triangles i am using to draw the texture with a function to draw a circle. However after testing, it turned out to be slower…
Guedez
  • 189
  • 3
  • 14
0
votes
0 answers

Summing colors in fragment shader

If I use: void main() { gl_FragColor = texture2D ( sampler, uvVarying ) * colorVarying; } with colorVarying being (1, 0, 0, 0) in a simple fragment shader, the texture is turned red as I expected. But I would like to add more red, instead of…
vertti
  • 7,539
  • 4
  • 51
  • 81
0
votes
2 answers

Serious Lag due OpenGL Fragment Shader

Fragment shader causes serious lag when I run it on iPhone 4. I tried to comment part of calculations, however still there are some jitters even though I barely am doing any calculation in the Fragment Shader. // Fragment Shader Code uniform…
Nima
  • 969
  • 3
  • 10
  • 14
0
votes
1 answer

How to pass YUV data into a fragment shader without GL_LUMINANCE

In Android, in order to pass YUV420sp into a fragment shader I pass the information spliting the data into Y-U-V, and passing each sugin glTexImage2D with GL_LUMINANCE format But now I need to do Offscren-Rendering for which I require FBOs, the…
PerracoLabs
  • 16,449
  • 15
  • 74
  • 127
0
votes
1 answer

OpenGL ES 2 - Drawing GL_POINTS directly vs indirectly

I am creating an iOS app for drawing / sketching and right now encountering a problem when I draw GL_POINTS indirectly to an FBO that then this FBO is stamped onto a final FBO. Here is the result when I draw the GL_POINTS DIRECTLY to an FBO And…
Coolant
  • 448
  • 6
  • 13
0
votes
1 answer

What's happens on default fragment shader in CG shader language?

I have code on CG. In this code vertex shader emit 3 parameters: vertex position (float4), texture coordinates (float2) and color (float4). But fragment program not defined. How shader use this 2 parameters (uv and color) on fragment shader?
toodef
  • 125
  • 1
  • 11
0
votes
1 answer

Best way to animate textures in OpenGL ES 2.0

I want to animate a some numbers in openGl ES 2.0. To try and make it work to start with I have created a timer and am trying to get the numbers to change dependant on the timer. The timer is set up on a sin() wave so the numbers should increase…
D.Cole
  • 27
  • 10
0
votes
1 answer

GLSL Shader Ported From HLSL Is Not Working

I have this HLSL Shader for blur: struct VS_INPUT { float4 Position : POSITION0; float2 TexCoord : TEXCOORD0; float4 Color : TEXCOORD1; }; struct VS_OUTPUT { float4 Position : POSITION0; float4…
jmasterx
  • 52,639
  • 96
  • 311
  • 557
0
votes
1 answer

OpenGL - GLSL Shaders, Alpha blending

I am using this fragment shader: #version 150 core uniform sampler2D texture1; in vec4 pass_Color; in vec2 pass_TextureCoord; out vec4 out_Color; void main(void) { out_Color = pass_Color; // Override out_Color with our texture pixel …
Amit Assaraf
  • 512
  • 11
  • 34
0
votes
1 answer

OpenGL Texture override material color

I want to render a scene and blend the material color with the texture. i am using programmable pipeline and GLSL, when the function texture() is called, all the portion of the meshes wish dont have texture become transparent. (even if i dont use…
bruchuck
  • 13
  • 2