Skip to content

Commit

Permalink
Surface examples updated
Browse files Browse the repository at this point in the history
  • Loading branch information
syanenko committed Feb 5, 2023
1 parent ec60fdd commit 3851181
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 82 deletions.
Binary file modified examples/ex_surface.mlx
Binary file not shown.
158 changes: 76 additions & 82 deletions examples/ex_surface_utf8.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
pl = povlab( povray_version,...
povray_path, ...
povray_out_dir);

% Environment

pl.include_begin('environment');
Expand All @@ -21,85 +22,85 @@
'[1.0 color rgb<0.1, 0.1, 0.1> ]} '...
'scale 1 }}']);
pl.include_end();

% Scene 1

% pl.scene_begin('scene_file', 'surface1.pov', 'image_file', 'surface1.png');
% pl.include("glass");
% pl.include("metals");
% pl.include("environment");
%
% % Camera
% pl.camera('angle', 35, 'location', [-10 -10 6], 'look_at', [0 0 0], 'type', 'perspective');
%
% % Lights
% pl.light('location', [-10 -17 7], 'color', [2 2 2], 'shadowless', true);
% pl.light('location', [100 200 300], 'color', [1 1 1], 'shadowless', true);
%
% % Hide preview
% %f = figure('Visible', 'off');
% %ax = axes(f);
%
% % Surface
% size = 60;
% [X,Y,Z] = peaks(size);
% s = surf(X,Y,Z);
% % With checkerd texture
% pl.surface('surface', s, 'scale', [1, 1, 0.35], 'texture_odd', 'Gold_Nugget', 'texture_even', 'T_Ruby_Glass');
%
% % With color map
% % pl.surface('surface', s, 'colormap', 'jet', 'scale', [1, 1, 0.35], 'finish', 'ambient 0.1 diffuse 0.4 reflection 0.15 specular 5.4 roughness 0.4');
% pl.scene_end();
%
% % Render and display
%
% figure()
% image = pl.render();
% imshow(image);
% % Scene 2
%
% pl.scene_begin('scene_file', 'surface2.pov', 'image_file', 'surface2.png');
% pl.include("glass");
% pl.include("metals");
% pl.include("environment");
%
% % Camera
% pl.camera('angle', 35, 'location', [-13 -13 8], 'look_at', [0 0.2 0], 'type', 'perspective');
%
% % Lights
% pl.light('location', [-10 -17 7], 'color', [2.5 2.5 2.5], 'shadowless', true);
% pl.light('location', [100 200 300], 'color', [1 1 1], 'shadowless', true);
%
% % Hide preview
% % f = figure('Visible', 'off');
% % ax = axes(f);
%
% % Surface
% [X,Y] = meshgrid(-4:.2:4);
% Z = Y.*sin(X) + X.*cos(Y);
% s = surf(X,Y,Z,'FaceAlpha',0.5);
%
% % With checkerd texture
% % pl.surface('surface', s, 'scale', [1, 1, 0.35], 'texture_odd', 'Bright_Bronze', 'texture_even', 'Orange_Glass');
%
% % With color map
% pl.surface('surface', s, 'colormap', 'hsv', 'scale', [1, 1, 0.35], 'finish', 'ambient 0.01 diffuse 0.3 reflection 0.1 specular 5.4 roughness 0.4');
% pl.scene_end();
% % Render and display
%
% figure();
% image = pl.render();
% imshow(image);
% Scene 3

pl.scene_begin('scene_file', 'surface1.pov', 'image_file', 'surface1.png');
pl.include("glass");
pl.include("metals");
pl.include("environment");

% Camera
pl.camera('angle', 35, 'location', [-10 -10 6], 'look_at', [0 0 0], 'type', 'perspective');

% Lights
pl.light('location', [-10 -17 7], 'color', [2 2 2], 'shadowless', true);
pl.light('location', [100 200 300], 'color', [1 1 1], 'shadowless', true);

% Hide preview
%f = figure('Visible', 'off');
%ax = axes(f);

% Surface
size = 60;
[X,Y,Z] = peaks(size);
s = surf(X,Y,Z);
% With checkerd texture
pl.surface('surface', s, 'scale', [1, 1, 0.35], 'texture_odd', 'Gold_Nugget', 'texture_even', 'T_Ruby_Glass');

% With color map
%finish = pl.declare("f", "finish {ambient 0.01 diffuse 0.3 reflection 0.1 specular 5.4 roughness 0.4}");
%pl.surface('surface', s, 'colormap', 'jet', 'scale', [1, 1, 0.35], 'finish', finish);
pl.scene_end();

% Render and display

figure()
image = pl.render();
imshow(image);

% Scene 2
pl.scene_begin('scene_file', 'surface2.pov', 'image_file', 'surface2.png');
pl.include("glass");
pl.include("metals");
pl.include("environment");

% Camera
pl.camera('angle', 35, 'location', [-13 -13 8], 'look_at', [0 0.2 0], 'type', 'perspective');

% Lights
pl.light('location', [-10 -17 7], 'color', [2.5 2.5 2.5], 'shadowless', true);
pl.light('location', [100 200 300], 'color', [1 1 1], 'shadowless', true);

% Hide preview
% f = figure('Visible', 'off');
% ax = axes(f);

% Surface
[X,Y] = meshgrid(-4:.2:4);
Z = Y.*sin(X) + X.*cos(Y);
s = surf(X,Y,Z,'FaceAlpha',0.5);

% With checkerd texture
% pl.surface('surface', s, 'scale', [1, 1, 0.35], 'texture_odd', 'Bright_Bronze', 'texture_even', 'Orange_Glass');
% With color map
finish = pl.declare("f", "finish {ambient 0.01 diffuse 0.3 reflection 0.1 specular 5.4 roughness 0.4}");
pl.surface('surface', s, 'colormap', 'hsv', 'scale', [1, 1, 0.35], 'finish', finish);
pl.scene_end();
% Render and display

figure();
image = pl.render();
imshow(image);

% Scene 3
pl.scene_begin('scene_file', 'surface3.pov', 'image_file', 'surface3.png');
pl.include("glass");
pl.include("metals");
pl.include("environment");

% Camera
pl.camera('angle', 35, 'location', [-25 -25 24], 'look_at', [0 0 0.5], 'type', 'perspective');
% pl.camera('angle', 35, 'location', [0 0 -25], 'look_at', [0 0 0.5], 'type', 'perspective');

% Lights
pl.light('location', [-10 -17 7], 'color', [2.5 2.5 2.5], 'shadowless', true);
Expand All @@ -110,29 +111,22 @@
%ax = axes(f);

% Surface
t = linspace (-8, 8, 40);
t = linspace (-8, 8, 50);
[x, y] = meshgrid (t, t);
r = sqrt (x .^ 2 + y .^ 2) + eps;
z = 18 * sin (r) ./ r;
s = surf(x,y,z, FaceColor = 'interp', EdgeColor = 'interp');

% t = linspace (-1, 1, 3);
% [x, y] = meshgrid (t, t);
% r = sqrt (x .^ 2 + y .^ 2) + eps;
% z = 18 * sin (r) ./ r;
% z = x;
% s = surf(x,y,z, FaceColor = 'interp', EdgeColor = 'interp');

% With checkerd texture
pl.surface('surface', s, 'scale', [1, 1, 3/10], 'texture_odd', 'Aluminum', 'texture_even', 'T_Winebottle_Glass');
% pl.surface('surface', s, 'scale', [1, 1, 0.5], 'texture_odd', 'Aluminum', 'texture_even', 'T_Winebottle_Glass');

% With flat texture
% pl.surface('surface', s, 'scale', [1, 1, 3/10], 'texture', 'Aluminum');
% pl.surface('surface', s, 'scale', [1, 1, 3/10], 'texture', 'T_Winebottle_Glass');
% pl.surface('surface', s, 'scale', [1, 1, 0.3], 'texture', 'Aluminum');
% pl.surface('surface', s, 'scale', [1, 1, 0.3], 'texture', 'T_Winebottle_Glass');

% With color map
%finish = pl.declare("f", "finish {ambient 0.01 diffuse 0.3 reflection 0.1 specular 5.4 roughness 0.4}");
%pl.surface('surface', s, 'colormap', 'hsv', 'scale', [1, 1, 0.35], 'finish', finish);
finish = pl.declare("f", "finish {ambient 0.01 diffuse 0.3 reflection 0.1 specular 5.4 roughness 0.4}");
pl.surface('surface', s, 'colormap', 'hsv', 'scale', [1, 1, 0.35], 'finish', finish);
pl.scene_end();
% Render and display

Expand Down

0 comments on commit 3851181

Please sign in to comment.