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

How do I render a subset of a texture (knowing the size in pixels) in a OpenGL/WebGL Fragment Shader?

I've got some code that is rendering 2D sprites to the screen. It all works; but the texture coords are provided in the range 0,0 - 1,1. I would like to supply the coordinates in pixels, so that when I'm creating a sprite, I can provide the part of…
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
0
votes
1 answer

Transparency in Three.js ShaderMaterial fragment shader

I've used Three.js quite a bit, but I'm just starting to learn how shaders work. I have a green cube which is one-half transparent, as defined in a THREE.ShaderMaterial (based on the "phong" ShaderLib). I put a simple red cube inside the…
TheJim01
  • 8,411
  • 1
  • 30
  • 54
0
votes
0 answers

Inconsistency with small custom WebGL shaders under linux with Three.js

I'm experiencing some weird behavior with a relatively small custom shaders. This is the expected behavior as seen under windows. Unfortunately under linux (you can see the files warcluster-shaders-ubuntu && warcluster-shaders-archlinux in the same…
0
votes
0 answers

Insanely slow ray tracer

I've started working on a ray tracer recently, and even though I got it working pretty well, I soon ran into some trouble. I'm trying to simulate a park, and I basically have one single DistanceFromPoint(vec3 p) function that calculates the distance…
0
votes
2 answers

LWJGL Texture loading / mapping issue

I'm drawing a quad with a 512 x 512 texture composed of 4 squares with 4 different colors (yellow, blue, green, red). When i look at the image it's all yellow but the tex coords space from 0 to 1 and i'm quite sure they're mapped correctly... here's…
Mk3Y
  • 1
  • 2
0
votes
1 answer

fast 2D texture line sample

Imagine you have a chessboard textured triangle shown in front of you. Then imagine you move the camera so that you can see the triangle from one side, when it nearly looks as a line. You will provably see the line as grey, because this is the…
Inuart
  • 1,432
  • 3
  • 17
  • 28
0
votes
1 answer

GLSL normal map lighting dark areas and light facing odd direction

I can't seem to figure out why my fragment and vertex shaders aren't working. I think I either have my view/perspective wrong, or maybe my normal map has negative values (since black is showing up lit). Either way, I've been at this for days and I…
justaguy
  • 21
  • 2
0
votes
2 answers

How to make a fragment shader replace white with alpha, opengl-es

I am trying to come up with a opengl-es fragment shader that will replace the white pixels with alpha. The image with the checkered background is what I want. The checkered background represents the image after alpha conversion. Any tips? Normally…
NJGUY
  • 2,045
  • 3
  • 23
  • 43
0
votes
1 answer

Math.random() undeclared identifier

I am trying to generate random colors in my fragment shader, but I'm running into compiler errors. Here is my code: