POV-Ray : Newsgroups : povray.general : Mesh rendering artifacts Server Time
29 Mar 2024 10:39:38 EDT (-0400)
  Mesh rendering artifacts (Message 44 to 53 of 63)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: yesbird
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 08:20:00
Message: <web.63da667e249f00765f3e868110800fb2@news.povray.org>
> I would go one step further, and put them all into the same array, although
> that's not strictly necessary.   I'm just thinking about juggling all of the
> data in a macro, and having a single array name would make it easier, but not
> really necessary.

That's what I've done, thanks to your examples, result attached.


Post a reply to this message


Attachments:
Download 'surface3_make_mesh.pov.txt' (931 KB)

From: Bald Eagle
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 20:25:00
Message: <web.63db100c249f00761f9dae3025979125@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> Hi, guys.
> May be am asking too many questions, but I am new to POV and before asking
> trying everything I can not for only one hour.
>
> Could you suggest the way of getting rid of artifact, markered on this image,



I knew this was going to be a debugging nightmare, so I made a nice big Gin &
Tonic, got out the Italian olive medley, and started fiddling.


I have found out what your problem is, and it's directly related to what MatLab
exports, and how you're trying to render it in POV-Ray.

At first glance, it sort of seemed to me that some of the colors were getting
"dragged" up into places that they shouldn't be.   And that's sort of what's
happening.  I outlined each triangle to show the edges, and there was a
pronounced matching of the colors with the edges of the grid - parabolas of
color that followed the vertical slicing of the surface.

What you WANT is a nice, gradient y pattern like I first suggested.
What you're getting is a 3-color interpolation of the 3 vertex colors, which is
blending colors from the wrong regions, and thus giving you the funny colors.

What I did was "shrink" the triangles a bit, and plot spheres with the vertex
colors at each vertex.   Then I made a cylinder with a gradient going from the
color of one vertex to the color of the other vertex.  Then I did the same
thing, only connecting all of the vertices to the triangle's center.

This shows the geometry and the colors along with the way the colors are
interpolated.

_I think you can fix this by changing the axes that you're slicing along._

I would also suggest that you orient all of you stuff the way POV-Ray does -
with a left-handed coordinate system, +x to the right, +y as up, and +z going
into the screen and away from you.

- BE


Post a reply to this message


Attachments:
Download 'surface3_checkattributes.png' (694 KB)

Preview of image 'surface3_checkattributes.png'
surface3_checkattributes.png


 

From: Tor Olav Kristensen
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 20:35:00
Message: <web.63db11c9249f0076383c879289db30a9@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> > I would go one step further, and put them all into the same array, although
> > that's not strictly necessary.   I'm just thinking about juggling all of the
> > data in a macro, and having a single array name would make it easier, but not
> > really necessary.
>
> That's what I've done, thanks to your examples, result attached.

I'm sorry to say, but I don't think that this is a sound advise.

Have a look at these two ways of organizing, naming and declaring the data:

// ====================================================================

#declare V = array[4802][9] {
{<3.76, 7.35, 2.01>, <3.76, 7.67, 1.63>, <4.08, 7.67, 1.39>, <0.32, 0.64, 0.70>,
<0.36, 0.74, 0.56>, <0.40, 0.76, 0.52>, <0.38, 1.00, 0.00>, <0.48, 1.00, 0.00>,
<0.55, 1.00, 0.00>},
{<3.76, 7.35, 2.01>, <4.08, 7.35, 1.83>, <4.08, 7.67, 1.39>, <0.32, 0.64, 0.70>,
<0.38, 0.69, 0.62>, <0.40, 0.76, 0.52>, <0.38, 1.00, 0.00>, <0.43, 1.00, 0.00>,
<0.55, 1.00, 0.00>},
....
}

// ====================================================================

// 50x50 Vertices --> 2x49x49 triangles
#declare M = 2*(50 - 1)*(50 - 1);

// Triangle data
#declare VV = array[M][3]; // Vertices
#declare NN = array[M][3]; // Normals at the vertices
#declare Colors = array[M][3]; // Colors at the vertices

#declare VV =
    array[M][3] {
        { <3.76, 7.35, 2.01>, <3.76, 7.67, 1.63>, <4.08, 7.67, 1.39> },
        { <3.76, 7.35, 2.01>, <4.08, 7.35, 1.83>, <4.08, 7.67, 1.39> },
        ...
    }
;
#declare NN =
    array[M][3] {
        { <0.32, 0.64, 0.70>, <0.36, 0.74, 0.56>, <0.40, 0.76, 0.52> },
        { <0.32, 0.64, 0.70>, <0.38, 0.69, 0.62>, <0.40, 0.76, 0.52> },
        ...
    }
;
#declare Colors =
    array[M][3] {
        { <0.38, 1.00, 0.00>, <0.48, 1.00, 0.00>, <0.55, 1.00, 0.00> },
        { <0.38, 1.00, 0.00>, <0.43, 1.00, 0.00>, <0.55, 1.00, 0.00> },
        ...
    }
;

// ====================================================================

Which one do you think informs a new user best about what is going on ?

I don't think that it should be a goal in this case to write minimal
code and packing things as tightly together as possible.

Giving names to different sections of data should be part of the
documentation.

Magic numbers like 4802 is never a good thing. You should show the user
how you ended up with that number.

If everything is put into a single array, then if someone wants to
recalculate e.g. the normals, they may have to deal with the vertices
and the colors too.

I myself have been abusing Excel for many years to process data that
would have been much better dealt with in a high level programming
language. So I don't think that making it easier to import all the
data in one go into a spreadsheet justifies anonymising and obscuring
the data even more than they already are.

I apologize if this sounds a bit harsh, but I am writing this with my
best intentions.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 20:55:00
Message: <web.63db179e249f0076383c879289db30a9@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "yesbird" <nomail@nomail> wrote:
> > Hi, guys.
> > May be am asking too many questions, but I am new to POV and before asking
> > trying everything I can not for only one hour.
> >
> > Could you suggest the way of getting rid of artifact, markered on this image,
>
>
>
> I knew this was going to be a debugging nightmare, so I made a nice big Gin &
> Tonic, got out the Italian olive medley, and started fiddling.
>
>
> I have found out what your problem is, and it's directly related to what MatLab
> exports, and how you're trying to render it in POV-Ray.
>
> At first glance, it sort of seemed to me that some of the colors were getting
> "dragged" up into places that they shouldn't be.   And that's sort of what's
> happening.  I outlined each triangle to show the edges, and there was a
> pronounced matching of the colors with the edges of the grid - parabolas of
> color that followed the vertical slicing of the surface.
>
> What you WANT is a nice, gradient y pattern like I first suggested.
> What you're getting is a 3-color interpolation of the 3 vertex colors, which is
> blending colors from the wrong regions, and thus giving you the funny colors.
>
> What I did was "shrink" the triangles a bit, and plot spheres with the vertex
> colors at each vertex.   Then I made a cylinder with a gradient going from the
> color of one vertex to the color of the other vertex.  Then I did the same
> thing, only connecting all of the vertices to the triangle's center.
>
> This shows the geometry and the colors along with the way the colors are
> interpolated.
>...

Yes, I think you have found the reason for the artifacts. Good job!

Here's a web page about how to deal with this:

"How to blend colors across 2 triangles"
https://webglfundamentals.org/webgl/lessons/
webgl-qna-how-to-blend-colors-across-2-triangles.html

Nice image btw.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Bald Eagle
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 20:55:00
Message: <web.63db17c6249f00761f9dae3025979125@news.povray.org>
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:

> Which one do you think informs a new user best about what is going on ?


THIS ONE!  THIS ONE!  :D

#declare V = array[4802][9] {

//  VERTEX1    NORMAL1   VERTEX2   NORMAL2    VERTEX3    NORMAL3   COLOR1
COLOR2   COLOR3
{<-8.00, -8.00, -1.51>, <+0.19, +0.19, +0.96>, <-8.00, -7.67, -1.62>, <+0.07,
+0.07, +1.00>, <-7.67, -7.67, -1.64>, <-0.06, -0.06, +1.00> <1.00, 0.66, 0.00>,
<1.00, 0.61, 0.00>, <1.00, 0.61, 0.00>}


> I don't think that it should be a goal in this case to write minimal
> code and packing things as tightly together as possible.
>
> Giving names to different sections of data should be part of the
> documentation.

It should, and If someone like me wants to look at it in a spreadsheet, then I
could just regurgitate it out into a #debug file and do it that way.

> Magic numbers like 4802 is never a good thing. You should show the user
> how you ended up with that number.

I'd agree, as it also helps when writing the code for loops, etc.
As much math as I do, I can never seem to get the really simple stuff right.

>
> If everything is put into a single array, then if someone wants to
> recalculate e.g. the normals, they may have to deal with the vertices
> and the colors too.

The first thing I did was recalculate the normals, and
a) you are right, it was confusing at first, because there were no labels, and I
forgot the alternating structure of the smooth_triangle format.
b) it was still pretty easy since I just made a smaller array of the new
normals, and used a modified macro to make the mesh with the new normals from
the new array.

> I myself have been abusing Excel for many years

OMG.  There's help out there, Tor.  I hear there's even some groups that can
wean you off of that with OpenOffice.   ;)

> I apologize if this sounds a bit harsh, but I am writing this with my
> best intentions.

We're all just here to learn and play.  Don't go full Ive, and I'm sure
everything will be ok  :D

- Bill


Post a reply to this message

From: Bald Eagle
Subject: Re: Mesh rendering artifacts
Date: 1 Feb 2023 21:05:00
Message: <web.63db1a32249f00761f9dae3025979125@news.povray.org>
Also:

I've been casually wondering, "Why is this guy from Russia using "yesbird" as a
username?"

And then I see the YesShows album cover!   WooHoo!

As jr would say, "I'm chuffed!"
Yes is easily at the top of the list of my favorite bands of all time.


I think a Yes themed POV-Ray render is going to have to be one of my next
non-math doodles.


- BE


Post a reply to this message

From: yesbird
Subject: Re: Mesh rendering artifacts
Date: 2 Feb 2023 03:25:00
Message: <web.63db7207249f00763d614a2510800fb2@news.povray.org>
> I knew this was going to be a debugging nightmare, so I made a nice big Gin &
> Tonic, got out the Italian olive medley, and started fiddling.

If I could, I'd buy them for you )

> I have found out what your problem is, and it's directly related to what MatLab
> exports, and how you're trying to render it in POV-Ray.
>

It was a serious investigation, so I am a little ashamed that my question forced
you to do so much work.

> _I think you can fix this by changing the axes that you're slicing along._

Many thanks ! Now know where to look to fix it. In any case I decided to follow
your suggestion and do all calculations in POV, passing only function or mesh,
described surface, using yours and Tor's code, leaving present implementation as
alternative.

>THIS ONE!  THIS ONE!  :D
>#declare V = array[4802][9] {
>//  VERTEX1    NORMAL1   VERTEX2   NORMAL2    VERTEX3    NORMAL3   COLOR1
COLOR2   COLOR3

Sorry, I missed it, assumed, that macro code is transparent and hence structure
is 'self-explained'.

> I would also suggest that you orient all of you stuff the way POV-Ray does -
> with a left-handed coordinate system, +x to the right, +y as up, and +z going
> into the screen and away from you.

I only want to make it compatible with ML's defaults and render from the same
viewpoint as it does.


Post a reply to this message

From: yesbird
Subject: Re: Mesh rendering artifacts
Date: 2 Feb 2023 03:45:00
Message: <web.63db7741249f00763d614a2510800fb2@news.povray.org>
> And then I see the YesShows album cover!   WooHoo!
> As jr would say, "I'm chuffed!"
> Yes is easily at the top of the list of my favorite bands of all time.

Unbelievable ! I didn't expected to find yesfun here, on 3D math forum. I am mad
about Yes and Roger Dean from schooldays and even trying to follow his style. My
dream-of-the-life is making full-format 3D animation by "Tales from Topographic
Oceans" with original music.

Although I am mastering ZBrush and Cinema4D, the amount of work is frightens me,
and I am stopped at simple 2D sprite animations:
https://yesbird.ru/

>
> I think a Yes themed POV-Ray render is going to have to be one of my next
> non-math doodles.
>

Making RD-like images with POV sound very interesting, may be some images from
my archive will inspire you for this feat:
https://drive.google.com/file/d/1jkq5-iT88QdkPPtHoOZztfcBuw-ku_3w/view?usp=sharing

Please keep me informed, I would like to see even intermediate results.


Post a reply to this message


Attachments:
Download 'talestopooriginal1920x1200.jpg' (900 KB)

Preview of image 'talestopooriginal1920x1200.jpg'
talestopooriginal1920x1200.jpg


 

From: Bald Eagle
Subject: Re: Mesh rendering artifacts
Date: 2 Feb 2023 06:35:00
Message: <web.63db9fc6249f00761f9dae3025979125@news.povray.org>
"yesbird" <nomail@nomail> wrote:
> > And then I see the YesShows album cover!   WooHoo!
> > As jr would say, "I'm chuffed!"
> > Yes is easily at the top of the list of my favorite bands of all time.
>
> Unbelievable ! I didn't expected to find yesfun here, on 3D math forum. I am mad
> about Yes and Roger Dean from schooldays and even trying to follow his style. My
> dream-of-the-life is making full-format 3D animation by "Tales from Topographic
> Oceans" with original music.

That would be sick.  I've listened to that album in its entirety countless
times.





https://www.dimensions-math.org/

https://www.chaos-math.org/en.html



I've made a few animations before - but an entire 2 hours done with nothing but
POV-Ray    :O


> Although I am mastering ZBrush and Cinema4D, the amount of work is frightens me,
> and I am stopped at simple 2D sprite animations:
> https://yesbird.ru/


Very cool.  You should check out Inigo Quilez of Shadertoy on YouTube and
Martijn Steinrucker (YT; Art of Code) - they both do some amazing graphics and
animation work starting from almost nothing.


Post a reply to this message

From: Bald Eagle
Subject: Re: Mesh rendering artifacts
Date: 2 Feb 2023 07:05:00
Message: <web.63dba67e249f00761f9dae3025979125@news.povray.org>
Hi Sergey,

"yesbird" <nomail@nomail> wrote:

> It was a serious investigation, so I am a little ashamed that my question forced
> you to do so much work.

Well, it was a challenge to figure out what to do, for sure.   I was sitting
there staring at 4,802 vector entries in OpenOffice, thinking "How the
Fu....nction am I going to figure out if all of the adjacencies match up...?"

And then I outlined the triangles, which were arranged in a different manner
than I had expected, and got the idea to slightly separate them, and then put
colored spheres on, but singce they'd overlap, I had to "shrink" the corner
vector in toward the center.
Then I thought that maybe there was some kind of color-averaging that gave a
middle-gray in the middle of the interpolation, so I put the spheres in the
centers and connected with lines -

which showed that the problem if the vertices, and nothing in a spreadsheet or
evaluating adjacencies would have revealed anything anomalous - it's definitely
something that I needed to see.

Anyway, it makes for a good rule of thumb - "always slice meshes parallel to the
texture gradient".  :)

> > _I think you can fix this by changing the axes that you're slicing along._
>
> Many thanks ! Now know where to look to fix it. In any case I decided to follow
> your suggestion and do all calculations in POV, passing only function or mesh,
> described surface, using yours and Tor's code, leaving present implementation as
> alternative.

Indeed.   I am a big fan of plenty of redundant options.

Just a few thoughts I had while cramming dirty pallet shrinkwrap into the
hydraulic compactor:

Matlab probably has a lot of routines that allow the user to manipulate
arbitrary data in ways that POV-Ray currently cannot.  Data that has no equation
that it's derived from.   Random points, measurement data, statistics, etc.

(It would be great of we had linear regression, and singular value decomposition
/ principal component analysis   ...   I'm working on it)

Also, I'm curious as to what a VERY large "3D" thing would look like in MatLab -
something that extends deep into the screen.  It likely uses simple raster
graphics - whereas POV-Ray does things in "actual 3D", so the farther away it
gets, the smaller it gets - until it's less than a single pixel wide/high.

One final thing that most might not consider as a pertinent issue:
POV-Ray is open source, which means that anything that gets done in "POV space"
is freely available to anyone, "forever".

Considering the state of the world and the censorship and deplatforming and
corporate hijinks going on, it might be best to preserve as much accessibilty to
the data and the ability to manipulate and render it as possible, purely for
those reasons.
When will Matlab get bought by the WEF or infiltrated by "them"?  You could lose
your Matlab license, they could change the code, change the interface, change
the output, write the output in binary, or proprietary encrypted format, or put
spyware into their code package such that you'd rather not use it anymore.

Laugh all you want, but...    I'll start working on that tin-foil texture.

> >THIS ONE!  THIS ONE!  :D
> >#declare V = array[4802][9] {
> >//  VERTEX1    NORMAL1   VERTEX2   NORMAL2    VERTEX3    NORMAL3   COLOR1
> COLOR2   COLOR3
>
> Sorry, I missed it, assumed, that macro code is transparent and hence structure
> is 'self-explained'.

It is, of course, but I stumble blindly through most of these projects and
usually need some sort of Braille guideposts.  :P

> > I would also suggest that you orient all of you stuff the way POV-Ray does -
> > with a left-handed coordinate system, +x to the right, +y as up, and +z going
> > into the screen and away from you.
>
> I only want to make it compatible with ML's defaults and render from the same
> viewpoint as it does.

Understood.   It's pretty typical to convert scenes modeled in Moray or other
software packages that have different coordinate systems to POV-Ray - usually
using a transform {} matrix on the scene or the camera.

When most everything is worked out and running, it probably won't be that big of
a deal, but for debugging sanity, it might be worth putting labeled axes in the
scene, and defining the transform matrix at the top of the scene, with a few
lines of comments describing exactly what it does and why it's there.


Happy rendering,

- Bill


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.