The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
0
votes
0answers
8 views

GLSL - increasing line spacing with y

I'm trying to force perspective into the horizon of a Shadertoy scene by drawing horizontal lines at decreasing distances as y grows to create an outrun-esque scene, but can't figure out which ...
0
votes
0answers
13 views

Voronoi pattern with toon lighting

I currently have a single step toon shader using this simple behaviour (no anti-aliasing for the moment). As expected the result is a single straight line. ...
0
votes
1answer
13 views

What are the type constants that the documentation for glGetProgramResourceiv() refers to?

Quoting the Khronos OpenGL documentation pages for the glGetProgramResourceiv() function: For the property GL_TYPE, a single integer identifying the type of an ...
1
vote
0answers
30 views

How to render multiple shaders per mesh

I've tried looking everywhere, but I just don't get it. How is multiple shaders assigned to a mesh if you can only bind a single shader in OpenGL? Assume I have a mesh with a texture shader and now I ...
2
votes
0answers
47 views

Implementing GGX VNDF importance sampling with DXR

I am currently implementing the GGX specular BRDF in a DXR raytracer using the importance sampling method describe by Heitz I am sampling the VNDF with: ...
2
votes
0answers
46 views

Calculate the distance between two 3d points in screen coordinates

Given the Point A with the coordinates gl_FragCoord.xy, I have to find the distance to the Center of the cube face to which it belongs in screen coordinates. ...
1
vote
0answers
22 views

Confusion about glVertexAttribPointer and non-active attributes

When binding an attribute index using glVertexAttribPointer, what happens when a later bound program does not contain an attribute at said index? Is the behaviour undefined, or is the attribute ...
4
votes
1answer
70 views

Why is OpenGL recompiling my depth map vertex shader based on the GL state?

I've written a shader that writes depth to each face of a cube map, as part of rendering cube map shadows for a realtime 3D engine I'm writing with OpenGL and C++. The shader transforms each vertex ...
2
votes
1answer
41 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
48 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
65 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
78 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
95 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
112 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 ...
0
votes
1answer
133 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 ...
2
votes
1answer
107 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, ...
-1
votes
1answer
94 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.
2
votes
0answers
58 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 ...
0
votes
1answer
90 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 ...
2
votes
1answer
66 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 ...
1
vote
1answer
106 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 ...
2
votes
1answer
54 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 ...
1
vote
1answer
303 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 ...
1
vote
1answer
224 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 ...
0
votes
1answer
125 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
138 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
900 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 ...
1
vote
1answer
338 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
93 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
1answer
231 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
2answers
368 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
202 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
353 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 (...
3
votes
2answers
361 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 ...
11
votes
2answers
4k 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?
1
vote
1answer
58 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
43 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
760 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 ...
1
vote
0answers
407 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
131 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
152 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
155 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
57 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
78 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?
5
votes
1answer
150 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 ...
0
votes
1answer
46 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 ...
3
votes
4answers
246 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 ...
1
vote
1answer
53 views

Non-point lights

Is there a technique for implementing non-point lights (i.e. light that has actual physical dimensions)? I can't think of anything except than making a light source out of multiple point lights, but ...