Le 06/10/2013 22:13, Py Fave a écrit :
> Hello , i just opened your last patch and am looking at it .
> weanwhile i reply to your points
>
> 2013/10/6 Jack <j...@rybn.org>:
>> Hello,
>>
>> Le 05/10/2013 22:51, Py Fave a écrit :
>>
>> in fact my problem is not solved .
>> it seems like the feedback effect  happens everywhere but on the
>> surface drawn by the shader .
>>
>> According to the patch, the feedback is applied on a [square 4] (where there
>> is also the [torus 2]).
>> Then, [gemframebuffer] 'snap' the whole 'inside' [square 4]. And your torus
>> is inside this snapshot (as texels and not vertices).
>>
> yes ,and then there is  some feedback on the texels of the square .
> but in my patch if i rotate the torus i get some feedback but not on the
> shaded part (only the silhouette of the torus .  i don't know why .
> i would like everything to go in the feedback loop .
>
> in fact i try to have trails that show "geodesics" on a surface
> later i plan to replace my torus with other models .
>
>
>
>> i use a torus , in perspective wich has a shader applied .
>>
>> i tried the following workaround(archive is joined ) , but still no luck .
>> the file to open has a OPEN in name .
>>
>> It seems there is no circle4.geom, [receive13] and [nshader0]
>> objects/abstractions in your .zip.
> sorry i forgot  .
>
> receive13 only is missing .
> it's part of ext13 library (and is in pd-extended iirc)
> http://puredata.info/downloads/ext13
>
> [receive13 nothing ]could  be replaced by receive nShader1
> or all the shader abstraction can be replaced by the classical shader network
> with fragment shader = circle4.frag  and vertex shader = circle4.vert.
> no .geom was used
>
>
>> i would like the dots to have the feedback ,
>> or dots + geometry alltogether.
>>
>> I can't see dot in your patch (or gem window), maybe they come from geometry
>> shader (which is missing) ?
>>
> i didn't use geometry shader . just  fragment .
> glsl program complains in the abstraction  but no harm here i think
>
>> i tried pix_snap2tex ( using gems.feedback from pdmtl abstractions) too
>> but no luck because we can't choose the mixing function .
>> and i would like only white to make trails .
>> and i don't know how to keep the supporting geometry from appearing .
>> the torus should be full black with a white trail only .
>>
>> A simple possibility is to use 2 torus, a black 'on' a white. And use the
>> white for the trail ?
>>
>> An other way :
>>
>> white torus as texture
>> |__> in the feedback __> output feedback as texture
>> |__> convert white in black texel __> output black torus as texture
>>
>> Then mix (multiply) black torus with white feedback to get a black torus
>> with white trails.
>> ++
>>
>> Jack
>>
> i'll send a modified patch a bit later .
>
> Thank you so much i see some good things from the last patch you sent .
>
> it is not what i want to do but opens other directions
> and perhaps i was focusing on one method but there seems to be alternatives .
>
> i'll update this thread tomorrow .
> i have to keep some life away from computer :-)
>
> Thanks for your help
>
> Py
>
> _______________________________________________
> Pd-list@iem.at mailing list
> UNSUBSCRIBE and account-management -> 
> http://lists.puredata.info/listinfo/pd-list

Hello Pierre-Yves,

This patch should work for your purpose.
If it doesn't work, you have, maybe, a problem with your configuration.
++

Jack


// Cyrille Henry 2007

void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

}
uniform float time, alpha_back;
uniform vec2 mouse;
uniform vec2 resolution;

uniform sampler2D backbuffer;

#define PI2 6.2831853070


// definition for a scale, rotate, and color transform
// color transform is multiply (darken) only
struct Transform {
        vec4 color;
        vec2 center;
        float scale;
        float rotation;
};

vec2 applyTransform(const Transform t, vec2 v) {
        v -= t.center;
        float c = cos(t.rotation);
        float s = sin(t.rotation);
        return (vec2(
                (v.x*c - v.y*s),
                (v.y*c + v.x*s)) * t.scale + t.center);
}

#define SCALE 5.0

// model will be scaled such that the rectangle (-SCALE/2, -SCALE/2), (SCALE/2, 
SCALE/2)
// will be centered and fit the window with square aspect ratio.
float scale = SCALE / min(resolution.y,resolution.x);

vec2 mapModelToTexture(const vec2 v) {
        return (v/(resolution*scale) + 0.5);
}

vec2 mapTextureToModel(const vec2 v) {
        return (v - 0.5 * resolution) * scale;
}

// apply transform, return backbuffer sample
vec4 getBackbufferTransform(const Transform t, vec2 v) {
        return t.color * 
                texture2D(backbuffer, 
                   mapModelToTexture(applyTransform(t, v)));
}

vec4 whiten(const vec4 color, float f) {
        return (1.-f)*color + vec4(f);
}

void main( void ) {
        // transform fragment coords to model coords
        vec2 v = mapTextureToModel(gl_FragCoord.xy);

        // draw orbs
        
        const float innerRadius = 0.01;
        float outerRadius = .24 + .03 * (sin(17.*time) + sin(11.*time));
        
        vec2 p1 = (vec2(sin(time), cos(time)));
        vec2 p2 = (vec2(sin(time*1.1), cos(time*1.1)));
        vec2 p3 = (vec2(sin(time*1.3), cos(time*1.3)));

        float d1 = length(v -p1);
        float d2 = length(v -p2);
        float d3 = length(v -p3);

        const float aa = 0.95;
        const float bb = 0.65;
        const float cc = 0.05;
        const vec4 color1 = vec4(aa, bb, cc, 2.0);
        const vec4 color2 = vec4(cc, bb, aa, 2.0);
        const vec4 color3 = vec4(aa, cc, bb, 2.0);

        vec4 drawing = vec4(0.,0.,0.,0.);
        drawing += smoothstep(outerRadius, innerRadius, d1) * color1;
        drawing += smoothstep(outerRadius, innerRadius, d2) * color2;
        drawing += smoothstep(outerRadius, innerRadius, d3) * color3;
        
        // draw ring/disc
        float rr = length(v);
        drawing += vec4(1.)
                * smoothstep(1.1, 1., rr)
                * smoothstep(0.9, 0.5+0.5*sin(0.1*time), rr);

        // apply feedback transforms to backbuffer
        
        // define transform structs
        float r = time*.27;
        Transform t1 = Transform(
                whiten(vec4(aa, bb, cc, 1.0), 0.7), 
                vec2(-.7, 0.),
                1.5, 
                -r*3.);
        Transform t2 = Transform(
                whiten(vec4(cc, bb, aa, 1.0), 0.7),
                vec2(0.7, 0.),
                1.5,
                r*2.);

        // composite feedback with drawing
        vec4 fc = max(  getBackbufferTransform(t1, v),
                        getBackbufferTransform(t2, v));
        gl_FragColor = (1.-drawing[3])*fc -vec4(.01) + drawing[3]*drawing;
        gl_FragColor.a = alpha_back;
}

// Jack/RYBN 2013
#extension GL_ARB_texture_rectangle : enable
uniform sampler2DRect MyTex1, MyTex2;

void main() {
        vec2 tex_coord = gl_FragCoord.st;
        vec4 color = texture2DRect(MyTex1, tex_coord);
        vec4 color0 = texture2DRect(MyTex2, tex_coord);
        color *= 0.01;
        color0 *= 0.99;
        gl_FragColor = color+color0;
 }

Attachment: test.pd
Description: application/puredata

_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to