From 4edb84839ecb1ddb9eba1053875971b5f9fd31d9 Mon Sep 17 00:00:00 2001 From: neurolabusc Date: Thu, 30 Jul 2020 11:54:46 -0400 Subject: [PATCH] New release (v1.0.20200729) --- commandsu.pas | 2 +- define_types.pas | 2 +- gl_legacy_3d.pas | 79 ++------ mainunit.lfm | 1 + mainunit.pas | 9 + mesh.pas | 1 - opts.inc | 2 +- .../Resources/script/create_atlas.gls | 2 +- surfice.app/Contents/Resources/script/cx.gls | 9 - .../Contents/Resources/script/newer_2017.py | 18 ++ surfice.lps | 171 +++++++++--------- 11 files changed, 129 insertions(+), 167 deletions(-) delete mode 100644 surfice.app/Contents/Resources/script/cx.gls create mode 100644 surfice.app/Contents/Resources/script/newer_2017.py diff --git a/commandsu.pas b/commandsu.pas index 6f8cb92..c659479 100755 --- a/commandsu.pas +++ b/commandsu.pas @@ -140,7 +140,7 @@ procedure WAIT (MSEC: integer); (Ptr:@OVERLAYCLOSEALL;Decl:'OVERLAYCLOSEALL';Vars:''), (Ptr:@OVERLAYCOLORNAME;Decl:'OVERLAYCOLORNAME';Vars:'(lOverlay: integer; lFilename: string)'), (Ptr:@OVERLAYLOAD;Decl:'OVERLAYLOAD';Vars:'(lFilename: string)'), - (Ptr:@OVERLAYEXTREME;Decl:'OVERLAYMINMAX';Vars:'(lOverlay, lMode: integer)'), + (Ptr:@OVERLAYEXTREME;Decl:'OVERLAYEXTREME';Vars:'(lOverlay, lMode: integer)'), (Ptr:@OVERLAYMINMAX;Decl:'OVERLAYMINMAX';Vars:'(lOverlay: integer; lMin,lMax: single)'), (Ptr:@OVERLAYOPACITY;Decl:'OVERLAYOPACITY';Vars:'(lOverlay: integer; OPACITY: byte)'), (Ptr:@OVERLAYTRANSPARENCYONBACKGROUND;Decl:'OVERLAYTRANSPARENCYONBACKGROUND';Vars:'(lPct: integer)'), diff --git a/define_types.pas b/define_types.pas index dcb1a57..ee329d8 100755 --- a/define_types.pas +++ b/define_types.pas @@ -10,7 +10,7 @@ interface {$endif} const - kVers = 'v1.0.20200529'; + kVers = 'v1.0.20200729'; NaN : double = 1/0; kTab = chr(9); kCR = chr (13); diff --git a/gl_legacy_3d.pas b/gl_legacy_3d.pas index 34810b8..6d298bd 100755 --- a/gl_legacy_3d.pas +++ b/gl_legacy_3d.pas @@ -18,21 +18,7 @@ interface norm : TPoint3f; //vertex normal clr : TRGBA; end; - (*const kVert3dx = '#version 120' -+#10'attribute vec3 Vert;' -+#10'attribute vec3 Norm;' -+#10'attribute vec4 Clr;' -+#10'varying vec3 vN, vL, vV;' -+#10'varying vec4 vClr, vP;' -+#10'uniform vec3 LightPos = vec3(0.0, 20.0, 30.0); //LR, -DU+, -FN+' -+#10'void main() {' -+#10' vP = vec4(Vert, 1.0);' -+#10' vN = normalize(gl_NormalMatrix * Norm);' -+#10' vV = -vec3(gl_ModelViewMatrix* vP);' -+#10' vL = normalize(gl_LightSource[0].position.xyz);' -+#10' gl_Position = gl_ModelViewProjectionMatrix * vP;' -+#10' vClr = Clr;' -+#10'}'; *) + const kVert3d = '#version 120' +#10'attribute vec3 Vert;' +#10'attribute vec3 Norm;' @@ -84,24 +70,22 @@ interface +#10'varying vec4 vClr;' +#10'varying vec3 vN, vL, vV;' +#10'void main() {' - +#10' float Ambient = 0.4;' + +#10' float Ambient = 0.5;' +#10' float Diffuse = 0.7;' - +#10' float Specular = 0.6;' + +#10' float Specular = 0.2;' +#10' float Shininess = 60.0;' +#10' vec3 l = normalize(vL);' +#10' vec3 n = normalize(vN);' +#10' vec3 v = normalize(vV);' +#10' vec3 h = normalize(vL+v);' +#10' float diffuse = dot(vL,n);' - +#10' vec3 a = gl_FrontMaterial.ambient.rgb;' - +#10' a = mix(a.rgb, vClr.rgb, vClr.a);' - +#10' vec3 d = a * Diffuse;' - +#10' a *= Ambient;' - +#10' float diff = dot(n,l);' - +#10' float spec = pow(max(0.0,dot(n,h)), Shininess);' - +#10' vec3 backcolor = Ambient*vec3(0.1+0.1+0.1) + d*abs(diff);' - +#10' float backface = step(0.00, n.z);' - +#10' gl_FragColor = vec4(mix(backcolor.rgb, a + d*diff + spec*Specular, backface), 1.0);' + +#10' vec3 a = vClr.rgb * Ambient;' + +#10' vec3 d = vClr.rgb * Diffuse;' + +#10' float diff = dot(n,l);' + +#10' float spec = pow(max(0.0,dot(n,h)), Shininess);' + +#10' vec3 backcolor = Ambient*vec3(0.1+0.1+0.1) + d*abs(diff);' + +#10' float backface = step(0.00, n.z);' + +#10' gl_FragColor = vec4(mix(backcolor.rgb, a + d*diff + spec*Specular, backface), 1.0);' +#10'}'; @@ -183,7 +167,7 @@ function BuildDisplayListStrip(Indices: TInts; Verts, vNorms: TVertices; vRGBA: i,j, n: integer; begin n := length(Indices); - if (n < 2) or (length(Verts) < 2) or (length(Verts) <> length(vNorms)) or (length(Verts) <> length(vRGBA)) then exit; + if (n < 2) or (length(Verts) < 2) or (length(Verts) <> length(vNorms)) or (length(Verts) <> length(vRGBA)) then exit(0); //glDeleteLists(displayList, 1); result := glGenLists(1); glNewList(result, GL_COMPILE); @@ -215,47 +199,6 @@ function BuildDisplayListStrip(Indices: TInts; Verts, vNorms: TVertices; vRGBA: glLineWidth(1); end; -(*function TColorToF (C: TColor; i: integer): single; -begin - result := 1; - if i = 1 then result := red(C)/255; - if i = 2 then result := green(C)/255; - if i = 3 then result := blue(C)/255; -end; - -procedure SetLighting (var lPrefs: TPrefs); -// http://www.cs.brandeis.edu/~cs155/OpenGL%20Lecture_05_6.pdf -//https://lost-contact.mit.edu/afs/su.se/i386_linux24/pkg/matlab/13/toolbox/matlab/graph3d/material.m -//https://www.opengl.org/sdk/docs/man2/xhtml/glMaterial.xml -// https://github.com/Psychtoolbox-3/Psychtoolbox-3/blob/master/Psychtoolbox/PsychDemos/OpenGL4MatlabDemos/UtahTeapotDemo.m -var - kMaterial : array [1..5] of single = (0.3, 0.6, 0.9, 120, 1.0); //shiny - wcolor : array [1..4] of single = (1, 1, 1, 0.5); //white - objcolor : array [1..4] of single = (1, 1, 1, 0.5); //white - kaRGB, kdRGB, ksRGB : array [1..4] of single; - i: integer; -begin - for i := 1 to 4 do begin - objcolor[i] := TColorToF(lPrefs.ObjColor,i); - kaRGB[i] := objColor[i] * kMaterial[1]; - kdRGB[i] := objColor[i] * kMaterial[2]; - ksRGB[i] := (((1-kMaterial[5]) * objColor[i]) +(kMaterial[5] * wcolor[i])) * kMaterial[3]; - end; - //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GLint(GL_FALSE)); - glEnable(GL_LIGHTING); - glEnable(GL_LIGHT0); - glLightfv(GL_LIGHT0, GL_AMBIENT, @KaRGB); - glLightfv(GL_LIGHT0, GL_DIFFUSE, @KdRGB); - glLightfv(GL_LIGHT0, GL_SPECULAR, @KsRGB); - glShadeModel(GL_SMOOTH); - glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, @objColor); - glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE, @objColor); - glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, @wColor); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, kMaterial[4]); -end; *) - - {$IFNDEF DGL} //gl.pp does not link to the glu functions, so we will write our own procedure gluPerspective (fovy, aspect, zNear, zFar: single); //https://www.opengl.org/sdk/docs/man2/xhtml/gluPerspective.xml diff --git a/mainunit.lfm b/mainunit.lfm index 9475843..c882162 100755 --- a/mainunit.lfm +++ b/mainunit.lfm @@ -1623,6 +1623,7 @@ object GLForm1: TGLForm1 'gl.resetdefaults()' 'gl.meshload(''BrainMesh_ICBM152Right.mz3'')' ) + OnKeyUp = ScriptMemoKeyUp ParentFont = False ScrollBars = ssAutoBoth TabOrder = 0 diff --git a/mainunit.pas b/mainunit.pas index cca9567..7e9a296 100755 --- a/mainunit.pas +++ b/mainunit.pas @@ -347,6 +347,8 @@ procedure LayerAlphaTrackMouseUp(Sender: TObject; Button: TMouseButton; Shift: T procedure PaintModeMenuClick(Sender: TObject); procedure PasteMenuClick(Sender: TObject); procedure PrevOverlayMenuClick(Sender: TObject); + procedure ScriptMemoKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState + ); procedure Shaders1Click(Sender: TObject); procedure UpdateLayerBox(NewLayers: boolean); @@ -2292,6 +2294,13 @@ procedure TGLForm1.PrevOverlayMenuClick(Sender: TObject); UpdateLayerBox(true); end; +procedure TGLForm1.ScriptMemoKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + inherited; + ScriptBox.Caption := format('Scripting [Line %d Col %d]', [ScriptMemo.CaretPos.Y+1, ScriptMemo.CaretPos.X+1]); +end; + procedure TGLForm1.Shaders1Click(Sender: TObject); begin diff --git a/mesh.pas b/mesh.pas index 296a0bf..5fe4182 100755 --- a/mesh.pas +++ b/mesh.pas @@ -1411,7 +1411,6 @@ procedure DrawOverlay(prog: GLuint); vao := 0; vbo := 0; vaoOverlay := 0; vboOverlay := 0; {$ELSE} {$IFDEF LEGACY_INDEXING} - //nFacesOverlay := 0; //TODO2020 if index_vbo <> 0 then glDeleteBuffers(1,@index_vbo); if (vertex_vbo <> 0) then diff --git a/opts.inc b/opts.inc index db806e3..32f4acc 100755 --- a/opts.inc +++ b/opts.inc @@ -6,7 +6,7 @@ // NOT COREGL, DEFINED LEGACY_INDEXING : uses indexed vertices and glDrawElements (medium efficiency) // NOT COREGL, NOT LEGACY_INDEXING : glCallList with redundant vertices (least efficient) -//{$DEFINE COREGL} +{$DEFINE COREGL} {$DEFINE LEGACY_INDEXING} {$DEFINE GEOM_GLEXT} //{$DEFINE HEMISSAO} //for hemispherical SSAO - requires shaders that save surface normal - see hemiAO3 and hemiAO diff --git a/surfice.app/Contents/Resources/script/create_atlas.gls b/surfice.app/Contents/Resources/script/create_atlas.gls index 206ff01..d4a2256 100644 --- a/surfice.app/Contents/Resources/script/create_atlas.gls +++ b/surfice.app/Contents/Resources/script/create_atlas.gls @@ -6,7 +6,7 @@ begin azimuthelevation(240, 15); meshload('AICHAhr_left.mz3'); n := atlasmaxindex(0); - for i := 2 downto 2 do begin + for i := n downto 1 do begin setlength(msk, i); for j := 1 to i do msk[j-1] := j; diff --git a/surfice.app/Contents/Resources/script/cx.gls b/surfice.app/Contents/Resources/script/cx.gls deleted file mode 100644 index 88e083f..0000000 --- a/surfice.app/Contents/Resources/script/cx.gls +++ /dev/null @@ -1,9 +0,0 @@ -begin - resetdefaults(); - //assign intensities to superior frontal regions (aicha regions 4..6) - // save as file named 'surficetemp.mz3' in our home directory - atlasstatmap('AICHAhr_left.mz3','surficetemp.mz3',[4,5,6],[7,3,4]); - meshload('lh.pial'); - overlayload('surficetemp.mz3'); - shaderxray(1.0, 0.3); -end. \ No newline at end of file diff --git a/surfice.app/Contents/Resources/script/newer_2017.py b/surfice.app/Contents/Resources/script/newer_2017.py new file mode 100644 index 0000000..ff23e78 --- /dev/null +++ b/surfice.app/Contents/Resources/script/newer_2017.py @@ -0,0 +1,18 @@ +import gl +gl.resetdefaults() +gl.meshload('BrainMesh_ICBM152Right.mz3') +gl.meshcurv() +gl.overlayminmax(1,-1,1) +gl.overlaycolorname(1,'surface') +gl.overlayinvert(1,1) +gl.overlayload('motor_4t95vol.nii.gz') +gl.overlaycolorname(2,'kelvin') +gl.overlayminmax(2,2,7) +gl.overlayload('scalp.mz3') +gl.overlaycolorname(3,'gold') +gl.shaderxray(1.0, 0.9) +gl.meshoverlayorder(1) +gl.colorbarvisible(0) +gl.shaderambientocclusion(0.05) +gl.azimuthelevation(90, 15) +gl.clipazimuthelevation(0.5, 0, 90) diff --git a/surfice.lps b/surfice.lps index 603e289..e89e13b 100644 --- a/surfice.lps +++ b/surfice.lps @@ -18,8 +18,8 @@ - - + + @@ -47,7 +47,7 @@ - + @@ -69,10 +69,10 @@ - + - + @@ -126,19 +126,18 @@ - - - + + + - - + - + @@ -146,8 +145,7 @@ - - + @@ -162,26 +160,26 @@ - - - + + + - + - + - - + + @@ -250,9 +248,11 @@ + - - + + + @@ -261,165 +261,166 @@ - + - + + - + - + - + - + - + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - - + + - - + +