Absolute Linear Texture > GLSL Shader

toneburst's picture

This is a hair-tearer.... I need to to get a texture into a GLSL shader in Absolute Linear format (ie disable all color-correction). Can anyone suggest a method for doing this? I've tried using the Color Matching patch, to disable Color-Matching, and using a passthrough OpenCL Kernel patch to set the image format to Absolute Linear. Neither method seems to work.

Anyone any tips?

a|x

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

Oh, and the texture in question is the result of compositing (using a Source Over patch) the output of an OpenCL Kernel (set to Absolute Linear output image format), and the iSight input, though the latter could be any arbitrary video image.

vade's picture
Re: Absolute Linear Texture > GLSL Shader

I would try to Render In Image your iSight image, sans color correction for RII, and then try tagging the output of your Source Over with the Image Color Matching Properties to none, Core Image ought to match the linear from RII with the OpenCL linear and not correct it to anything?

Just a guess.

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

Thanks vade, I'll give that a go.

a|x

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

Nope, that doesn't work. There must be some non-bypassable colorspace conversion going on in the process of converting a QC Image to an OpenGL texture. The funny thing is, I've not had the same problem with a similar Core Image Kernel patch. The problem there is I'm attempting to use a lookup table that's larger than the output image, so that whole ROI/DOD nightmare kicks in, and my brain tries to crawl out of one of my ears.

a|x

vade's picture
Re: Absolute Linear Texture > GLSL Shader

Are you marking your LUT as __table so it does not undergo transforms in the destination coordinate space?

QC image is an opaque type that wraps various image formats, (like raw textures, CVImageBuffers (CVPixelBufferRefs and CVOpenGLTexureRefs), CGImages, etc). Most of those types have colorspaces associated with them, except for textures, which are always interpreted linearly, unless the texture is an SRGB texture, which I dont think QC supports.

Try adding an additional Image Texturing property into the RII for the image you are rendering into. I know, this Colorspace conversion shit is really annoying. Maybe I ought to make a utility plugin that re-marks images with different colorspaces, to spoof? That could cause all kinds of hurt though. Hrm.

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

Re. CIKernel: I tried using __table, but it doesn't make any difference. I have to crop the output image or it comes out the size of the LUT, with the other image at bottom-left. The problem is, I can't access any of the LUT image that's outside the area of the other image if I crop the output to the size of the reference input image. It's very frustrating- I've never been able to get my head around CoreImage's ROI/DoD setup, and nobody has ever been able to explain it in a way that makes any sense to me.... moan, whinge etc...

Back to GLSL: The colorspace stuff generally just works... but in my particular scenario, I need to have exact values in my GLSL Shader. I'm trying to convert ASCII characters to pixel colors, then use that color in the shader to lookup into a table of characters. It's a ridiculously overcomplicated setup, but the idea is to be able to overlay arbitrary text ontop of a realtime ASCII-art effect. It relies on being able to encode the characters of the message into colors, then decode them into coordinates to lookup into the glyph texture in the shader.

a|x

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

It's weird... I've tried passing the input image through a RII with color-correction turned off, then through a Color Matching patch, with matching disabled. It definitely has an effect on the input image, but it doesn't seem to have any effect on the overlaid blocks of color from the OpenCL kernel. I'm thinking this isn't a color-management issue, but something that happens when the image is converted into a texture. In some cases, it's nearly right, just not quite there.. which of course, means that the text that gets rendered is complete nonsense....

a|x

usefuldesign.au's picture
Re: Absolute Linear Texture > GLSL Shader

Note to Kineme: Quote link still not providing a quoted text in comment box. Safari 5.0.3

tb wrote:
The problem there is I'm attempting to use a lookup table that's larger than the output image, so that whole ROI/DOD nightmare kicks in, and my brain tries to crawl out of one of my ears.

That ROI/DOD is a tricking business I never got to bottom of. If anybody has successfully understood it (and can practice the art!) Demo Comps are more than welcome.

One thing I've often tried to do when lining up two images for blending or CI Filter is to add pixels to the smaller image using the crop patch and extending the crop region beyond the image dimensions, it's never worked. I guess pre-blending with a larger blank image is the only way but it's hard to control the layout.

Crop doesn't seem to be a tool for relocating an images 'anchor' co-ords to shift alignment relative to the origin (0,0) (because no such things as anchors exist I guess!). Tooltips suggest images can carry offset dimensions like (-100,-100,200,200) would be a square 200px wide centred on origin. The whole area is always a frustration to my QC ease of use and a barrier to what I can achieve sanely.

gtoledo3's picture
Re: Absolute Linear Texture > GLSL Shader

The cl kernel has a setting that allows you to pick aspects of input and output color. Did you try that out? You'll have to run the kernel once before the ports appear.

Edit- I see that you did set output type. Did you try any of the other settings? I remember having something like what you're describing start working after using a counterintuitive setting.

You're setting output type but have you experimented with input type on the cl kernel?

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

Funnily enough, disabling color-correction works fine going into a CIFilter kernel. I was having other issues with that. I did try using a 'passthrough' OpenCL kernel to force disabling of color-correction, and various other combinations of patches and RIIs. I eventually gave up trying to get accurate colors into a GLSL shader, and went with adding the message ontop as a grid of Sprites, and using the Image Texturing Properties patch inside a Iterator, to lookup into the glyph table.

a|x

toneburst's picture
Re: Absolute Linear Texture > GLSL Shader

I very much share your frustration. I think some of the most confusing things about QC are related to dimensions and coordinates. I've never really fully got my head around how dimensions work in Render In Image or Image With String patches, either. QC seems to add a whole level of extra confusion on top of the already confusing series of coordinate-space transformations that happen in the OpenGL pipeline.

a|x