[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] Linear-to-sRGB conversion to the drawing buffer using sRGB extension
- To: public_webgl@khronos.org
- Subject: [Public WebGL] Linear-to-sRGB conversion to the drawing buffer using sRGB extension
- From: Oskar Skrinjar <oskar@scientificiv.com>
- Date: Sat, 15 Jul 2017 11:14:06 -0400
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=scientificiv.com; s=default; h=Content-Transfer-Encoding:MIME-Version: Content-Type:In-Reply-To:References:Subject:To:From:Message-ID:Date:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xOWMK64fi7XtX6hgFBvlewAJu1DKfP5uid5ntSmKJRU=; b=Anr/gTP2/6iAYHMwfMOIJG5yWS ClBqsDIAHvxH50LnRC3EU+OCd17Qay1MJeL5B/tUkXxU0Ol5bS96OzQT6/DA1aRcVVu8P3OZkqMT2 o4owWK5D96GXX1HsOkharUhY5YqGqfDDdDckLs7O/3WmffiWJ6KGKWEGLdWxCynU69Yw=;
- In-reply-to: <20170626203753.Horde.zWT9A0XVTkE13E-bV3-3OJi@vps15070.inmotionhosting.com>
- List-archive: <https://www.khronos.org/webgl/public-mailing-list/archives/>
- List-id: Public WebGL Mailing List <public_webgl.khronos.org>
- List-owner: <mailto:owners-public_webgl@khronos.org>
- List-post: <mailto:public_webgl@khronos.org>
- List-subscribe: <mailto:majordomo@khronos.org?body=subscribe%20public_webgl>
- List-unsubscribe: <mailto:majordomo@khronos.org?body=unsubscribe%20public_webgl>
- References: <CAOK8ODhYLf_QfjCLa=FVfYAyxDFk3QXFHLRRew9VFoX8q9Xd8A@mail.gmail.com> <CAGdfWNOUe7J+KbP6Y-jfrcovx8n301N6sO1HFnCHpat4P+oXFg@mail.gmail.com> <CAMYvS2fhAdhtWzn_9hFRyeKqkQuDjKraX9oBR9t6WfhPs2ukSg@mail.gmail.com> <CAOK8ODjyjkWgXHXQeRwM8jBR+RTH8tuDk78bAOj39npTL7oKwQ@mail.gmail.com> <CAMYvS2dgZ4_HT3a_P5ntW3rAdz4bNS43LTAQKsgfaWHaE_2izA@mail.gmail.com> <20170626203753.Horde.zWT9A0XVTkE13E-bV3-3OJi@vps15070.inmotionhosting.com>
- Sender: owners-public_webgl@khronos.org
- User-agent: Horde Application Framework 5
Hello,
I have a question to those who know how to use sRGB extension with WebGL 1.
When I use an image as a texture, if I specify the texture to be sRGB,
it seems that it works properly, since the pixel color values get
smaller in the fragment shader and if I directly display that texture
using a full screen quad, I get a darker version of the image, which
should be the case. Thus, the fragment shader gets the colors in the
linear space and then I can do processing in the linear space.
I have problems going back from linear values to sRGB values at the
end of the processing pipeline, i.e. when I want to render the final
result to the drawing buffer. If I directly render the linear color
values into the drawing buffer the displayed image looks darker, as
expected. Since it is not possible to specify that the drawing buffer
does linear-to-sRGB conversion, I tried to use an FBO for that purpose.
If I create an FBO with an sRGB texture as COLOR ATTACHMENT 0, then
rendering linear colors into that FBO seems to work properly. E.g.
when I write inside the fragment shader a gray value of 54 (R=54,
G=54,B=54) into the FBO and then use pixelRead to check the stored
value, the stored value in the FBO is (127,127,127), which should be
the case. Thus, that FBO stores colors in the sRGB space, as expected.
What I do not know how to do is displaying the content of that FBO to
the screen. If I do a “transfer pass”, i.e. use the FBO’s color
attachment texture as an input, and read it from a fragment shader and
then write the color values into the drawing buffer I end up with
linear values. This is because that color attachment texture is sRGB
and reading it from a fragment shader converts the values from the
sRGB to linear space and the resulting image is darker. Of course, I
could do linear-to-sRGB conversion inside the fragment shader, but
that is what the sRGB extension should somehow do.
Could someone refer me to examples or explain how to convert linear
color values into sRGB color values that end up in the drawing buffer
using the sRGB extension. Any help will be appreciated.
Thanks,
Oskar
Oskar Skrinjar, PhD
Scientific Imaging and Visualization, LLC
Website: http://www.scientificiv.com
Email: oskar@scientificiv.com
Phone: 404 863 2371
-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl
-----------------------------------------------------------