I've been looking into gamma correction, and what I should do to do proper gamma-aware rendering, but browsing the web has left me somewhat confused.
My basic understanding is as follows. Basic notions: 1. (most) texture images are gamma pre-corrected (not linear, either sRGB or something similar). 2. Shading computation should be done in a linear color space. To do gamma-aware rendering in theory, I have to: A. transform my texture images from nonlinear to linear color space B. do my lighting/shading computations in linear color space C. transform the results from linear back to nonlinear color space Now I understand that OpenGL helps me with step A with the sRGB internal texture format, and that step B is my own concerns. My main confusion comes with step C. If I would render to an FBO, I can specify the sRGB format for the FBO as well, and OpenGL takes care of step C. However, I cannot really find anything similar for rendering directly to screen. It would appear that in that case I would have to do step C myself - explicitly - in my shaders. I cannot get OpenGL to do that for me automatically. Is this a correct assumption, or am I missing something? Thanks, Gerco. |
Hi Gerco,
I am also interested have you solved? |
I think it should be definitely determined at the creation of the opengl context.
As it is written here, For the default framebuffer, color encoding is determined by the implementation. For example for GLWF3, there is the GLFW_SRGB_CAPABLE property So does jogl offers the SRGB option? |
Administrator
|
On 12/19/2014 10:03 AM, elect [via jogamp] wrote:
> I think it should be definitely determined at the creation of the opengl context. > > As it is written here > <https://www.opengl.org/sdk/docs/man3/xhtml/glGetFramebufferAttachmentParameter.xml>, > > > / For the default framebuffer, color encoding is determined by the > implementation. > / > > For example for GLWF3, there is the GLFW_SRGB_CAPABLE property hence your assumption would need some reason, e.g. a EGL, GLX, WGL .. reference. As I understand, you assume either: [1] SRGB selection as a context property This does not exist in the GL spec. [2] SRGB selection as a pixelformat property We have to look, but I doubt. One may select SRGB texture formats, GL spec. I am unaware of a generic overall SRGB mode, but if you have information about it (GL, EGL, ..) that would be great. ~Sven signature.asc (828 bytes) Download Attachment |
At least for WGL (https://www.opengl.org/wiki/Creating_an_OpenGL_Context_%28WGL%29#Pixel_Format_Extensions) it may be possible to choose sRGB-pixel format for the default framebuffer. (I have only done desktop GL so I don't know about GLES-spec). |
In reply to this post by Sven Gothel
Unfortunately documentation over internet regarding sRGB for the default framebuffer lacks. What I linked is the only source mentioning something about it and therefore this is the only thing my assumption is based on. I had the hint of the context reading this guy http://stackoverflow.com/questions/25842211/opengl-srgb-framebuffer-oddity In the GL pipeline one should work in linear RGB (lRGB). OpenGL offers all the tools to make it without any additional modification for the devs and, more important, free performance-wise. This means sRGB textures as input will be translated automatically to lRGB and output textures to sRGB, default framebuffer included, if properly configured. Scanning Jogl, I found some interesting variables about the same thema EGL.java public static final int EGL_VG_COLORSPACE_sRGB = 0x3089; public static final int EGL_VG_COLORSPACE_LINEAR = 0x308A; WGLExt.java public static final int WGL_ARB_framebuffer_sRGB = 1; public static final int WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20A9; public static final int WGL_EXT_framebuffer_sRGB = 1; public static final int WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20A9; GLX.java public static final int GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20B2; public static final int GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20B2; I hope that helps |
Administrator
|
In reply to this post by elect
On 12/19/2014 03:12 PM, elect [via jogamp] wrote:
> Sven Gothel wrote > This is not a canonical reference, > hence your assumption would need some reason, > e.g. a EGL, GLX, WGL .. reference. > > As I understand, you assume either: > [1] SRGB selection as a context property > This does not exist in the GL spec. > > [2] SRGB selection as a pixelformat property > We have to look, but I doubt. > > One may select SRGB texture formats, GL spec. > > I am unaware of a generic overall SRGB mode, > but if you have information about it (GL, EGL, ..) > that would be great. > > ~Sven > > signature.asc (828 bytes) > <http://forum.jogamp.org/attachment/4033786/0/signature.asc> > <http://forum.jogamp.org/attachment/4033786/0/signature.asc%3E> > > Unfortunately documentation over internet regarding sRGB for the default > framebuffer lacks. What I linked is the only source mentioning something about > it and therefore this is the only thing my assumption is based on. I had the > hint of the context reading this guy > > http://stackoverflow.com/questions/25842211/opengl-srgb-framebuffer-oddity > > In the GL pipeline one should work in linear RGB (lRGB). OpenGL offers all the > tools to make it without any additional modification for the devs and, more > important, free performance-wise. This means sRGB textures as input will be > translated automatically to lRGB and output textures to sRGB, default > framebuffer included, if properly configured. Maybe this has to be defined in it's parent Capabilities, allowing to select the default framebuffer / pixelformat (-> onscreen). This 'Capabilities.colorspace' entry shall be utilized for [1] onscreen drawables and [2] offscreen FBO drawables, if available. <https://en.wikipedia.org/wiki/SRGB> Capabilities.colorspace might be of an integer or enum type w/ (currently known) values: lRGB (default, linear) and sRGB (standardized RGB). We may refactor TextureData.Colorspace and extend it's type accordingly. Onscreen drawables will require assistance of EGL, GLX, EGL .., where FBO offscreen can be supported merely by 'some' GL extension(s). Implementation ================== <https://en.wikipedia.org/wiki/SRGB#Usage> refers to EXT/framebuffer_sRGB <https://www.opengl.org/registry/specs/EXT/framebuffer_sRGB.txt> which will allow implementing [2]! Note: While FBObject shall support sRGB naturally, one can already use above extension in their own code using textures and FBOs. It has to be seen, whether implementation of [1] is supported, i.e. possible. +++ Please copy/paste this information and text to a new bug report (enhancement) for our records. Volunteers ? Thank you! ~Sven > > Scanning Jogl, I found some interesting variables about the same thema > > EGL.java > public static final int EGL_VG_COLORSPACE_sRGB = 0x3089; > public static final int EGL_VG_COLORSPACE_LINEAR = 0x308A; > WGLExt.java > public static final int WGL_ARB_framebuffer_sRGB = 1; > public static final int WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20A9; > public static final int WGL_EXT_framebuffer_sRGB = 1; > public static final int WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20A9; > GLX.java > public static final int GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20B2; > public static final int GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20B2; > > I hope that helps > > ------------------------------------------------------------------------------ > If you reply to this email, your message will be added to the discussion below: > http://forum.jogamp.org/Proper-gamma-aware-rendering-tp4030515p4033788.html > To start a new topic under jogl, email [hidden email] > To unsubscribe from jogl, click here > < > NAML > <http://forum.jogamp.org/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- health & wealth mailto:[hidden email] ; http://jausoft.com land : +49 (471) 4707742 ; fax : +49 (471) 4707741 Timezone CET: PST+9, EST+6, UTC+1 signature.asc (828 bytes) Download Attachment |
For opening a new bug report? This is for sure something I can do :p |
In reply to this post by jmaasing
For inspiration, this is how some other framework specifies it at window creation, as hints about the default framebuffer format.
http://www.glfw.org/docs/latest/window.html#window_hints I think something similar in GLCapabilities would make sense. |
I just copy/paste.
https://jogamp.org/bugzilla/show_bug.cgi?id=1115 Let me know if it sounds good or not |
Free forum by Nabble | Edit this page |