Skip to content

Commit 7fa0f53

Browse files
committed
fix ::Lattice with Shading == 1
1 parent 33e7b02 commit 7fa0f53

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

lib/PDL/Graphics/TriD/GL.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ use OpenGL::Modern qw(
178178
GL_ARRAY_BUFFER GL_ARRAY_BUFFER_BINDING
179179
GL_ELEMENT_ARRAY_BUFFER GL_ELEMENT_ARRAY_BUFFER_BINDING
180180
GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER
181-
GL_NEAREST GL_CLAMP_TO_EDGE GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T
181+
GL_LINEAR GL_CLAMP_TO_EDGE GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T
182182
GL_TEXTURE_2D GL_TEXTURE_BINDING_2D
183183
GL_FLOAT GL_STATIC_DRAW
184184
);
@@ -219,8 +219,8 @@ sub load_texture {
219219
# ||= as only need one, even if re-setup
220220
glBindTexture($target, $this->{Impl}{$idname} ||= glGenTextures_p(1));
221221
glTexImage2D_c($target, 0, $iformat, $x, $y, 0, $format, $type, $pdl->make_physical->address_data);
222-
glTexParameteri($target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
223-
glTexParameteri($target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
222+
glTexParameteri($target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
223+
glTexParameteri($target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
224224
glTexParameteri($target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
225225
glTexParameteri($target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
226226
}

lib/PDL/Graphics/TriD/Objects.pm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,12 @@ sub new {
211211
));
212212
}
213213
if ($options->{Shading}) {
214-
if ($options->{Smooth}) {
215-
$this->{Normals} = $vn;
216-
} else {
214+
$this->{Normals} = $options->{Smooth} ? $vn : $fn->dummy(1,$idx0)->clump(1,2);
215+
if (!$options->{Smooth}) {
217216
$this->{Points} = $this->{Points}->dice_axis(1,$idxflat);
218217
my ($cols) = grep defined $this->{$_}, qw(Colors TexCoord);
219218
$this->{$cols} = $this->{$cols}->dice_axis(1,$idxflat);
220-
$this->{Normals} = $fn->dummy(1,$idx0)->clump(1,2);
219+
$this->{$cols} = $this->{$cols}->splitdim(1,3)->t->avgover->dummy(1,3)->clump(1,2) if $options->{Shading} == 1;
221220
$this->{Faceidx} = PDL->sequence(PDL::ulong,$idx0,@idxdims);
222221
}
223222
}

0 commit comments

Comments
 (0)