Skip to content

Commit

Permalink
New release (v1.0.20200729)
Browse files Browse the repository at this point in the history
  • Loading branch information
neurolabusc committed Jul 30, 2020
1 parent 2f4443c commit 4edb848
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 167 deletions.
2 changes: 1 addition & 1 deletion commandsu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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)'),
Expand Down
2 changes: 1 addition & 1 deletion define_types.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
79 changes: 11 additions & 68 deletions gl_legacy_3d.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;'
Expand Down Expand Up @@ -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'}';


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions mainunit.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,7 @@ object GLForm1: TGLForm1
'gl.resetdefaults()'
'gl.meshload(''BrainMesh_ICBM152Right.mz3'')'
)
OnKeyUp = ScriptMemoKeyUp
ParentFont = False
ScrollBars = ssAutoBoth
TabOrder = 0
Expand Down
9 changes: 9 additions & 0 deletions mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion mesh.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion opts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion surfice.app/Contents/Resources/script/create_atlas.gls
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions surfice.app/Contents/Resources/script/cx.gls

This file was deleted.

18 changes: 18 additions & 0 deletions surfice.app/Contents/Resources/script/newer_2017.py
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit 4edb848

Please sign in to comment.