Questions tagged [c++]
The c++ tag has no usage guidance.
167
questions
17
votes
1answer
12k 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
1answer
3k 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 ...
13
votes
4answers
1k 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 ...
8
votes
2answers
6k 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
1k 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
738 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
348 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
643 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
1k 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 ...
7
votes
1answer
770 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
182 views
Proper architecture for rendering history of streamed data (points)
Overview
My program receives some data points (0-400 per sec).
...
7
votes
1answer
963 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 ...
7
votes
1answer
3k 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
2answers
619 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
5k 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
1k 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
534 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
3k views
How do I create a Win32 window with a Vulkan context?
I am aware of libraries that already do this (like GLFW), but I would actually prefer do all of the window and context creation by myself.
5
votes
1answer
338 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
968 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
2k 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 ...
5
votes
1answer
163 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
131 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
832 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 ...
5
votes
2answers
799 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
1k 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
214 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
0answers
348 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
228 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
658 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
200 views
4
votes
1answer
761 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
284 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
1k 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:
...
4
votes
1answer
257 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
191 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
1answer
2k 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 ...
4
votes
0answers
336 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
650 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/...
3
votes
1answer
246 views
How to unproject cursor with orthographic projection
With perspective projection we can unproject screen space coordinates of the cursor to the near and far plane of the frustum and calculate the direction of the ray through the cursor.
...
3
votes
1answer
2k views
3
votes
1answer
4k 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.
...
3
votes
1answer
199 views
Shader that transforms a mercator projection to equirectangular?
I am new in the OpenGL - GLSL and trying to make a shader that taking a mercator projection texture as a source and converting it to an equirectangular projection texture.
Sample input: (1024x1024)
...
3
votes
1answer
393 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 ...
3
votes
1answer
2k views
What do the OpenGL version strings from glxinfo actually mean?
Note: I wasn't 100% certain if this question belonged here or in Ask Ubuntu. I figured since it was about OpenGL programming I'd put it here, but if I should move it to Ask Ubuntu, please let me know.
...
3
votes
1answer
291 views
Wrong color in .ppm file
I'm going through the rasterizer tutorial from Scratchapixel, but I encountered a problem with the generation of the .ppm file. Since something was off, I reduced the example to the bare minimum, so I ...
3
votes
1answer
2k views
Please, help me to understand why my raytracing camera rotates in wrong directions?
I'm trying to build a raytracer and I use this article on how to build camera system. The problem is that when, after calculating ray direction in camera space, I multiply it by camera-to-world ...
3
votes
1answer
121 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 ...
3
votes
1answer
423 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:
...