Hot answers tagged

30 votes
Accepted

What does "makeContextCurrent" do exactly?

OpenGL is a state machine. An OpenGL context holds that state. The state contains information such as which textures are bound to which texture units, which attachments the current FBO has, and things ...
user1118321's user avatar
  • 3,401
23 votes

Get vector length with GLM

Sorry folks for posting such a trivial issue! The issue is solved. I was using the wrong function. Here goes the correct one: ...
sajis997's user avatar
  • 1,229
10 votes

DirectX12 CbvHeap

In DX12, a descriptor is a small record, basically a pointer, that tells the GPU where to find some data such as a constant buffer. Since each object is going to have its own constant buffer data with ...
Nathan Reed's user avatar
  • 24.7k
9 votes
Accepted

Ray casting in fan configuration produces point cloud with curvature, how to eliminate curvature?

The direction vectors start at +15 degrees on the YZ plane, and continue in increments of -2 degrees down to -15. There's your problem—by generating the rays that way, you're doing something more ...
Nathan Reed's user avatar
  • 24.7k
9 votes
Accepted

Modern way of light sources in OpenGL?

Why are they deprecated? Those functions are deprecated because the OpenGL API moved in favor of a programmable pipeline in contrast with the old fixed pipeline. The programmable pipeline allows the ...
Samu's user avatar
  • 546
7 votes
Accepted

Role of PDF of Uniform Random Sampling in a path tracer

Firstly, as @trichoplax correctly pointed out, your randomPoint function calculates a point in a cube, then uses rejection sampling to return all points that are inside a unit sphere. In order to ...
RichieSams's user avatar
  • 3,732
7 votes
Accepted

Generate this kind of 2d burst or pulse algorithm?

Rather than using an image, I would suggest doing this kind of effect using a shader. I'm not familiar with Cocos2d-x, but some quick googling suggests that it can work with shaders. You'd use a pixel ...
Nathan Reed's user avatar
  • 24.7k
7 votes
Accepted

Archimedean spiral in C++

Figured it out :) The dominos are now being placed along the X and Y coordinates generated by the function. The original code in the question was plotting a wave of points outwards from the centre ...
David's user avatar
  • 303
7 votes
Accepted

Projected grid water horizon detail

I believe a common solution is to split the camera transform used to project the grid from the camera transform that is used to render the grid. At perspectives close to top-down, the two cameras ...
Benedikt Bitterli's user avatar
7 votes

How can I utilize all cores of CPU In my ray tracer with std::thread?

This is not really a CG issue but you appear to have an integer division problem. Assuming mMaxThreads is an integer, ...
Olivier's user avatar
  • 1,585
7 votes
Accepted

How do I create a Win32 window with a Vulkan context?

There's no such thing as a Vulkan context, the way there is with OpenGL. This is because Vulkan is a lower level API and an OpenGL context ties together a number of concepts that are distinct in the ...
Jherico's user avatar
  • 511
6 votes

Projected grid water horizon detail

You can be both realistical and real-time. the secret is to change representation each time the information get under the Shannon-Nyquist (i.e. grid) scale: from geometry to normal maps to shading ...
Fabrice NEYRET's user avatar
6 votes
Accepted

How to convert a thread ID into Screen Space Coord in an OpenGL Compute Shader?

The problem is actually in your fragment shader: color_out = texture(source_image, gl_FragCoord.xy); The texture() function accepts normalized coordinates which ...
Jason Allen's user avatar
6 votes
Accepted

Shadow rays in Raytracing

Your if condition makes me suspicious. You should include the diffuse and specular shading if the intersection test didn't hit an object; that is, if ...
Dan Hulme's user avatar
  • 6,700
6 votes
Accepted

Path tracer not rendering shadows

The problem appears to be unintentionally transparent surfaces Although the image is grainy, it is sufficiently clear to estimate that all of the darker regions are due to surfaces facing away from ...
trichoplax is on Codidact now's user avatar
6 votes
Accepted

Open GL Shader Storage Buffer Objects to replace Vertex Attributes

The counter you want is built in the shader as gl_VertexID. However you have 16 attributes of 4 components each to work with. Take 2 components for the texture ...
ratchet freak's user avatar
6 votes
Accepted

Artifacts when gamma correcting

Short answer, set the precision of the image to a higher value. Long answer, When looking at a gamma correction curve, you can see that the lower values get changed much more, this means that the ...
bram0101's user avatar
  • 1,595
6 votes

How to handle a parametric equation in raytracing?

Many years ago I worked on a ray tracer that handled parametric surfaces, so this is unlikely to be state of the art, but, IIRC, I used a combination of interval arithmetic with (binary?) subdivision ...
Simon F's user avatar
  • 4,171
5 votes

Resulting Probabilty Density in Path Tracer for paths using Next Event Estimation

I don't have any experience with Gradient Domain Path Tracing, but here are my thoughts: There seems to be a different problem If you look carefully at the little spikes of distortion in the final ...
trichoplax is on Codidact now's user avatar
5 votes

Path tracer not rendering shadows

is it correct having such a big light? I don't see any problem with having a big area light. That said, it also depends on the scale of your scene. If the light is large compared to it, shadows will ...
Julien Guertault's user avatar
5 votes

How to compensate low amount of rays reaching the light in a Path Tracer

A note first From the look of your screen capture, I suspect there might still be a bug in your code. Noise is to be expected with only 16 spp, but your picture still looks surprisingly dark to me. ...
Julien Guertault's user avatar
5 votes

The meaning of early ray termination and front-to-back traversal in ray tracing

Front-to-back traversal is the idea that when traversing a ray through the acceleration structure, we want to examine nodes that are in front, i.e. closer to the camera, before other nodes. If you ...
Nathan Reed's user avatar
  • 24.7k
5 votes
Accepted

How should I generate the view position for a light at infinity when creating depth maps?

Instead of using a perspective projection you would use a orthographic projection. Then the trick is to position the bounding box to in front of the normal camera. An additional option is to add a ...
ratchet freak's user avatar
5 votes
Accepted

Angle between two points in Cartesian coordinate system C++

The parametric equation for a spiral is: $$ \begin{eqnarray} \begin{aligned} x &= &(a + b \theta) \times \cos(\theta)\\ z &= &(a + b \theta) \times \sin(\theta) \end{aligned} \...
joojaa's user avatar
  • 8,397
5 votes
Accepted

Dx12 Vertex Buffer incorrect

Vector has a few different semantics from static arrays. For one it's a struct containing a pointer a capacity and a length (at the very least). That means that ...
ratchet freak's user avatar
5 votes
Accepted

Swap buffers twice does not show the first scene

If you swap buffers, you have a triangle in your screen and a empty color buffer in the other side. No, you do not. Buffer swapping does not necessarily mean that the current contents of the front ...
Nicol Bolas's user avatar
  • 9,697
5 votes
Accepted

Strange behaviour in vertex shader with divisions

The vertex shader only runs per vertex, not for every point in the square. So the four vertices are mapped to (±2, ±2), and then the GPU draws a polygon between those vertices, which does cross the ...
Nathan Reed's user avatar
  • 24.7k
5 votes

How to use multithreading in 3D software renderer to speed up fetching texture values

It could be that you have to overcome a different bottleneck first. Have you ever read Jim Blinn's "The Truth About Texture Mapping"? (I had a quick search to see if I could find a non-paywalled ...
Simon F's user avatar
  • 4,171
5 votes

Vulkan best way of updating pipeline viewport

Both suggested methods are fine, but they should be preferred in certain situations. Dynamic state should be preferred in situations where you have many, perhaps thousands of, pipeline objects or you ...
aces's user avatar
  • 1,353

Only top scored, non community-wiki answers of a minimum length are eligible