Questions tagged [shader]

For all questions related to shaders, i.e. the programmable part of the GPU pipeline. For language-specific shader questions, see also the [glsl] and [hlsl] tags.

Filter by
Sorted by
Tagged with
2
votes
1answer
216 views

How to match Blenders polynomial lens distortion model with GLSL?

I'm trying to re-implement Blenders (libmv) polynomial lens distortion model using shadertoy, in order to apply the lens distortion in another application ideally by generating a STMap for that. I ...
2
votes
1answer
29 views

Use glTranslatef and shaders?

In newer OpenGL it's encouraged to use shaders and pass the model-view-projection as parameters. But what if I drew a complex object, and wanted to translate/rotate it and draw many copies? For ...
2
votes
0answers
43 views

Screen space reflections become warped when looking up or down

I have been experiencing issues over the past few days with implementing SSR on water into my engine. Looking straight forward, it appears to be alright. However, when I look up or down, the ...
2
votes
1answer
55 views

Represent shape as particles

Input: Triangles which make up an arbitrary shape. Each triangle is represented by 3 3D points. Output: A set of particles which fills up the inside of the object (see image). I have read the ...
2
votes
1answer
54 views

Is it possible to bind dynamic texture samplers to a shader in DX12?

So usually texture samplers are set directly in the D3D12_ROOT_SIGNATURE_DESC structure in DX12, at least that's how I've been setting them. I was wondering if it's ...
2
votes
1answer
75 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'...
-1
votes
2answers
62 views

Why does Cubemap have 6 individual textures?

I am learning about Cubemap and I learned that A cubemap is basically a texture that contains 6 individual 2D textures but my question is Why does it contain 6 individual texture ? and also I've read ...
0
votes
1answer
87 views

shaderc compile through api with #include

I'm using shaderc to compile glsl code in to spirv module and pass to pipelie in REAL-TIME. I want to use #include to reuse some of the shader code but shaderc is having problems recognizing it. Any ...
1
vote
1answer
140 views

How does a GLSL Sampler2D read a Vec2 UV coordinate to determine UV range

I am working with an atlas shader that steps through various sprite tiles within a single png atlas page to playback an animation with sampler2D. Looking at the shader code, I would expect to have to ...
2
votes
1answer
132 views

How to voxelize geometry using textures and shaders?

I am trying to fetch a given geotery and through (potentially multiple) render passes create a 3D texture that stores the color value of said geometry into an associated texel. In other words there ...
8
votes
2answers
780 views

How can I offset/shrink a triangular polygon in GLSL?

I need to offset all (blue) triangles, each independently of the others, using the vertex-shader. In order to manipulate the triangle as a whole, I've created custom (vec3) attributes for each vertex (...
3
votes
2answers
304 views

Why are depth buffer values clamped to (0, 1)?

This is a simple question. I know that in OpenGL or other graphics API, the values stored in the depth buffer are automatically clamped to (0,1). I just want to know why people do this instead of ...
2
votes
1answer
85 views

2D Line of Sight + Visibility Calculations

I am currently working on an algorithm to calculate visibility in a 2D top-down level. The level contains actors, with position and "sight" information walls, ...
0
votes
1answer
92 views

Sphere Texture Mapping Algorithm

I am trying to generate UV coordinates automatically to map a texture on a sphere. The problem is with seams when going from 0.8 to 0.2 there is a discontinuity and interpolation in fragment shader ...
1
vote
1answer
87 views

OpenGL Unable to retrieve the values of data sent to shader using textures

I've been following these tutorials and i can't figure out how to send data to shaders using textures. https://en.wikibooks.org/wiki/OpenGL_Programming/Scientific_OpenGL_Tutorial_02 In this tutorial ...
-1
votes
1answer
86 views

Where should I learn shaders as a vulkan user?

I have no prior experience with any other graphics low level libraries and I have barely any clue how shaders work, any book related to shadings is bloated with opengl code and is demoralizing.
11
votes
2answers
3k views

Why are normal maps blue and purple in color?

I am learning about normal mapping. I understood that RGB values are converted into XYZ, but my question is how is it converted and why is the normal map blue and purple in color?
2
votes
0answers
55 views

Show the edges between the clipping plane and clipped objects [closed]

I want to utilize shaders to not only discard fragments if they are on one side of a predefined plane but also render a contour along the intersection. My fragment shader currently does something ...
1
vote
1answer
249 views

Convert RGB image to YUV420 using a hlsl shader

I am new to shaders and I need to convert efficiently an RGB image to YUV420. I can convert the RGB image to YUV420 with a simple c++ program that uses the ...
0
votes
1answer
84 views

Ray tracing the next week: understanding Instances

My question is not about the code, but it's about the approach used by the author Peter Shirley (and apparently common practice in ray tracers) of handling Instances. To understand the question it's ...
7
votes
1answer
8k views

GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?

I'm new to shaders and know that you can color pixels with gl_FragColor but sometimes there is this thing: ...
2
votes
1answer
49 views

Is there an analogue of OpenGL's ImageLoadStore in DirectX 12?

I'm trying to port part of an OpenGL program into an existing DirectX 12 software, at some point in their shaders they use OpenGL ImageLoadStore in order to store information in 3D Textures without ...
0
votes
1answer
100 views

Convert shader from GLsl 1.50 to 1.30

I'm a newbie with OpenGl and I'm stuck in following the tutorial. I found this tutorial with these shaders ...
1
vote
1answer
118 views

Texturing an “infinite” plane

I am rendering an infinite plane as described in the following answers: https://stackoverflow.com/questions/12965161/rendering-infinitely-large-plane https://stackoverflow.com/questions/7380250/how-...
7
votes
2answers
848 views

Why are oct trees so much more common than hash tables?

When reading papers I commonly find Oct tree implementations of geometry representations to sort the data. However whenever I think about the problem hash tables seem better overall. Hash tables have ...
6
votes
0answers
185 views

Avoiding Mach band effect when using multiple lights

I wrote a simple Phong shader with two directional lights for a project, and noticed an unpleasant artifact in the lighting. Where both lights are illuminating the same region, dark bands appear at ...
1
vote
1answer
262 views

Is a single shader and 1x1 pixel white sampler more efficient than frequent switching between shaders with and without samplers?

I have some existing OpenGL code that I am porting to Vulkan. The question is somewhat relevant to both OpenGL and Vulkan. I am rendering some primitives using textures, some single channel, others ...
2
votes
1answer
90 views

LoopBlinn Cubic Curve Rendering - Serpentine arteffect

I am trying to implement the Loop-Blinn cubic curve in java using the following source codes GPU-Curve-Rendering and WebCore. Both of them are showing few arteffects and i cannot figure out why. Here ...
2
votes
2answers
261 views

How can I draw this style of grid?

I'm trying to write code (in any language) to render this 3D grid, matching the look and colors as closely as possible:
7
votes
1answer
200 views

How does this small fractal shader work?

I would like to know the magic behind this tiny fractal shader; I didn't really understand the code and the mentioned thread... Is there an accessible explaination? https://www.shadertoy.com/view/...
2
votes
1answer
268 views

What is shader warming, and why does Direct3D seem to avoid it?

I am involved in a project that had been modified to run on Apple and Linux computers, when it was originally Windows only. Specifically, Metal and Vulkan renderers have been written alongside the ...
2
votes
1answer
1k views

Can i compile my shaders to SPIR-V without using glslangValidator?

I'm making a cross-platform application, and i need my shaders to be compiled to SPIR-V for both Opengl and Vulkan. It seems that the only way to do so is to call a separate program, called "...
1
vote
0answers
54 views

Evenly distributed point cloud for a grass renderer on a sphere

I'm trying to add some details like grass, rocks, trees, etc. to my little procedurally-generated planet. The meshes for the terrain are created from a spherified cube which is split in chunks (...
1
vote
1answer
50 views

Difference between using + and * operator after tex2D to add albedo color?

I have a two different codes with a little difference Case 1. I used a + operator before _myColor. ...
1
vote
0answers
41 views

Simulating vanishing points shader

How do I create a vertex shader that allows to choose 3 non aligned direction vectors and then allows to morph all vectors positions such that every vertex is remapped so that two vertices that are ...
6
votes
1answer
706 views

Why are tessellation shaders disliked?

I often hear that tessellation shaders aren't great for performance reasons. Something along the lines that if you try to use a tessellation shader, you'll find that the data you get out isn't ...
7
votes
1answer
363 views

Explicit vs Automatic Attribute Binding

I'm a beginner in OpenGL and I've been doing some research on the topic of shaders and attributes. Most places I go say that explicit attribute binding (whether it be in the shader itself with ...
1
vote
0answers
382 views

How Skia uses OpenGL backend?

Skia 2D's one notable backend in OpenGL, but how does it work under the hood to render? Say, we need to draw an anti-aliased circle. Does Skia: make a quad (using 2 triangles) and paint the circle ...
0
votes
0answers
122 views

Changing coordinate system from texelFetch to textureLod is breaking the algebra

I have a scene rendered using texelFetch() and I am trying to modify the shader to use textureLod() instead. This is the image generated with texelFetch: When I try to change the shader to use ...
3
votes
1answer
144 views

Importance Sampling in Unreal Engine Formula Derivation (Irradiance term)

I am currently trying to understand IBL in Unreal Engine, and there are so much things that I don't understand about the formula. Unreal approximate the specular term of shading equation by doing ...
1
vote
1answer
142 views

Controling order of execution of a (compute) shader on an array of vertices (data) in Vulkan

Is it possible to force Vulkan to execute a shader on vertices (data) in a semi-consecutive manner? For example, if the data passed to the shaders as a binary tree, shader would process it one layer ...
1
vote
1answer
56 views

Can you avoid querying for a texture location in OpenGL?

The way I learnt to send a texture to a shader is more or less ...
1
vote
0answers
73 views

How do modern GPUs handle branching instructions in shader code?

It has often been recommended to avoid branching conditions in shaders. Why? What happens exactly in modern GPUs in that case? Is it still recommended to avoid branching?
2
votes
2answers
93 views

Shader cannot move texture x, y location

Crossposted https://forum.openframeworks.cc/t/shader-cannot-move-texture-x-y-location/29395 Hello I am trying to move the x y location of the texture using this code but it doest not work. ...
5
votes
1answer
136 views

Radiative Transfer Equation for Photorealistic Rendering

I've recently become interested in photorealistic rendering, and I've been looking at the different rendering philosophies. I read this Disney Research bachelor's thesis, which states both the ...
2
votes
2answers
173 views

Shader Prototyping Frameworks

I wonder if there exists any shader prototyping framework where I can debug (on cpu) my shaders, experiment with them and instantly see results and even write unit tests. The framework does not have ...
3
votes
4answers
222 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
2answers
219 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
228 views

Parallax/relief mapping with gl_FragDepth and conservative depth

New to writing shaders, please forgive any naivety in the question! Parallax mapping in any of its ray-marchy variants (e.g. steep parallax, cone step mapping, POM) generates fake geometry on a ...
0
votes
1answer
42 views

Dynamically allocating morph targets in shaders

So with the idea that I want to load in an object with morph targets and for simplicity sake I know it will have between 1-8 position morph targets. Ultimately I want to do ...