narthex
  • Member for 5 years, 5 months
  • Last seen this week
GLSL. Can someone explain why gl_FragCoord.xy / screenSize is performed and for what reason?
Accepted answer
30 votes

First, gl_FragCoord.xy are screen space coordinates of current pixel based on viewport size. So if viewport size is width=5, height=4 then each fragment contains: Why are uvs needed? For example I ...

View answer
Getting rid of branching to check if a variable is within a range in GLSL
Accepted answer
10 votes

This could be done that way: First condition is float val = 1.0-step(shouldY, ActualY); Then, the condition: state >= 20.0 && state < 40.0 can be changed to step(20.0, state) - step(...

View answer
Handling Projective Aliasing In Shadow Mapping
Accepted answer
9 votes

Shadow mapping with acceptable quality is quite a journey. So you implemented first step - basic shadow map that encompass whole scene statically. This means that shadow map texel size in light view ...

View answer
Multiple viewports with modern OpenGL?
Accepted answer
8 votes

Rendering to different viewports (parts) of the same screen can be done as follows: For example splitting screen into four parts and rendering the same scene four times to each corner with different ...

View answer
Trying to understand environmental cubemaps
Accepted answer
5 votes

Your confusion comes from fact that in some basic tutorials like one you point cubemap which is used for applying lighting is global and static - it does not come from actual geometry but from infite ...

View answer
What is the difference between a Sampler and an Image variables in GLSL?
5 votes

Images creation is the same as texture, but it must be binded as image to image units. These are equivalent of "texture units". With them you can arbitrarily perform read/write/modify operations using ...

View answer
Advice on how to create GLSL 2D soft smoke/cloud shader
4 votes

There is good glsl source of noise (simplex noise) online to make real time noise. In addition to this, to make effect of moving fog/smoke like in this video you can make 3D FBM function. This is my ...

View answer
Multiple VAO share a VBO
Accepted answer
4 votes

VAO can share VBO's because they do not store vertex data itself but references to Vertex Buffer Objects. So you can first generate your buffers and upload your buffer data (vertex data and index ...

View answer
What is the correct way to put different textures on different parts of an object?
Accepted answer
4 votes

In vertex, put vPos as varying. Then instead of doing the height check in vertex, do it in fragment. if(outVPos.y > 1.2) { textureColor = texture2D(urooftext, outTexCoords); } else { ...

View answer
How can I draw this style of grid?
3 votes

You can do it by only rendering a flat plane and then making a grid in fragment shader. This is actually a nice exercise. To get these two color values, you can use color selector, which is ...

View answer
Spherical Harmonics Diffuse CubeMap. How to get coefficients?
Accepted answer
3 votes

So at start you have samples from your cube map. Each sample has color and normal (dir) at which you sampled that color. This is how I do it. I use coeffs from this paper (the same you linked), there ...

View answer
Clashes when combining openGL and GUI
Accepted answer
3 votes

General answer is that creating a window as a GUI element with some GUI designer library involves subclassing some basic GUI element (like widget in QtCreator for example) with class providing ...

View answer
light probe (for global illumination) placement techniques?
2 votes

Looking for answer for similar question, I found that work: http://www.cse.chalmers.se/~uffe/xjobb/bowald_final_master_thesis_v2.pdf It is based on automatic grid placement which depends on scene ...

View answer
How to use multithreading in 3D software renderer to speed up fetching texture values
2 votes

This is rather general programming question but parallelizing for loop (most common usage) in c++ is easy with openMP library. Basic example for parallelizing outer loop: #pragma omp parallel for ...

View answer
Screen Space Ambient Occlusion Issues
Accepted answer
2 votes

You need to be careful about spaces - position and normal need to be in view space. To transform depth into view space position I used this method. So: vec3 viewPositionFromDepth(vec2 vTexCoord) { ...

View answer
searching for acceptable quality shadow mapping techniques
2 votes

Well nevermind. I made some research and actually gonna: sample ESM using Poisson sampling in PCF fashion (thanks Bart Wronski for great Poisson Sample generator app) and extend this to PCSS ...

View answer
Can I use the same vertices to render multiple things?
Accepted answer
2 votes

If your intention is to render some textured or colored triangles and points colored diferently at the same time at vertex postions with one draw call: glDrawElements(GL_TRIANGLES, draw_count, ...

View answer
Shader code for putting an atmosphere over a planet
1 votes

I believe that Space Engine as a base algorithm still uses Precomputed Atmospheric Scattering by E. Bruneton. It is released on github. So it is good starting point if you want to implement ...

View answer
How to watch image being ray traced?
1 votes

In QtCreator IDE (C++) any kind of image buffer - result of CPU raytracing or (what I did) frames captured from the camera can be easily rendered or painted on Widget - which is simplest part of the ...

View answer
Rotating object around its own center
1 votes

I see you are rendering one quad of grass at the time. Many draw calls each for small number of vertices aren't very efficient and would make massive CPU bottlenecks especially if you want to render ...

View answer
How to clip multiple tiled textures to polygon in Webgl / opengl
1 votes

Quick idea: render platforms color to screen quad render mesh and platforms to screen quad, but as a mask. For example mesh is white, rest is black. in another pass sample these textures and if mask ...

View answer
Rotating an Object Around an Axis
1 votes

Instead of "stacking" or overwriting these transformations on one matrix You may try doing that using matrix multiplication: Matrix4f translate = translate(translation, new Matrix4F() /*identity*/); ...

View answer
ping pong between same framebuffer two color attachments
Accepted answer
1 votes

Actually, GL_COLOR_BUFFER_BIT also need to be cleared After creation of the framebuffer, draw buffer need to be set to: glDrawBuffer(GL_COLOR_ATTACHMENT0); and then after each swap: glClear(...

View answer
Using imageLoad/imageStore to perform atomic add
0 votes

Instead of using compute shader with atomic operations, I used instanced draw call with additive blending. In compute shader I had X as destination texels and Y as different sample directions for each ...

View answer
Texture prefiltering for Linearly Transformed Cosines
Accepted answer
0 votes

I achieved similar result to theirs. First, the target texture for mip generation is base texture size + two margins, each equals 0.125 of base size. Then during generation of base mip level, there ...

View answer
Multiplication of SH coefficient sets representing occlusion and color
Accepted answer
0 votes

I was overthinking it. The usual reconstruction for given direction and then multiplication will work fine probably.

View answer
Frustum aligned volume integration - aliasing issue - temporal reprojection
0 votes

Well actually I think I was doing it wrong. I stored raymarching effects in 2D texture. This is not correct because it suffers from issues. Correct way is store raymarching effect in 3D texture, to ...

View answer