luma displacement map with 2 images
I'm looking for a shader like td.lumadisplace.jxs with the function of taking the luma map of the first image to displace the second image.
Does anyone have heard about something like that?
Thanks
Hi,
perhaps you could use td.repos.jxs to achieve similar effect, or you
could try modifying lumadisplace shader to use two texture inputs.
-nesa
Thanks. The problem is that I don't understand what does the td.repos.jxs do exactly. The only doc I've found was inside the code: "distortion based on position map in second inlet"
Do you know what this shader does and how to use it?
Unfortunately, I'm not very good to program GLSL so it will be quite long for me to change the code of the lumadisplace for 2 textures...
Tank!
Ok, I've found how to use the repos.jxs shader. That's almost what I was looking for isn't?
Yes that's exactly what you want to use:)
If you look at the td.repos.jxs in text editor, you'll see this line:
vec4 look = texture2DRect(tex1,texcoord1);//sample repos texture
which assigns color&alpha value from second texture going into
jit.gl.slab into a variable named 'look'.
texcoord1 is variable containing the coordinates of the pixel you want
to read.
the value of 'look' is later used to modify texture coordinates of the
first texture:
vec2 abso = look.ra*texdim0*amt;//absolute coordinates
which means 'repos coordinate is value of 'look' multiplied by the
size of first texture(texdim0) and then multiplied by the amount
parameter.
look.ra means that shader uses only red&alpha channels.
this is where one of the differences between lumadisplace and repos
takes place - repos uses red channel to modify X coordinate and alpha
channel for Y coordinate - just like jit.repos.
near the end of the file you'll see:
vec4 repos = texture2DRect(tex0, coord);
this is where the first texture(first inlet of jit.gl.slab) is being
sampled for the final output, using the coordinates modified by the
second texture.
So, this is a ruff overview of what's going on in td.repos.jxs. If you
want to modify it to use the luma value to offset both x&y
coordinates, you would need to first calculate the luminance of the
pixel, and then use it to offset both coordinates by the same amount.
Now you could take a look into saturation shader(cc.saturate.ip.jxs),
and see how luminance is calculated:
vec3 intensity = vec3 (dot(texColor, LumCoeff));
here they calculate the dot product between color and
'grayish'(LumCoeff) values. Lumcoeef is defined earlier in the shader
as a constant value:
const vec3 LumCoeff = vec3 (0.2125, 0.7154, 0.0721);
So you could use these two lines to create a modified version of
td.repos.jxs - first you should duplicate the file and rename it to
td.lumarepos.jxs.
Then you can open td.lumarepos.jxs, and start hacking by pasting the
lines for calculating luminance.
But you should take care not to brake the structure of jitter shader,
so first you could paste 'const' line after the 'uniform' declarations
and before void main() function.
Next step is to add the dot product calculation to your new shader.
In repos shader, 'look' variable contains color information of the
second texture:
vec4 look = texture2DRect(tex1,texcoord1);//sample repos texture
And this is what you can use to calculate the luminance(instead of
texColor used in saturation shader), by adding this line right after
reading the texture:
vec4 look = texture2DRect(tex1,texcoord1);//sample repos texture
look = vec4 (dot(look, LumCoeff));
and now you have a lumadisplace&repos crossbred mutant shader!
But if you're not interested in learning glsl, then you can just
insert 'cc.saturate.ip.jxs' slab with '@param alpha 0.' between your
displacement texture and right inlet of slab contating td.repos.jxs
to achieve the same result:)
hope this helps,
nesa
On Jan 25, 2009, at 8:18 PM, Julien-Robert wrote:
>
> Ok, I've found how to use the repos.jxs shader. That's almost what I
> was looking for isn't?
> --
> Julien-Robert
> jitter@cycling74.com`
Thanks a lot for all these explanations!