Open knupel opened 5 years ago
Thanks for the tips but I set a previous PGraphics in order to change the source. You can get an interesting result if you set the previous texture as the current and not the datamosh buffer
Your flip.glsl
can be useful to handle PGraphics/PImage UV situation but i If/Else statements be have performance issue on older GPU. I will recommend to use mathematical condition (step, min, max... operations) or preprocessor condition to avoid it.
Here some informations about it :
thanks for the info-link el professor del glsl!
It's my syntax if-else
from Processing... i must improve that for glsl coding for the future !!!!
ahaha no problem ;)
There are differents solutions. For exemple you can set a flag using a step operator :
uniform int uvflag; //0 nothing, 1 invert)
float cond = step(0.1, uvflag);
uv.y = uv.y * cond +(1.0 - uv.y) * (1.0 - cond);
Usually a test if my texture is an PImage or a PGraphics in java using :
public boolean isPImage(PImage src) {
if(src instanceof PGraphics) {
return false;
}else {
return true;
}
}
thx for the code, because I try to understand, but i was little lost :) now with your code is perfect. BIG UP !!!!
Sure no problem. I know how mathematical condition can be tricky to conceive ;)
That's work like a charm !!!! But after test it's necessary to invert the uv.y
vec2 set_uv(int flip_vertical, int flip_horizontal, vec2 res) {
vec2 uv;
if(all(equal(vec2(0),res))) {
uv = vertTexCoord.st;
} else if(all(greaterThan(res,vertTexCoord.st))) {
uv = vertTexCoord.st;
} else {
uv = res;
}
// flip
float condition_y = step(0.1, flip_vertical);
uv.y = 1.0 -(uv.y *condition_y +(1.0 -uv.y) *(1.0 -condition_y));
float condition_x = step(0.1, flip_horizontal);
uv.x = uv.x *condition_x +(1.0 -uv.x) *(1.0 -condition_x);
return uv;
}
PS : what the tip to add color in your code post ?
Just a quick improvement to gain 1 or 2 fps ! It's not necessary to create a
PGraphics previous
. Pass directlydatamoshBuffer
and at the end filter the result to reverse totaly and back to normal situation.reverse uv.y on the
datamosh.glsl
flip.glsl