Questions tagged [glsl]

GLSL is the OpenGL shading language. Use this tag for questions which are specifically about shaders written in this language. For generic shader questions use [shader] instead.

Filter by
Sorted by
Tagged with
4
votes
2answers
644 views

OpenGL: Purpose of transform matrix in Vertex shader where transform*vertex

I'm trying to understand OpenGL by using Processing OpenGL ES. If I have an example Cube to render. I've read that a vertex shader will be run once for each Vertex. The fragment shader will be run (...
4
votes
1answer
2k views

Unable to pass custom Matrix4 to GLSL as a uniform

I am fairly new to graphics programming and I am trying to pass a custom Matrix4 (non-glm) to my vertex shader by using a uniform. ...
4
votes
1answer
571 views

Exponential shadow maps sampling with PCF for sampler2DShadow instead of sampler2D

I am trying to make use of free hardware PCF sampling with sampler2DShadow and extend it to more samples. So far I am sampling shadow map (...
4
votes
1answer
4k views

Why is my fragment shader not showing any colors?

I am basically following this tutorial about diffuse lighting in OpenGL. I did some modifications but the idea is the same, at least that's what I think. However, my fragment shader is not showing any ...
4
votes
1answer
914 views

Guidance with Sphere-Map calculation in GLSL

I'm trying to achieve the same effect in OpenGL/GLSL as what Blender does when you add a texture, set to "Reflection" This ultimately is a way to fake specularity, or "metallicness" if I get it right....
4
votes
1answer
1k views

How to dynamically calculate texture coordinates in a vertex shader with OpenGL?

I modified my code, and tried to pass a set of integers specifying the face of a cube (top, bottom left...) to the vertex shader in order to draw multiple instances of a cube face. I did this by ...
4
votes
1answer
427 views

Screen Space Ambient Occlusion Issues

I'm having problems with Ambient Occlusion. I've tried to follow both John Chapman's improvements over the Crytek AO and LearnOpenGL's tutorial of it when I failed to properly obtain the correct ...
4
votes
1answer
335 views

Special Texture Stretching without deformation

I am trying to achieve a special texture stretching effect in my shader. Here is how I define my uv before sampling my texture, nothing really special. ...
4
votes
1answer
119 views

NormalMap problems: bumps work, but shade does not

I've been trying to figure this out for a few days now, but I just can't get it right. I've read multiple tutorials and possible explanations, I even watched a java tutorial without finding the ...
4
votes
1answer
1k views

Attribute Location in Multiple Shader Programs

I'm trying to switch between the rendering of two different scenes as fast as possible using OpenGL. For all my OpenGL related stuff I wrote a wrapper-class which provides a quite easy way of adding ...
4
votes
3answers
432 views

Texture coordinates projection

I have some classic texture coordinates and as a normal behaviour they follow the mesh's transformations. I am trying to use the same texture coordinates behaviour but without being affected by the ...
4
votes
2answers
528 views

Clearing but not drawing objects

I was trying to draw a plane and cubes in a framebuffer but nothing is drawing in that framebuffer besides clearing it with a color. Here's the code... ...
4
votes
1answer
502 views

Shader won't work

I have managed to implement a garoud shader with specular lighting efects in Processing 3.0 . Now I am trying with a fragment Phong shader but cannot make it work. I can´t find where is the error. It ...
4
votes
1answer
185 views

How to set the GLFW OpenGL target?

I'm programming on a Mac and I'm learning OpenGL in the library GLFW. My problem is that my Mac supports OpenGL up to version 4.1, but when I try to compile the shaders with ...
4
votes
0answers
253 views

Indexing gl_TessLevelOuter[] with gl_InvocationID on a tessellation control shader

I'm using hardware tessellation to render a terrain mesh with variable LOD. I have this snippet on my tessellation control shader: ...
3
votes
2answers
1k views

Why do we multiply vertex from left side in vertex shader with matrices?

I have been learning OpenGL 3.3 and I saw this expression: gl_Position = projection * view * model * vertex I am confused because I read in some book that if the ...
3
votes
4answers
302 views

How to access several textures from huge amount of textures in a shader?

I'm developing a light probe based GI solution and currently dealing with light leaks due to interpolation between probes located on opposite sides of the walls. I want to tackle the problem by ...
3
votes
1answer
241 views

GLSL function parameters

In GLSL: Common Mistakes it states: Functions parameters must be declared with the in, out, or ...
3
votes
1answer
1k views

How to get assembly code from GLSL Shader

I am new to optimizing shader code. Now that I have written an "optimzation", I want to make sure that it really speeds things up and is not just an unreadable version of what I intend to do. For this,...
3
votes
1answer
265 views

Is sub-texel shading possible?

I suspect the answer is no, but thought I'd ask anyway. It seems that other than using nearest neighbour and bilinear interpolations, there is nothing you can do to determine how two adjacent pixels ...
3
votes
1answer
47 views

Operator associativity and 4x4 matrices - performance question

During vertex processing with 4x4 matrices, we might stack multiple transformations like projection, model-world, world-camera, etc. by doing something like this: $$v_{final} = T_N \cdot ... \cdot ...
3
votes
1answer
140 views

Shader that transforms a mercator projection to equirectangular?

I am new in the OpenGL - GLSL and trying to make a shader that taking a mercator projection texture as a source and converting it to an equirectangular projection texture. Sample input: (1024x1024) ...
3
votes
1answer
464 views

Benchmark GLSL fragment shader

How can I benchmark a fragment shader? What my shader does is basically lots of floating point operations, since it's doing some procedural stuff.
3
votes
1answer
319 views

Bug: Overly Sharp Highlights in PBR

I'm still working on my BRDF equations. Theoretically, all equations are correct, but the hilights are super sharp. I'm not sure if this is a result of me not using Image-Based Lighting (I currently ...
3
votes
1answer
1k views

What do the OpenGL version strings from glxinfo actually mean?

Note: I wasn't 100% certain if this question belonged here or in Ask Ubuntu. I figured since it was about OpenGL programming I'd put it here, but if I should move it to Ask Ubuntu, please let me know. ...
3
votes
1answer
593 views

How does GLSL code get “loaded” and “compiled”?

I just wanted to find out for sure how GLSL code gets loaded and compiled. Does the g++ compiler do it?
3
votes
1answer
1k views

Phong shading in OpenGL: line of light from the center of the world

I implemented a Phong shader in GLSL, but there is a bug. What you are (supposed) to see down below: A point light source rotating around the center of the world, with a radiance of (0, 100, 0) A ...
3
votes
1answer
274 views

Easing curves on the GPU?

I was thinking that I could pass a timestamp in (from requestAnimationFrame) to the vert shader, and just have my easing curves in the GPU instead of using (for example) Tween.js from the outside. Is ...
3
votes
1answer
424 views

Combine material coefficients and textures in Phong Shading

I'm trying to implement a simple Phong shader that supports non-physically-based materials and textures. Even though the material has a texture for each light component I still want the respective ...
3
votes
2answers
329 views

How to generate chaotic halftone pattern?

I'm trying to generate a random halftone like below image: this is a simple halftone that I tried, but I need a random halftone ...
3
votes
1answer
162 views

How can I implement GIMP's “Colorize” function?

I have an RGB pixel that I'd like to colorize in my program (I'm using GLSL) very similar to how the GIMP "Colors > Colorize" function works. In my program, I can easily convert between RGB and HSV. ...
3
votes
0answers
79 views

Projective Texture / Shadow Mapping — Why is the perspective division performed in the fragment shader?

I've just worked my way through this OpenGL shadow mapping tutorial. While I understand the basic algorithm, one thing puzzles me: During the 2nd render pass all vertices are transformed into the clip ...
3
votes
0answers
251 views

Circular pattern aliasing in voxel ray tracer

I am doing a voxel based raytracer. In other words, I first voxelize the scene using rasterization and I proceed to raytrace the volume in a 3D image to generate a final frame. Currently I noticed ...
3
votes
0answers
243 views

How to output a 32 floating value in a render buffer with fragment shader

I would like to downsample my depth buffer and my normals. For that, I take in input of my shader, the corresponding textures (depth, normal), and I write my new values in a multi render target. I ...
3
votes
0answers
252 views

GLSL shader debugging [closed]

Is there any tool available for debugging GLSL shaders? I have nvidia geForce 940m GPU which doesn't support Nvidia NSight and RenderDoc is great but it doesn't support GLSL shader debugging. I am ...
2
votes
1answer
455 views

Clarifying vulkan glsl std140

So I have a uniform block that looks something lile this { mat4; mat4[128]; uint[16] } The block should total up to 8320 bytes. After aligning by 256 bytes for nvidia, that brings the total ...
2
votes
1answer
137 views

Difference between isnan and comparison to self

In GLSL, what is the difference between isnan(x) and !(x == x)?
2
votes
1answer
720 views

Shader storage buffer indexing by 4 bytes instead of 3?

I am trying to send rendering information for an instancing rendering using shader buffer objects. My current problem is that I have 2 shader buffer objects, one which works just fine, and another ...
2
votes
1answer
793 views

Bezier Curve Tool Controlled by Mouse

So I have recently learned about Bezier Curves (quadratic & cubic) and have a thorough knowledge of how they work. In my graphics engine in DirectX I wanted to implement a Bezier Curve Tool ...
2
votes
1answer
107 views

How to work around the pointer limitations of GLSL?

(I am new to Computer Graphics in general) I am learning how to ray trace from a book called ''Peter Shirley - Ray Tracing in One Weekend''. In the book, the code is written in C++. I have ...
2
votes
1answer
58 views

Rendering moist/wet materials like human anatomies for surgical simulators

Real human anatomies look wet/ moist when operated. I am looking for some good methods for rendering anatomies in a virtual simulation, and hence I have done a literature survey on 'Rendering wet ...
2
votes
1answer
68 views

Creating glsl library

I have different functions for example normalmapping which I use all the time... Now I thought about making a small glsl library. My problem: I don't want to have all functions within the same "...
2
votes
1answer
55 views

Point light illuminating only half of a scene

A point light is illuminating only a half of a scene in my small 3D renderer. It happens on every scene I've tried (conference room, cornell box, etc). How do I go about debugging this? What could ...
2
votes
1answer
257 views

GLSL Compute Shader doesn't run for large inputs

The shader takes an SSBO of Photons that have a position, direction, wavelength and intensity and each thread is responsible for tracing exactly one photon through the grid, where at each grid cell ...
2
votes
2answers
171 views

OpenGL - Recreate position in viewspace from depth values

Current state: I belive the reconstructed positions are correct. However, I still have the same problem as all the time. When I rotate around my single pointlight appears to be moving around also. I ...
2
votes
1answer
80 views

Alpha component in color buffer affects RGB components?

I'm looking for a way to make my surface semitransparent, and for now i ended up using this configuration: ...
2
votes
1answer
124 views

How can deal with batch rendering when the elements in the batch changed every frame?

Since I am using batch rendering, so I should pack every render units can be batched into one big VBO. But, what if I am in a case where render units are dynamically changed, some new units are added ...
2
votes
2answers
874 views

Transforming fragment-to-camera to tangent space for parallax occlusion mapping

I'm trying to implement POM using this tutorial. As stated, I need to transform fragment-to-camera to tangent space and then pass it to a function. tangent space is computed using Assimp. Well I ...
2
votes
2answers
207 views

Can I use the same vertices to render multiple things?

I'm passing my vertex shader a bunch of vertices and color data. I would like to first render the triangles and then render a point at each vertex. The triangles render fine, but I can't think of a ...
2
votes
1answer
98 views

Strange dark spot when lighting in deferred rendering PBR shaders

It's probably something obvious but there seems to be a strange issue with lighting in my pipeline. I'm trying to keep everything in world space at the moment for simplicity but cannot figure out what'...