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

Color code only one column in tableau
alloy appcelerator textfeild font color not visible in android version 5
GNU parallel - keep output colored
Getting the dominant color in processing
Spectrum color picker HSV to RGB
Why! 100% Cyan in CMYK is NOT rgb(0,255,255)? in Photoshop
webgl discard fragment, but also check discarded colors?
How to change JVectorMap Country Colors v1.2.0
RGB LED strip - blue color not working right (with IR receiver/remote)
Managing the palette indicators in gnuplot
Converting Color Profile from Adobe RGB for Reading in Skimage on Linux
Appropriate Syntax For Alternating Row Colors
Changing the unselected color of a UITabBar Item iOS 9
ffmpeg how to put color overlay over video
Detect a colour based on its RGB
Lossless grayscale JPEG “color” inversion?

Categories

HOME
cocoapods
elasticsearch
webview
extjs
powerbi
seedstack
key
compilation
out-of-memory
ios-simulator
biztalk
portable-class-library
nsis
mathematical-optimization
gallery
qooxdoo
navigation
haxe
static-analysis
heuristics
powermock
closures
vertica
infrared
parceler
spring-shell
android-custom-view
jitsi
data-type-conversion
akka-persistence
websphere-portal
restier
onchange
sendmessage
docx4j
delayed-job
gsp
cloveretl
cmis
creation
pdfnet
cheat-engine
stat
oauth2-playground
coverage.py
web-inspector
morphline
music21
autorelease
aws-kinesis-firehose
knockout-2.0
password-hash
karabiner
simple-schema
watir-webdriver
exc-bad-access
bpms
bigdecimal
msg
logical
livereload
jpda
ftp-client
unsigned
ajaxmin
exists
mathnet
swiffy
mercurial-extension
ioexception
teensy
bjam
gluon-desktop
supersocket.net
sequence-sql
explain
artisan
kefir.js
phpredis
actionpack
scala-macros
android-audiomanager
famo.us
cout
jquery-mobile-flipswitch
box2dweb
neo4jphp
fileshare
armv6
colon
boinc
san
non-ascii-characters
hints
flv
thejit
uipasteboard
photo-management
aptitude
ios-4.2
mongrel
j2mepolish
resharper-5.0
browser-based
rational-unified-process
wmd-editor
database-cloning
word-automation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App