GithubHelp home page GithubHelp logo

Comments (3)

ec- avatar ec- commented on August 17, 2024

It heavily depends on a renderer: in OpenGL you need to set color mask before each drawcall, in Vulkan - use dedicated greyscale pipeline (-> 2x pipelines in general), as for me - not worth an effort over added renderer(s) complications

from quake3e.

WHS-Phoenix avatar WHS-Phoenix commented on August 17, 2024

I'm using OpenGL. I haven't messed with the Vulkan renderer yet.

The answer you provided doesn't really explain anything to me that I can understand. Again, I know next to nothing about how OpenGL works, and I find it difficult to grasp. I did try to add the qglColorMask statement before and after the draw functions without any good effect. If set to GL_FALSE it just locks the current frame and won't ever release it. If set to GL_TRUE it does nothing different.

Here is the current greyscale function as I have it written. Perhaps you could take a look and see what's wrong? I have tried running this after R_RenderView as well as calling it from a rendercommand_t. The same thing happens either way. It works without the multitexture buffers, but repeatedly draws if they are enabled.

void FBO_GreyScaleScreen(int x, int y, int width, int height)
{
image_t *image;

// Phoenix - this works, just need to get it to not draw multiple times.
// r_ext_multisample 0 stops it but not sure how to get around it with multisample enabled.

// Must sync render thread so that the GL commands will work.
R_IssuePendingRenderCommands();
qglFinish();

// Use a scratch image from the array to write our framebuffer into

if (!tr.scratchImage[15]) {
	tr.scratchImage[15] = R_CreateImage(va("*scratch%i", 15), NULL, NULL, width, height, IMGFLAG_CLAMPTOEDGE | IMGFLAG_RGB | IMGFLAG_NOSCALE);
}

image = tr.scratchImage[15];
GL_Bind(image);

FBO_Bind(GL_READ_FRAMEBUFFER, frameBuffers[0].fbo);


// Copy down the framebuffer onto the scratch image, converting to greyscale by using
// GL_LUMINANCE as the channel instead of GL_RGBA
// Make sure the color is not set funky
qglColor3f(1, 1, 1);
qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, x, y, width, height, 0);


// Set up for 2D rendering

RB_SetGL2D();

// Draw the actual screen overlay.  This will cover the full render window
// regardless of FOV or screen width.
qglBegin(GL_QUADS);
qglTexCoord2f(0, 1);
qglVertex2f(x, y);
qglTexCoord2f(1, 1);
qglVertex2f(x + width, y);
qglTexCoord2f(1, 0);
qglVertex2f(x + width, y + height);
qglTexCoord2f(0, 0);
qglVertex2f(x, y + height);
qglEnd();

}

from quake3e.

ec- avatar ec- commented on August 17, 2024

I was not correct about OpenGL:

  1. create separate dedicated post-processing ARB/GLSL shader
  2. do render to the separate render target, save as texture for p.3
  3. apply post-processing fullscreen quad in correct place (right before UI 2d rendering starts)

This all is OpenGL-specific + slow and not predictable since there is no reliable way to detect transition to UI rendering because some mods may have full 3D UI - thus, not worth an effort

from quake3e.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.