From 2e368438f3f6c0a65f0883ad272b6f2d9b719dbc Mon Sep 17 00:00:00 2001 From: HOSOKAWA Kenchi Date: Fri, 27 May 2011 00:17:33 +0900 Subject: [PATCH] sll --- dev4/Shader/Gabor.fx | 23 +++--- dev4/Shader/Gabor.ps | Bin 832 -> 936 bytes dev4/psychlops/core/graphic/canvas.cs | 10 +++ test4/PsychlopsMain.cs | 148 ++++++++++++++++++++++++++++++++-- 4 files changed, 163 insertions(+), 18 deletions(-) diff --git a/dev4/Shader/Gabor.fx b/dev4/Shader/Gabor.fx index 095d01f..5ec9fbf 100644 --- a/dev4/Shader/Gabor.fx +++ b/dev4/Shader/Gabor.fx @@ -45,16 +45,15 @@ float rp(float2 uv) } float4 main(float2 uv : TEXCOORD) : COLOR -//float4 main(float2 uv : VPOS ) : COLOR { - //float _r = rp(uv)*sigma*4.0; - //float env = exp( -(_r*_r) / 2.0 ) * alpha; - float _r = rp(uv)*8; - float env = exp( -(_r*_r) / (2.0) ) * alpha; - - float _x = sin(orientation)*uv[0]-cos(orientation)*uv[1]; - float l = 0.5+env*contrast*0.5*cos(frequency*_x + phase); - - float4 color = float4(l,l,l,1.0); - return color; -} + float _r = rp(uv)*8; + float env = exp( -(_r*_r) / (2.0) ) * alpha; + + float _x = sin(orientation)*uv[0]-cos(orientation)*uv[1]; + float cl = 127.0/255.0+env*contrast*127.0/255.0*cos(frequency*_x + phase); + if(_r>3.2) if(abs(cl-127.0/255.0)<0.005) cl=127.0/255.0; + float l = cl; + + float4 color = float4(l,l,l,1.0); + return color; +} \ No newline at end of file diff --git a/dev4/Shader/Gabor.ps b/dev4/Shader/Gabor.ps index cdc54db9cb2e54d29aa22ef7b51400704afffa94..e937ad44a140fbf5583854cfd249f1072fb8a841 100644 GIT binary patch delta 512 zcma)2yH3PF3>+WX+dy#?d;+?^K)mW}Bhm6DSvvar0Y@|_ReBme0BU~V{$m;2S`JYm zWg~lbJTvR}^=n?PWrMrVkKOIr*UKAFZuUF58UycmsD4hPmtf!zR4Enz? z5w?ZdKg<2Na#=8QvohHXOqsHg*Ep7MFgqq_ebtTcAo|~TYmas0@=brVFgbrj*OpNt yK#0YHFkQMqNAubCLG!3H13&oEqmO`?0?XvvzAW@?`W)@~sH$G~=fn@CR^S`aI#uZa delta 407 zcma)1xe>xJ5ZsgTLt+AIpbG|Oh)LZ8C6M{3!3~IvA#w>6<37Zmga(@kjik}->UQ@Y z^{W~W(&`bjHJoKXT->P_CCc;kB~SplhA!*iTfk+0&Q-voSAJ^h--$UvLCwjp0B)ze zy!12|bh?e=jzKyj;s<+|F<9_BVkTf%LyC|TY36!P=8m(z$LC|c-PZ|R72BwHV)c^nh diff --git a/dev4/psychlops/core/graphic/canvas.cs b/dev4/psychlops/core/graphic/canvas.cs index 7f0267b..e67c6ae 100644 --- a/dev4/psychlops/core/graphic/canvas.cs +++ b/dev4/psychlops/core/graphic/canvas.cs @@ -730,6 +730,16 @@ namespace Psychlops { return new System.Windows.Point(d.x, d.y); } + + + public Point datum { get { return this; } set { this = value; } } + public Point shift(Point p) { this = this + p; return this; } + public Point centering(Point p) { this = p; return this; } + public Point getDatum() { return this; } + public Point setDatum(Point p) { this = p; return p; } + public Point shift(double x, double y, double z = 0.0) { return shift(new Point(x, y, z)); } + public Point centering() { return centering(Main.drawable.getCenter()); } + public Point centering(double x, double y, double z = 0.0) { return centering(new Point(x, y, z)); } } partial struct Color diff --git a/test4/PsychlopsMain.cs b/test4/PsychlopsMain.cs index 16acfd8..3969c0b 100644 --- a/test4/PsychlopsMain.cs +++ b/test4/PsychlopsMain.cs @@ -1,5 +1,140 @@ - +using Psychlops; +namespace PsychlopsSilverlightApp +{ + + public class PsychlopsMain + { + + + public void psychlops_main() { + + Canvas display = new Canvas(768,768); + + double rect_size = 100; + double rect_lum = 0.5; + double bg_lum = 0.5; + double size = 250.0; + double sigma; + sigma = size/6.0; + double lambda; + lambda = 6*sigma; + int envelopemode = 0; + double refresh = display.getRefreshRate(); + double[] SF=new double[2]; + + SF[0]=4.0; + SF[1]=4.0; + + double phase=0; + + double[] initphase = new double[2]; + double _i, _j, _x, _y, _x2, _y2, col; + double amplitude = 1.0; + + Rectangle fixation1 = new Rectangle(3,9); + Rectangle fixation2 = new Rectangle(9,3); + fixation1.centering(); + fixation2.centering(); + Rectangle contrastrect = new Rectangle(); + contrastrect.set(760,760); + + Image envelope = new Image(); + Psychlops.Color bglum= new Color(0.5,0.5,0.5); + Psychlops.Color masklum = new Color(0.5,0.5,0.5,0.5); + + Interval rng = new Interval(); + + + Psychlops.Widgets.Slider TF; + TF = new Psychlops.Widgets.Slider("TF", 0.25<=rng<=2.0 , 0.1); + TF.value=0.75; + + + + Psychlops.Widgets.Slider SFs; + SFs = new Psychlops.Widgets.Slider("SF", 4.0<=rng<=16.0 , 4.0); + SFs.value = 4.0; + + Psychlops.Widgets.Slider contrast; + contrast= new Psychlops.Widgets.Slider("Contrast", 0.0<=rng<=1.0 , 0.1); + contrast.value = 0.1; + + + var element = StaticFunctions.NewArray(2); + for (int i = 0; i < element.Length; i++){ + element[i].setSigma(sigma); // set a size of patch as a halfwidth of Gaussian + element[i].orientation = Math.PI/4.0+Math.PI/2.0*(1-i);//Math.PI/2*(rand()%2);// //set orientations + initphase[i]=0; + } + + + + envelope.set(size, size); + envelope.clear(bglum); + + for(int i=0; i0){ + envelope.centering().shift(size*0.6,-size*0.6).draw(); + envelope.centering().shift(-size*0.6,size*0.6).draw(); + } + masklum.set(bg_lum, bg_lum, bg_lum, 1-contrast); + contrastrect.centering(); + contrastrect.draw(masklum); + fixation1.centering().shift(size*2,0.0); + fixation1.draw(Color.red); + fixation2.centering().shift(size*2,0.0); + fixation2.draw(Color.red); + + Display.flip(); + + + } + +} + + + + } + +} +/* using Psychlops; //Position Bias Program @@ -53,15 +188,16 @@ namespace PsychlopsSilverlightApp //img3.centering().shift(0, isize * 1.5).draw(); - foreach (var g in gabor1) + //foreach (var g in gabor1) + for (int i = 0; i < gabor1.Length; i++) { - g.wavelength = lambda; - g.phase = (double)frames * 2.0 * Math.PI * tfreq / 60; - g.contrast = contrast; + gabor1[i].wavelength = lambda; + gabor1[i].phase = (double)frames * 2.0 * Math.PI * tfreq / 60; + gabor1[i].contrast = contrast; //g.wavelength2 = lambda * 2; //g.phase2 = (double)frames * 2.0 * Math.PI * tfreq / 60; //g.contrast2 = contrast / 2; - g.draw(); + gabor1[i].draw(); } if (!Mouse.left.pressed()) frames++; -- 2.11.0