Chromatic Aberration Shader


    Sep 20 2007 | 10:26 am
    Hi all,
    I've finally started looking into glsl, and intrigued by the
    chromatic aberration shader I tried implementing it from the orange
    book...
    but, here goes, of course it doesn't work ;)
    It's probably something stupid, or maybe it's completely and utterly
    wrong...
    I get 'undeclared identifier' errors in the max window.
    Chromatic Aberration
    Brecht Debackere
    www.autofasurer.net
    M+32(0)498319302
    F+32(0)70429559
    Skype : Bdebackere
    brecht@visualantics.net

    • Sep 20 2007 | 4:42 pm
      Hi.
      A few things
      I do not believe you are allowed to set parameter defaults to formulas :
      >
      Do this math in the shader, or outside of it.
      Also, typically jitter binds the textures within the shader to
      texture units via
      (for zeroth texture unit)
      and lastly but most importantly, you are not, as far as I can see,
      specifying gl_FragColor, which is reqired in a fragment program to
      tell the GPU what your output color is. In fact, it seems as though
      you do not have a fragment program at all.
      On Sep 20, 2007, at 6:26 AM, Brecht Debackere wrote:
      > Hi all,
      >
      > I've finally started looking into glsl, and intrigued by the
      > chromatic aberration shader I tried implementing it from the orange
      > book...
      > but, here goes, of course it doesn't work ;)
      > It's probably something stupid, or maybe it's completely and
      > utterly wrong...
      > I get 'undeclared identifier' errors in the max window.
      >
      >
      >
      >
      > Chromatic Aberration
      >
      > > > > >
      >
      >
      >
      >
      >
      >
      > >
      >
      > >
      >
      >
      >
      >
      >
      > Brecht Debackere
      > www.autofasurer.net
      > M+32(0)498319302
      > F+32(0)70429559
      > Skype : Bdebackere
      > brecht@visualantics.net
      >
      >
      >
      v a d e //
      www.vade.info
      abstrakt.vade.info
    • Sep 20 2007 | 9:04 pm
      right. back to the drawing board :)
      thanks for the explanation...
      ...You live and learn. At any rate, you live.
      On 20 Sep 2007, at 18:42, vade wrote:
      > Hi.
      >
      > A few things
      >
      > I do not believe you are allowed to set parameter defaults to
      > formulas :
      >>
      >
      > Do this math in the shader, or outside of it.
      >
      > Also, typically jitter binds the textures within the shader to
      > texture units via
      >
      > >
      > (for zeroth texture unit)
      >
      > and lastly but most importantly, you are not, as far as I can see,
      > specifying gl_FragColor, which is reqired in a fragment program to
      > tell the GPU what your output color is. In fact, it seems as though
      > you do not have a fragment program at all.
      >
      >
      > On Sep 20, 2007, at 6:26 AM, Brecht Debackere wrote:
      >
      >> Hi all,
      >>
      >> I've finally started looking into glsl, and intrigued by the
      >> chromatic aberration shader I tried implementing it from the
      >> orange book...
      >> but, here goes, of course it doesn't work ;)
      >> It's probably something stupid, or maybe it's completely and
      >> utterly wrong...
      >> I get 'undeclared identifier' errors in the max window.
      >>
      >>
      >>
      >>
      >> Chromatic Aberration
      >>
      >> >> >> >> >>
      >>
      >>
      >>
      >>
      >>
      >>
      >> >>
      >>
      >> >>
      >>
      >>
      >>
      >>
      >>
      >> Brecht Debackere
      >> www.autofasurer.net
      >> M+32(0)498319302
      >> F+32(0)70429559
      >> Skype : Bdebackere
      >> brecht@visualantics.net
      >>
      >>
      >>
      >
      > v a d e //
      >
      > www.vade.info
      > abstrakt.vade.info
      >
      >
      >
      Brecht Debackere
      www.autofasurer.net
      M+32(0)498319302
      F+32(0)70429559
      Skype : Bdebackere
      brecht@visualantics.net
    • Jun 09 2008 | 10:51 am
      Apologies for digging up this old thread. I've finally continued my
      dabbling with glsl, still the same one from the orange book.
      I've started anew and so far came up with nothing much except for
      trying to fit the code into the .jxs format. In the end I'm trying to
      find figure out how the examples in the orange book translate to jitter.
      Surprisingly, it's not working ;) Any shader guru's willing to stare
      into this mess?
      chromatic aberration shader
    • Jun 11 2008 | 6:12 am
      I *believe* this is not working because Jitter 1.7, to my knowledge, does not support "uniform samplerCube Cubemap". I could be mistaken though.
    • Jun 11 2008 | 6:36 am
      On Tue, Jun 10, 2008 at 11:12 PM, vade wrote:
      >
      > I *believe* this is not working because Jitter 1.7, to my knowledge, does not support "uniform samplerCube Cubemap". I could be mistaken though.
      >
      Actually, one of the new things in Jitter 1.7 is cubemap support. See
      jit.gl.cubemap's help for more on this. As an example shader, here's
      a Fresnel shader that mixes reflection and refraction based on the
      angle of a ray hitting the object:
      Environment Mapping with a Cube Map
    • Jun 11 2008 | 6:42 am
      I'm not sure why you're multiplying the refractino vector by the
      gl_TextureMatrix. I think this might be your problem. See the shader
      I just posted as it does most of what you want. You'll just have to
      move some things from the fragment shader to the vertex shader.
      wes
    • Jun 11 2008 | 9:18 am
      Thanks guys. I'll scrutinize that shader.
      To elaborate on the gl_TextureMatrix : this code is literally from
      the orange book. That's what I'm trying to find out: how to get the
      examples in there to work.
      On 11 Jun 2008, at 08:42, Wesley Smith wrote:
      > I'm not sure why you're multiplying the refractino vector by the
      > gl_TextureMatrix. I think this might be your problem. See the shader
      > I just posted as it does most of what you want. You'll just have to
      > move some things from the fragment shader to the vertex shader.
      >
      > wes
    • Jun 11 2008 | 3:27 pm
      On Mon, Jun 9, 2008 at 12:51 PM, Brecht Debackere
      wrote:
      > Apologies for digging up this old thread. I've finally continued my
      > dabbling with glsl, still the same one from the orange book.
      > I've started anew and so far came up with nothing much except for trying to
      > fit the code into the .jxs format. In the end I'm trying to find figure out
      > how the examples in the orange book translate to jitter.
      >
      > Surprisingly, it's not working ;) Any shader guru's willing to stare into
      > this mess?
      >
      I also copied the chromatic Aberration shader from the Orange Book and can
      get a result in Jitter. However, when I copy the code from your post I get
      a compilation error when I try to use it. I seem to remember trying a
      shader that you posted previously (?) but had the same result. I looked at
      the code and couldn't find any difference between your version and mine but
      put it down to not looking hard enough.
      Whenever I copy code from a browser I get rid of hidden formatting (by
      selecting zap gremlins in text wrangler), sometimes this can interfere with
      the code when it gets compiled. Also, I've found that my graphics card
      doesn't support some shaders. You might want to check that yours supports
      the gl and shading code that you use.
      Anyway, here's a version of the same shader that I did to try and understand
      what was happening. I simply changed the varying variables to uniform ones
      that can be altered from Jitter. If you can get it to work it might help to
      demonstrate how to draw up the jxs files for Jitter.
      pelado
    • Jun 11 2008 | 3:35 pm
      great! I get no more errors at least with yours. I might 've made
      some typo's along the way since I copied it manually from the book.
      There are still some things I don't fully understand though, since it
      only seems to color my object black; the cubemap e.g. where should it
      come from?
      On 11 Jun 2008, at 17:27, pelado wrote:
      > On Mon, Jun 9, 2008 at 12:51 PM, Brecht Debackere
      > wrote:
      > Apologies for digging up this old thread. I've finally continued my
      > dabbling with glsl, still the same one from the orange book.
      > I've started anew and so far came up with nothing much except for
      > trying to fit the code into the .jxs format. In the end I'm trying
      > to find figure out how the examples in the orange book translate to
      > jitter.
      >
      > Surprisingly, it's not working ;) Any shader guru's willing to
      > stare into this mess?
      >
      > I also copied the chromatic Aberration shader from the Orange Book
      > and can get a result in Jitter. However, when I copy the code from
      > your post I get a compilation error when I try to use it. I seem
      > to remember trying a shader that you posted previously (?) but had
      > the same result. I looked at the code and couldn't find any
      > difference between your version and mine but put it down to not
      > looking hard enough.
      >
      > Whenever I copy code from a browser I get rid of hidden formatting
      > (by selecting zap gremlins in text wrangler), sometimes this can
      > interfere with the code when it gets compiled. Also, I've found
      > that my graphics card doesn't support some shaders. You might want
      > to check that yours supports the gl and shading code that you use.
      >
      > Anyway, here's a version of the same shader that I did to try and
      > understand what was happening. I simply changed the varying
      > variables to uniform ones that can be altered from Jitter. If you
      > can get it to work it might help to demonstrate how to draw up the
      > jxs files for Jitter.
      >
      > pelado
      >
      >
      > > > >
      >
      >
      >
      >
      >
      > >
      > > >
      > >
      >
      >
      >
    • Jun 11 2008 | 3:42 pm
      you need to place a jit.gl.cubemap object in your patch and import some
      textures to get a result. See the cubemap help file.
      pelado
      On Wed, Jun 11, 2008 at 5:35 PM, Brecht Debackere
      wrote:
      > great! I get no more errors at least with yours. I might 've made some
      > typo's along the way since I copied it manually from the book.
      > There are still some things I don't fully understand though, since it only
      > seems to color my object black; the cubemap e.g. where should it come from?
      >
      >
      >
      > On 11 Jun 2008, at 17:27, pelado wrote:
      >
      > On Mon, Jun 9, 2008 at 12:51 PM, Brecht Debackere
      > wrote:
      >
      >> Apologies for digging up this old thread. I've finally continued my
      >> dabbling with glsl, still the same one from the orange book.
      >> I've started anew and so far came up with nothing much except for trying
      >> to fit the code into the .jxs format. In the end I'm trying to find figure
      >> out how the examples in the orange book translate to jitter.
      >>
      >> Surprisingly, it's not working ;) Any shader guru's willing to stare into
      >> this mess?
      >>
      >
      > I also copied the chromatic Aberration shader from the Orange Book and can
      > get a result in Jitter. However, when I copy the code from your post I get
      > a compilation error when I try to use it. I seem to remember trying a
      > shader that you posted previously (?) but had the same result. I looked at
      > the code and couldn't find any difference between your version and mine but
      > put it down to not looking hard enough.
      > Whenever I copy code from a browser I get rid of hidden formatting (by
      > selecting zap gremlins in text wrangler), sometimes this can interfere with
      > the code when it gets compiled. Also, I've found that my graphics card
      > doesn't support some shaders. You might want to check that yours supports
      > the gl and shading code that you use.
      >
      > Anyway, here's a version of the same shader that I did to try and
      > understand what was happening. I simply changed the varying variables to
      > uniform ones that can be altered from Jitter. If you can get it to work it
      > might help to demonstrate how to draw up the jxs files for Jitter.
      >
      > pelado
      >
      >
      > > > >
      >
      >
      >
      >
      >
      > >
      > > >
      > >
      >
      >
      >
      >
      >
      >
      >
      >
      --
    • Jun 11 2008 | 3:50 pm
      wicked. Thanks a bunch
    • Jun 11 2008 | 6:43 pm
      The cubemap is a texture like any other Jitter texture. In this case
      though it's specifically jit.gl.cubemap which can be used just like
      jit.gl.texture but binds as a Cube Sampler instead.
      wes
      On Wed, Jun 11, 2008 at 8:35 AM, Brecht Debackere
      wrote:
      > great! I get no more errors at least with yours. I might 've made some
      > typo's along the way since I copied it manually from the book.
      > There are still some things I don't fully understand though, since it only
      > seems to color my object black; the cubemap e.g. where should it come from?
      >
      >
      >
      > On 11 Jun 2008, at 17:27, pelado wrote:
      >
      > On Mon, Jun 9, 2008 at 12:51 PM, Brecht Debackere
      > wrote:
      >>
      >> Apologies for digging up this old thread. I've finally continued my
      >> dabbling with glsl, still the same one from the orange book.
      >> I've started anew and so far came up with nothing much except for trying
      >> to fit the code into the .jxs format. In the end I'm trying to find figure
      >> out how the examples in the orange book translate to jitter.
      >>
      >> Surprisingly, it's not working ;) Any shader guru's willing to stare into
      >> this mess?
      >
      > I also copied the chromatic Aberration shader from the Orange Book and can
      > get a result in Jitter. However, when I copy the code from your post I get
      > a compilation error when I try to use it. I seem to remember trying a
      > shader that you posted previously (?) but had the same result. I looked at
      > the code and couldn't find any difference between your version and mine but
      > put it down to not looking hard enough.
      > Whenever I copy code from a browser I get rid of hidden formatting (by
      > selecting zap gremlins in text wrangler), sometimes this can interfere with
      > the code when it gets compiled. Also, I've found that my graphics card
      > doesn't support some shaders. You might want to check that yours supports
      > the gl and shading code that you use.
      > Anyway, here's a version of the same shader that I did to try and understand
      > what was happening. I simply changed the varying variables to uniform ones
      > that can be altered from Jitter. If you can get it to work it might help to
      > demonstrate how to draw up the jxs files for Jitter.
      > pelado
      >
      > > > >
      >
      >
      >
      > >
      > > >
      > >
      >
      >
      >
      >
      >
    • Jul 13 2008 | 11:37 pm
      I'm very interested in experimenting with Chromatic Aberration effects, but I dont know much about writing/implementing shaders yet.. -
      - is there any chance you could post an example patch with this CA Shader working?
      thanks!
    • Jan 19 2009 | 5:15 pm
      I started trying to convert the shader myself, but I know that I haven't gotten it quite right yet, I read in this thread that theres something with the cube mapping that has to be done in jitter but I dont fully understand how to do that. Im posting the version of the shader that I have partially converted, though I know its not quite right yet. Is it possible for someone to post a proper working version and show me what it is I am doing wrong.
    • Jan 20 2009 | 9:07 pm
      robtherich posted a great fixed version of my poor attempt on here:
      Thanks all!
      Man what a great shader! I thirst for more!!
      NCRIII