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

Questions tagged [c++]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
14
votes
1answer
8k views

Get vector length with GLM

I am quite confused over how GLM library is behaving or I am using it improperly. glm::vec2 testVec(6,-4); float len = testVec.length(); I get the value ...
13
votes
4answers
751 views

Projected grid water horizon detail

I'm trying to implement an ocean scene with C++ and DirectX11. Currently I have a projected grid, Gerstner waves and a basic shading. My problem is that when I aim my camera horizontally, so I can see ...
11
votes
1answer
2k views

What does “makeContextCurrent” do exactly?

I am pretty confused about that function. GLFW Context reference says as follow: This function makes the OpenGL or OpenGL ES context of the specified window current on the calling thread. A ...
8
votes
2answers
4k views

Archimedean spiral in C++

Im trying to plot the x and y positions of an Archimedean spiral in C++. So far I've been trying something like this, but no luck: ...
8
votes
2answers
680 views

What is a good approach for handling uniforms in modern OpenGL?

I'm creating a renderer using modern OpenGL (3.1 and up) and now I'm trying to create an efficient but flexible way of handling uniforms. I've been reading up on uniform buffer objects and on what a '...
7
votes
1answer
615 views

DirectX12 CbvHeap

With directX12 they introduced heap descriptors. A way for us to describe the table for resources we wanted to send to the shaders. I'm admittedly very new at computer graphics and only tinkered a bit ...
7
votes
1answer
306 views

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

I'm attempting to perform an intersection test using ray casting (not sure if correct term so please forgive me if not) and am outputting the intersections as a point cloud, and the point cloud shows ...
7
votes
2answers
519 views

How to handle a parametric equation in raytracing?

After taking a look at the Mobius strip, I noticed its equation is really simple and tried to add it into my Raytracer. I tried a "naive" way by simply generating N...
7
votes
1answer
546 views

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

I'm new to computer graphics. These days I've been trying to understand how ray tracing using an acceleration data structure works. I came across the term "early ray termination" several times, I ...
7
votes
1answer
161 views

Proper architecture for rendering history of streamed data (points)

Overview My program receives some data points (0-400 per sec). ...
7
votes
1answer
810 views

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

I am trying to implement my own Gradient Domain Path Tracer by following the code of this guy who already implemented it: https://gist.github.com/BachiLi/4f5c6e5a4fef5773dab1 I already managed to ...
6
votes
1answer
502 views

Open GL Shader Storage Buffer Objects to replace Vertex Attributes

At first: I already posted this on the stackoverflow community. I'm new and didn't know about this community here. I apologize. I basically got the same question as the guy who asked here: https://...
6
votes
1answer
3k views

Shadow rays in Raytracing

After spending a few days making very little headway with a simple Raytracing program that implements Phong illumination (with shadows and no attenuation), I'm convinced I've made a logic error that I'...
6
votes
2answers
994 views

OpenGL with SFML, create an n-pointed star?

Completely stuck on how to do this. Yes, it is a homework problem, but its the first we've had in the class so not too familiar with graphics. Also, seeing as its homework, please don't just give the ...
6
votes
1answer
2k views

How can I generate mipmaps manually?

This question has an answer here: https://stackoverflow.com/questions/42596516/generating-mipmaps-manually It was a silly mistake. Sorry for the inconvenience. OpenGL is fairly difficult to learn. ...
6
votes
1answer
432 views

Perspective correct interpolation of normal values

I'm currently writing a software rasterizer and I'm at the point where I can draw arbitrary triangles with vertex colors and perspective correct texture mapping. I do point and directional lighting by ...
5
votes
1answer
2k views

Modern way of light sources in OpenGL?

In older versions of OpenGL there were things like: glLight(...) gl_LightSourceParameters The modern way of doing lighting is passing light source parameters manually to the shader in vao-s? Or ...
5
votes
1answer
271 views

Artifacts when gamma correcting

Doing post-process gamma correction is showing texture artifacts, here is a small example on a skybox: The first image is gamma correcting on the skybox shader and seems correct, the lower is doing ...
5
votes
1answer
663 views

Type conversion to GL-types

If I have a std::vector<Foo> and want to store its size in a GLuint, my compiler gives a warning that there is possible ...
5
votes
1answer
836 views

Role of PDF of Uniform Random Sampling in a path tracer

I am trying to implement my own path tracer but before arriving to the question I want to give you a short overview: In the implementation of the rendering equation I use some particular technique in ...
5
votes
2answers
117 views

Problem with Basic Diffuse Lighting

So recently I have been learning how to implement Diffuse Lighting in DirectX and I have done so with the following code: ...
5
votes
1answer
160 views

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

I'm working on implementing Bruneton's cloud rendering paper, which requires one to render a pair of depth maps, similar to how shadow mapping works. In this case, my light source is the sun (or ...
5
votes
2answers
455 views

How to check which API's are available on a given machine?

I'm building an engine, which has Vulkan for its primary rendering engine. But to have at least some backwards compatibility with devices that don't have drivers for it (mainly mobile) I want to ...
5
votes
1answer
909 views

Ray-triangle intersection algorithm not intersecting (C++)

I've been trying to implement the Moller-Trumbore ray-triangle intersection algorithm in my raytracing code. The code is supposed to read in a mesh and light sources, fire off rays from the light ...
5
votes
1answer
523 views

Inverse value in a Perspective Matrix

I am a new leaner of computer graphics. I'm trying to understand a code I found online and I got stuck in the following formula: ...
5
votes
1answer
183 views

How to rasterize a line when the background color is not always white?

I've to rasterize a line taking into account not only the background color of the screen, which is white, but also the color of other objects in the scene. In my case, I've just another object, a ...
5
votes
1answer
1k views

Draw angles lines in raster graphics using bresenham line algorithm

I at the moment trying to draw some angled lines using bresenham line algorithm which can circulate a 2d array of size 21x21, as a line angled from 0 - 2pi. So the idea is that the program has to ...
5
votes
0answers
179 views

How to account for self intersection with large ray tracing scenes?

I'm working on a hybrid real time ray tracing project and trying to tackle the problem of self-intersection with larger scenes due to loss of float accuracy. The logic I'm trying to use is based on ...
5
votes
0answers
157 views

Computation of conservative AABB for clipped triangle

I'm currently trying to implement a fast algorithm for KD-Tree construction using SAH, as described in this paper: On building fast KD-trees for ray tracing, and on doing that in O(N log N) I found ...
4
votes
2answers
554 views

Path tracer not rendering shadows

I am trying to implement for research purposes a gradient-domain path tracer. In order to achieve this step I first need a working Path tracer. I have been creating one so far but results are wrong ...
4
votes
2answers
188 views

Strange behaviour in vertex shader with divisions

This is the vertex shader code: ...
4
votes
1answer
529 views

Angle between two points in Cartesian coordinate system C++

I'm trying to rotate a rectangle so that it faces another rectangle in a spiral. Im using the Bullet pyhics library and freeglut for the 3d application, for anyone interested https://github.com/...
4
votes
1answer
646 views

Dx12 Vertex Buffer incorrect

I'm playing around with directX 12 and I'm having some problems loading geometry in. I have a std::vector vertices definition and I do exactly what the dx12 template does with it. ...
4
votes
1answer
1k views

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

I've written an implementation of the sphere tracing algorithm in OpenGL 4+. As an experiment/toy project, I'm re-implementing it using the OpenGL 4.3 compute shader, but I'm having trouble with the ...
4
votes
1answer
1k views

How to get the GLFW_CONTEXT_VERSION_MAJOR value?

This code snippet: ...
4
votes
1answer
3k views

DirectX 12 Constant Buffer Binding

I can't really seem to figure out how to bind two constant buffers to my shaders. I have them described like so. One in slot b0 and the other in slot b1. ...
4
votes
1answer
228 views

Can't make blending work

I have a 3 dimensional dataset where each value of the dataset is normalized to [0, 1]. I want to visualize this dataset by using texture, and blending. However, it ...
4
votes
1answer
607 views

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

I am trying to implement for research purposes a path tracer, but so far but results are not so good and I will explain you why. The general idea before getting to the code: I am working on paths ...
4
votes
1answer
115 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
232 views

Material Layering

So after reading this Unreal Engine 4 Documentation page: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/LayeredMaterials/ (Which describes how to use material layering in UE4) ...
4
votes
1answer
310 views

Flexible Vertex Format Constants in Direct3D 11

How do you migrate Flexible Vertex Format Constants (or FVF codes) from DirectX 9 to Direct3D 11? Old code: ...
4
votes
1answer
111 views

Uniform not set, despite valid location

I try to write a simple triangle mesh renderer with OpenGL. ...
4
votes
1answer
171 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
314 views

ray-triangle intersection precision - c++

I'm building a software renderer but I think there might be some problem with my ray-triangle intersection accuracy. I implemented the algorithm referring to ...
4
votes
0answers
315 views

Incorrect instanced rendering

Previously, to render a bunch of quads, I was simply using a few uniforms (one for a model matrix and another for the texture layer ID). However, I'd rather not have to loop through each quad and set ...
3
votes
1answer
284 views

Generate this kind of 2d burst or pulse algorithm?

I'm currently trying to develop a game using Cocos2d-x using C++. I really need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was ...
3
votes
2answers
734 views

How to watch image being ray traced?

In my ray tracer, I render my images out to a .PPM file and then view it in photoshop. To make things easier and faster I want my ray tracer to open up another window and show the image being rendered ...
3
votes
1answer
459 views

Ray-tracing the Cornell Box results in really inconsistent image

So I have a vector of glm::vec3 containing the triangles for the classic Cornell Box called triangles. The Draw method casts a ray for each pixel on the screen and ...
3
votes
3answers
219 views

Is there a difference between window and screen in computer graphics?

I've been reading some code which setups a ray tracer and I've realized I've a doubt regarding what's a screen and what's a window in this context. Here's the relevant code using Qt: ...
3
votes
1answer
300 views

Creating a gently moving 2D fog effect

I am trying to create a fog-like effect, similar to that found using perlin noise. I know where I can find information about that effect, but it's harder for me to tell if it's an efficient route for ...