r/GraphicsProgramming • • Feb 27 '19

We're in UltraHD Morty! How to watch any movie in 4K (upscaling with neural networks and Photoshop)

Thumbnail
habr.com
0 Upvotes

r/GraphicsProgramming • • May 27 '24

Old question, but what are the system requirements for OpenGL ?

0 Upvotes

I am primarily a Machine Learning Engineer, however I have been meaning to learn something related to graphics as a hobby. So, I was hoping if I could start with OpenGL programming.

I have a laptop with 16gb RAM, RTX 3050 with 4gb VRAM and a 512 SSD. I also have a 256gb External SSD.

I was hoping if these specs are enough to develop a working model of a 3D game, a type of FPS. I have already coded the same game in Godot but was thinking of doing something more performance based.

It would also help if I get some online resources related to OpenGL. I work well with books and video lectures.

PS - I also know a bit of Rust and JavaScript. Do inform me if that could help.


r/GraphicsProgramming • • Jul 05 '17

Can you get a GPU to redraw the same frame over and over again?

0 Upvotes

Is it possible to redraw a frame after you've finished drawing it?

Example: draw frame 1, show frame 1 again, show frame 1 again, draw frame 2, etc

Is this possible?


r/GraphicsProgramming • • Sep 20 '22

Graphics Programmer opportunity available at GoPro!

3 Upvotes

GoPro has an exciting Advanced Technology role available. This is a fully remote role that can be done from anywhere in the United States. Please apply online or message me with any questions.

https://jobs.gopro.com/jobs/engineering/remote-usa/staff-software-engineer-advanced-technology/4162269?gh_jid=4162269#/


r/GraphicsProgramming • • Jun 13 '25

How stressful is graphics programming?

19 Upvotes

I'm battling with psychosis and major depression. I cannot function well when especially when i'm stressed. Lately i've been interested in the field but i don't know if i have what it takes. How stressful is your job in best and worst cases?


r/GraphicsProgramming • • Apr 04 '26

Help.Problem loading texture

Thumbnail
gallery
0 Upvotes

1 picture how it looks for me, 2 how it should look

I'm trying to implement loading GLB models in Opengl, the vertices are displayed correctly, but the textures are displayed incorrectly, and I don't understand why.

Texture loading code fragment:

if (!model.materials.empty()) {

const auto& mat = model.materials[0];

if (mat.pbrMetallicRoughness.baseColorTexture.index >= 0) {

const auto& tex = model.textures[mat.pbrMetallicRoughness.baseColorTexture.index];
const auto& img = model.images[tex.source];

glGenTextures(1, &albedoMap);
glBindTexture(GL_TEXTURE_2D, albedoMap);

GLenum format = img.component == 4 ? GL_RGBA : GL_RGB;

glTexImage2D(GL_TEXTURE_2D, 0, format, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.image.data());

glGenerateMipmap(GL_TEXTURE_2D);
}

}

Fragment shader:

#version 460 core

out vec4 FragColor;

in vec3 FragPos;
in vec2 TexCoord;
in vec3 Normal;
in mat3 TBN;

uniform sampler2D albedoMap;
uniform sampler2D normalMap;
uniform sampler2D metallicRoughnessMap;

uniform vec2 uvScale;
uniform vec2 uvOffset;

void main(){

    vec2 uv = TexCoord * uvScale + uvOffset;
    FragColor = vec4(texture(albedoMap, uv).rgb, 1.0);

}

r/GraphicsProgramming • • Jul 24 '26

Kanvon - Lua Scripting Showcasing Algorithms

0 Upvotes

r/GraphicsProgramming • • Apr 03 '26

trying to learn openGL to try and make something, unsure how to start

0 Upvotes

this might be a dumb question, but i feel like after a the first 2 chapters in learnopengl, it feels like i'll know how to do these specific things, but ill always have to circle back if i want to make something outside of that scope, like sure, i can do the whole "getting started" chapter, but will i know how to, for example, make a basic minecraft clone? there are alot of concepts in something like that that i feel most tutorials wont teach you, and ill end up only knowing the things a tutorial would teach you, should i be starting with small projects after a chapter or two to learn? i feel like im being vague, so please tell if thats the case!


r/GraphicsProgramming • • Jan 23 '20

Question How do i create a UI without a desktop environment? (Raspbian Linux)

0 Upvotes

Hi! I want to make a graphical user interface (GUI) that starts when i boot up my Raspberry PI (Would be really nice if all the other splash screens with text and other stuff wouldn't show either). My vision is like a car display system, where i could make my own bootanimation and control everything i see, including animations.

I basicly just want a good way (something that looks professional and gives me full control) of making a UI with lists and tabs i could navigate between with buttons i choose (probalby via the GPIO-pins).

I have experience with web development and some experience of android development. Python, Java, Kotlin, C#, The language doesn't really make that much of a difference as long as i can control the GPIO-pins. Everything I've found is like "Really easy tkinter python programs", which I'm not willing to use, and doesn't give me that much control. The problem is also that everything I've found depends on having a Desktop environment, like raspbian desktop, but as I don't use the desktop and I don't want the extra boot time, I wan't something that works from the raspbian command interface.

Would be nice hearing from you, as I'm new to this subreddit. Thank you in advance!


r/GraphicsProgramming • • Oct 16 '26

Video Head-to-head - literally :) my CPU renderer vs SwiftShader on 4 logical processors

12 Upvotes

413,532 triangles, with no geometry simplification

960 × 840 resolution

4 logical processors, enforced through process affinity

96 measured frames per renderer, following the same camera path

8 stationary warmup frames each

Pop Data Engine is 1.78× faster in this run.

Just bragging :)

It is in early development (this is actually 3d engine development for my OS) so there is a lot to work on, but it is fast :)


r/GraphicsProgramming • • Oct 10 '25

Software renderer?

Thumbnail reddit.com
0 Upvotes

r/GraphicsProgramming • • Aug 12 '24

Camera not working

0 Upvotes

(Solved)

This is sort of a two part problem I'm having. I'm currently working on adding a camera to my vulkan renderer. I'm doing this by creating and handling a camera along with its inputs, setting the mvp matrix of the object, updating the view matrix of the object and camera, then sending these to push constants in my vertex shader.

Here's my code for creating the camera

typedef enum
{
    FORWARD,
    BACKWARD,
    LEFT,
    RIGHT
}   movement;

typedef struct
{
    vec3 position, front, up, right, world_up;
    float lastx, lasty, fov, yaw, pitch, speed, sens;
    bool first_mouse;
}   camera;

static void camera_update_vecs(camera *c)
{
    vec3 new = {0, 0, 0};
    new[0] = cos(glm_rad(c->yaw)) * cos(glm_rad(c->pitch));
    new[1] = sin(glm_rad(c->pitch));
    new[2] = sin(glm_rad(c->yaw)) * cos(glm_rad(c->pitch));
    glm_normalize_to(new, c->front);

    vec3 temp = {0, 0, 0};
    glm_cross(c->front, c->world_up, temp);
    glm_normalize_to(temp, c->right);
    glm_cross(c->right, c->front, temp);
    glm_normalize_to(temp, c->up);
}

camera camera_init(vec3 pos)
{
    camera c =
    {
        .position = {*pos},
        .front = {0.0f, 0.0f, -1.0f},
        .world_up = {0.0f, 1.0f, 0.0f},
        .lastx = 400,
        .lasty = 300,
        .fov = 45.0f,
        .yaw = -90.0f,
        .pitch = 0.0f,
        .speed = 2.5f,
        .sens = 0.1f,
        .first_mouse = true
    };

    return c;
}

void camera_view_mat(camera *c, mat4 view)
{
    vec3 temp = {0, 0, 0};
    glm_vec3_add(c->position, c->front, temp);
    glm_lookat(c->position, temp, c->up, view);
}

void camera_keyboard_input(camera *c, movement m, float delta_time)
{
    float velocity = c->speed * delta_time;
    vec3 temp = {0, 0, 0};
    switch (m)
    {
        case FORWARD:
            glm_vec3_muladds(c->front, velocity, temp);
            glm_vec3_add(c->position, temp, c->position);
            break;

        case BACKWARD:
            glm_vec3_muladds(c->front, velocity, temp);
            glm_vec3_sub(c->position, temp, c->position);
            break;

        case LEFT:
            glm_vec3_muladds(c->right, velocity, temp);
            glm_vec3_sub(c->position, temp, c->position);
            break;

        case RIGHT:
            glm_vec3_muladds(c->right, velocity, temp);
            glm_vec3_add(c->position, temp, c->position);
            break;

        default:
            printf("Error: Unrecognized movement direction\n");
            break;
    }
}

void camera_mouse_input(camera *c, float xoffset, float yoffset)
{
    xoffset *= c->sens;
    yoffset *= c->sens;

    c->yaw += xoffset;
    c->pitch += yoffset;

    if (c->pitch > 89.0f)
        c->pitch = 89.0f;
    if (c->pitch < -89.0f)
        c->pitch = -89.0f;

    camera_update_vecs(c);
}

And this is my code for handling camera input

void input_handle(GLFWwindow *window, camera *c, float delta_time)
{
    input_handle_keyboard(window, c, delta_time);
    input_handle_mouse(window, c);
}

void input_handle_keyboard(GLFWwindow *window, camera *c, float delta_time)
{
    if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
        glfwSetWindowShouldClose(window, true);
    if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
        camera_keyboard_input(c, FORWARD, delta_time);
    if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
        camera_keyboard_input(c, BACKWARD, delta_time);
    if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
        camera_keyboard_input(c, LEFT, delta_time);
    if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
        camera_keyboard_input(c, RIGHT, delta_time);
}

void input_handle_mouse(GLFWwindow *window, camera *c)
{
    double xpos = 0.0, ypos = 0.0;
    glfwGetCursorPos(window, &xpos, &ypos);

    if (c->first_mouse)
    {
        c->lastx = xpos;
        c->lasty = ypos;
        c->first_mouse = false;
    }

    float xoffset = xpos - c->lastx;
    float yoffset = ypos - c->lasty;

    c->lastx = xpos;
    c->lasty = ypos;

    camera_mouse_input(c, xoffset, yoffset);
}

Here is the code where I fill out the push constant data (note I'm using cglm instead of glm so the syntax may look a bit strange to those who are unfamiliar with it)

typedef struct
{
    mat4 mvp;
}   vk_push_const;

void vk_push_const_buffer_init(camera *c, vk_push_const mvp, VkExtent2D img_extent)
{
    mat4 model = GLM_MAT4_IDENTITY_INIT;
    mat4 view = GLM_MAT4_IDENTITY_INIT;
    mat4 proj = GLM_MAT4_IDENTITY_INIT;

    glm_perspective(c->fov, (float) img_extent.width / (float) img_extent.height, 0.1f, 100.0f, proj);
    camera_view_mat(c, view);

    glm_mat4_mulN((mat4 *[]) {&proj, &view, &model}, 3, mvp.mvp);
}

Here's me sending the push constant data to the vertex shader

    vk_push_const mvp = {0};
    vk_push_const_buffer_init(c, mvp, s->img_extent);

    vkCmdPushConstants(cmd_buffers, layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(mvp), &mvp);

Here's me setting and using the camera in the game loop

typedef struct
{
    vk_context vk;
    camera c;
    float delta_time, last_frame;
}   game;

game game_init(bool debugging)
{
    game g =
    {
        .vk = vk_context_init("Game", debugging),
        .c = camera_init((vec3) {0.0f, 0.0f, 3.0f}),
        .delta_time = 0.0f,
        .last_frame = 0.0f
    };

    return g;
}

static void game_calc_delta_time(game *g)
{
    float current_frame = glfwGetTime();
    g->delta_time = current_frame - g->last_frame;
    g->last_frame = current_frame;
}

void game_run(game *g)
{
    while (!glfwWindowShouldClose(g->vk.d.window))
    {
        game_calc_delta_time(g);

        input_handle(g->vk.d.window, &g->c, g->delta_time);

        vk_context_run(&g->vk, &g->c);

        vk_window_poll_events();
    }

    vkDeviceWaitIdle(g->vk.d.device);
}

And finally, here's the vertex shader

#version 450

layout (location = 0) in vec2 in_pos;
layout (location = 1) in vec3 in_color;

layout (location = 0) out vec3 frag_color;

layout (push_constant) uniform push_const
{
    mat4 mvp;
}   mvp;

void main(void)
{
    gl_Position = mvp.mvp * vec4(in_pos, 0.0, 1.0);
    frag_color = in_color;
}

If I comment out the mvp matrix in the vertex shader here's what I see

However if I bring back the mvp matrix this is what I end up seeing

I don't think the problem is with the camera inputs because I already tested those out by adding print statements to make sure that they were at least being accessed and the inputs were being registered and validation layers are saying nothing

Edit: I fixed the problem I think the matrix data was uninitialized when I was sending it over this is the code I edited to fix it

static void camera_update_vecs(camera *c)
{
    vec3s new = GLMS_VEC3_ZERO_INIT;
    new.x = cos(glm_rad(c->yaw)) * cos(glm_rad(c->pitch));
    new.y = sin(glm_rad(c->pitch));
    new.z = sin(glm_rad(c->yaw)) * cos(glm_rad(c->pitch));
    glm_normalize_to(new.raw, c->front.raw);

    vec3s temp = glms_cross(c->front, c->world_up);
    glm_normalize_to(temp.raw, c->right.raw);
    temp = glms_cross(c->right, c->front);
    glm_normalize_to(temp.raw, c->up.raw);
}

camera camera_init(vec3s pos)
{
    camera c =
    {
        .position = pos,
        .front = {{0.0f, 0.0f, -1.0f}},
        .world_up = GLMS_YUP,
        .lastx = 400,
        .lasty = 300,
        .fov = 45.0f,
        .yaw = -90.0f,
        .pitch = 0.0f,
        .speed = 2.5f,
        .sens = 0.1f,
        .first_mouse = true
    };

    return c;
}

mat4s camera_view_mat_init(camera *c)
{
    vec3s temp = glms_vec3_add(c->position, c->front);
    mat4s view = glms_lookat(c->position, temp, c->up);

    return view;
}

void camera_keyboard_input(camera *c, movement m, float delta_time)
{
    float velocity = c->speed * delta_time;
    vec3s temp = GLMS_VEC3_ZERO_INIT;
    switch (m)
    {
        case FORWARD:
            glm_vec3_muladds(c->front.raw, velocity, temp.raw);
            glm_vec3_add(c->position.raw, temp.raw, c->position.raw);
            break;

        case BACKWARD:
            glm_vec3_muladds(c->front.raw, velocity, temp.raw);
            glm_vec3_sub(c->position.raw, temp.raw, c->position.raw);
            break;

        case LEFT:
            glm_vec3_muladds(c->right.raw, velocity, temp.raw);
            glm_vec3_sub(c->position.raw, temp.raw, c->position.raw);
            break;

        case RIGHT:
            glm_vec3_muladds(c->right.raw, velocity, temp.raw);
            glm_vec3_add(c->position.raw, temp.raw, c->position.raw);
            break;

        default:
            printf("Error: Unrecognized movement direction\n");
            break;
    }
}

void camera_mouse_input(camera *c, float xoffset, float yoffset)
{
    xoffset *= c->sens;
    yoffset *= c->sens;

    c->yaw += xoffset;
    c->pitch += yoffset;

    if (c->pitch > 89.0f)
        c->pitch = 89.0f;
    if (c->pitch < -89.0f)
        c->pitch = -89.0f;

    camera_update_vecs(c);
}

typedef struct
{
    mat4s mvp;
}   vk_push_const;

vk_push_const vk_push_const_buffer_init(camera *c, VkExtent2D img_extent)
{
    vk_push_const mvp = {0};

    mat4s model = GLMS_MAT4_IDENTITY_INIT;
    mat4s view = camera_view_mat_init(c);
    mat4s proj = glms_perspective_rh_no(glm_rad(c->fov), (float) img_extent.width / (float) img_extent.height, 0.1f, 100.0f);

    glm_mat4_mulN((mat4 *[]) {&proj.raw, &view.raw, &model.raw}, 3, mvp.mvp.raw);

    return mvp;
}

r/GraphicsProgramming • • Jan 18 '24

Not loving C++

12 Upvotes

How crippling it is for somebody in the field of graphics programming to not love C++? I'm learning C++ right now and really don't like the experience. I wonder how bad it would be for me if I stuck with a very basic subset of C++, closer to C than to modern C++. Does that disqualify me from getting a lot of jobs, even if I'm otherwise competent entry-level graphics programmer?

To put my question in more concrete terms: I'm currently writing a gltf loader (purely as an exercise). As a part of that, I need to parse JSON, so I'm writing a JSON parser as well. Now, I could write the JSON parser using all the modern c++ features, most notably unique_ptr, but passing those unique_ptrs creates a lot of accidential complexity. Notably, I'm constantly getting various compiler errors. I'm muddling through them, but I'm not sureI see the light at the end of the tunnel - C++ spec seems so large that I can see myself still fighting the language even 5 years from now, instead of having fun with it. Whereas, I could skip all that, and just allocate the elements of the Json object tree in a basic memory arena, load whatever I need from the Json into relevant buffers, and then just free the entire arena. That's super-simple memory management approach that is totally sufficient here (I'm not going to ever need to free arbitrary subtrees of the JSON tree), and is something that's advocated by Casey Muratori in his streams.


r/GraphicsProgramming • • Jul 29 '21

Possible to stretch/flatten this to be useable?

0 Upvotes

There's a post on mapmaking that has me curious if there's a way to grab the selected area and flatten it out appropriately. https://redd.it/ote25y

Does anyone have any ideas?


r/GraphicsProgramming • • Jan 15 '22

Need graphics dev for demoscene project

0 Upvotes

Hello,

My team manawar is looking for a graphics developer with some experience with DXR and DX12. We plan on releasing a demo in early summer and want to add some additional effects. We mostly do this in our small amount of free time and it helps improve our graphics knowledge as we learn. Here is some of our previous work https://youtu.be/qlu-Ga-MMGo https://youtu.be/urLWuG3p2qU. Lmk if you want to join our team and do some fun ray tracing/path tracing. Here is a link to the repo but requires a GPU that supports DXR so you need either RTX 2000-3000 or RDNA 6000. https://github.com/octopusprime314/atparty2021


r/GraphicsProgramming • • Feb 24 '23

Unreadable text from simple2d

0 Upvotes

I have this code that does not show the desired text properly:

    #include <simple2d.h>
    #include <stdio.h>
    #include <stdlib.h>

    #define X_MAX 800 
    #define Y_MAX 600 

    void render(void)
    {
        int x=400;
        int y=300;
        S2D_Text *beg_text = S2D_CreateText("/usr/share/fonts/gnu-free/FreeSans.ttf", "The text", 25);
    
        if(beg_text==NULL)
        {
            fprintf(stderr,"simple2d text creation failed.\n");
        }
    
        beg_text->x = x + 10;
        beg_text->y = y;
        beg_text->color.r = 0.1;
        beg_text->color.g = 0.1;
        beg_text->color.b = 0.1;
        beg_text->color.a = 1.0;
        S2D_DrawText(beg_text);
        S2D_FreeText(beg_text);
    }

    int main(void)
    {
        char *title = "The title";
        const S2D_Color color = {0.9, 0.9, 0.9, 1.0};

        S2D_Window *window = S2D_CreateWindow(title, X_MAX, Y_MAX, NULL, render, 0);
        window->background = color;
        window->frames = 1;

        S2D_Show(window);
        S2D_FreeWindow(window);
    
        return 0;
    }

r/GraphicsProgramming • • Nov 11 '24

Question Architecture question-What HW stage would be the most efficient for per vertex position alteration? | Possibly geomorphing related.

0 Upvotes

So I've had this idea regarding a heatmap that records the size of triangles in a meshes single vertex channel.
I've been looking into the VRAM cost of LODs(higher density) but not a fan of recent cluster implementations(might look into a very conservative streaming plan). So in order to take advantage of faster hardware quad rendering, I want to stop the view samples from sampling small triangles.

Basically the distance of the camera multiplies a sinking effect on small triangles(vertices under a threshold) and closure intensity of neighboring vertices(larger triangles end up occluding the smaller tris).

Up to 12m tris could be processed but I'm aware that some stages in the HW pipeline such as GS are slow and whatever HW stage unreal's WPO uses also had large documented overhead(haven't done serious performance measures).

Target hardware would be 20 series+, rnda2+, and arc gpus(in terms of HW support which are all pretty synced outside of MSAA support I've heard).

A point in the right direction would be helpful and just asking all GPs spaces I can reference 👍

Thanks.


r/GraphicsProgramming • • Nov 02 '23

Question deCasteljau Algorithm

0 Upvotes

Can anyone explain the algorithm? Instructor told about it in the lecture but his teaching is terrible so I still have no clue. Besides explanation do you have any visual material for this?


r/GraphicsProgramming • • Oct 26 '23

University or college

0 Upvotes

I'm from india interested in graphics programming. But i gone computer science but it doesn't work for me. Is there any college of university for graphics programming ??


r/GraphicsProgramming • • Sep 28 '21

Minimal NVIDIA example within GPU memory?

0 Upvotes

To get started, I just want to output something to a port on my NVIDIA Quadro P2000. I do not want to extend my display, just directly feed a monitor with what is generated.


r/GraphicsProgramming • • Mar 26 '21

Rotating a quad

0 Upvotes

Really noob question, but I'm really bad at math so can somebody explain how can I rotate a quad around its x, y or z axis?


r/GraphicsProgramming • • May 01 '24

Question How to have ray tracing as an optional button

0 Upvotes

I recently started to learn ray tracing, and from my understanding, the entire pipeline for ray tracing is very different And if i have to use ray tracing in an interactive scene, I need to generate a texture and then display the texture using openGL 2 triangles.

However, the rasterizer pipeline is entirely using many shaders. So do games just write 2 complete pipelines and switch between them based on if ray tracing is enabled?


r/GraphicsProgramming • • Apr 30 '24

Question glUseProgram isn't working outside of the constructor.

0 Upvotes

I'm doing my assignment for uni which a simple 3D opengl game. The problem is when I want to use shader the glUseProgram doesn't do anything. But when I call the glUseProgram in the Shader's constructor it works.

basicly DrawableGameObject's draw() function calls Material's use() function then sets the shader's uniforms and drawelements, Material's use() calls Shader's use() where you can find glUseProgram.