colors


openGLES 2 - How do I load a texture with 8-bit grayscale and 8-bit alpha, without expanding to 32-bit RGBA?


We're trying to optimize memory usage in our program, and we've noticed that some of our textures could be stored as greyscale with an alpha value as when stored as RGBA the RGB values are all the same.
We'd like to save disk space as well as memory by only needing to store 2 channels: greyscale and alpha, both 8-bit. Thus providing a 50% saving on both disk and memory over 32-bit RGBA.
However the hurdle we've hit is that we can't work out how to give this info to openGL. We can store the image on disk either as one image with two 8-bit channels, or as two images with one 8-bit channel each. I can't find a way for openGL to see this as a greyscale image so that it only has these two channels in memory without looking at them as being specific colours like Red and Green - as I have found GL_RG8 exists which has the right number of channels at the right bitdepth, but wrong colours.
Is this even possible in openGLES 2? Can we give 2 channels to openGL and tell it that they're not Red and Green but Grey and Alpha?
I have seen this question: Can I use a grayscale image with the OpenGL glTexImage2D function? but that's rather old and GL_LUMINANCE is now depricated.
Note that GL_RG8 only exists on OpenGL ES 3.x upwards; it's not part of OpenGL ES 2.x. For ES 2.x you can use GL_LUMINANCE_ALPHA. It's deprecated, but not removed, so should still work just fine.
If you really want to use GL_RG8 then you can fix "wrong color" either by using swizzles in the shader code to reorder the channels when you use them, or you can swizzle in the sampler by setting TEXTURE_SWIZZLE_[R|G|B|A] using glTexParameteri().

Related Links

Visual studio 2013 not highlighting typescript file
SAPUI5 Busy Indicator - Change standard color?
ColorFunction with InterpolationFunction in RegionPlot3D
how to create a coloring system with drag and drop
Syntax highlighting in zsh using 256 colors?
How can I render the same texture with different colors?
Jython: How do you setColor() to hexadecimal Color?
Tween.js and THREE.js, how do I make a color tween work?
Generate color palette from image with ImageMagick
Creating spreadsheet with OOXML & RGB color shows as hex 4 value instead of 3
JFreeChart gridline? paint set [closed]
How to change color of words in Gedit?
Modifying displayed pixels
Getting average color hue from specific spot via webcam
ios - set / unset button background color
How to fill in area with certain color

Categories

HOME
user-interface
verification
freeradius
qc
redmine
writefile
informatica
fogbugz
mosquitto
repair
google-search-console
wagtail
angular2-template
gtk
stack-overflow
log4j2
amazon-emr
fbloginview
phpstorm-2017.1
outlook-restapi
exe
jqxgrid
salt-cloud
weex
backtracking
pymongo
chronicle-queue
plyr
crud
clipboard
annotation-processing
ninject
bitbake
openbr
jsonresult
phpstorm-2016.1
premake
microsoft-certifications
quickcheck
bootstrap-sass
restful-architecture
cups
eclipse-gmf
variable-variables
assert
plane
cloudera-sentry
minikube
autorelease
supertest
nonlinear-functions
renderman
network-protocols
.when
boost-compute
yui3
svnserve
coovachilli
mathnet
jeditable
distributed-cache
gravatar
univocity
vim-plugin
wif4.5
wikimedia-commons
cryptojs
astropy
asp.net-web-api-helppages
componentart
python-c-extension
phonegap-facebook-plugin
comctl32
configurable-product
storing-data
box2dweb
git-reset
zend-search-lucene
miglayout
windows-taskbar
django-sites
infinite
acitree
tnt4j
google-code-prettify
statechart
getopt-long
system-information
monocross
exponent
radscheduler
nsrangeexception
azure-acs
airprint
nsconnection
anonymous-types
mongrel
odac
.net-client-profile
ntruencrypt
version-control-migration
code-camp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App