YOUR ACCOUNT

Login or Register to post new topics or replies
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Triangulation Script, initial study.

The only problem is that some lines are crossing over others, need some code to select the better (non-overlapping) of the two possible connections.

  Details E-Mail
Skybase
2D/3D Generalist

Posts: 4025
Filters: 76
Can you explain the magic in pseudo code?
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Sure. (Actually, I'll just explain it in English.)

I start with a straight square grid, the white points are initially on the crossing points. The x- and y-offsets of the white points of the grid are derived fr om perlin noise values, but they still remain within their own squares, ie. no point can go past another one vertically or horizontally. Then I draw the connecting lines, and alternating diagonal connecting lines (every other line is flipped).

The clearest explanation would be this image wh ere I turned the perlin contrast down:

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
The basic reason for this approach: No need for tables, the points are all derived procedurally, so I can do this with no significant loss in speed:

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Once I get the check-whether-a-point-is-inside-a-triangle part of the code working, I can get rid of the overlaps and start doing various fills between the lines.
  Details E-Mail
Crapadilla
lvl 52 Filter Weaver and Official "Filter Forge Seer"

Posts: 4365
Filters: 65
Quote
Once I get the check-whether-a-point-is-inside-a-triangle part of the code working


http://totologic.blogspot.fr/2014/01/...-test.html

Would this be of any help?

I've used the barycentric method for a custom "Free Triangle" component. Worked like a charm. smile:)
--- Crapadilla says: "Damn you, stupid redundant feature requests!" ;)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Hi Crapadilla,

Thanks. Yes, that's the method I'm using. For some reason didn't get it to work properly yet, probably just something simple I've missed.

TD
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Alright, some progress. Picking the color of the cell from image, average of the three corner values:

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
A plexus-like derivative thereof.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Tempted to do this with a table instead. Would give more freedom in placing the points. Probably be way faster too, especially when the point count is relatively low.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
So -- started to construct the same with a table...

Getting it to wrap properly was tricky enough.

  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
One significant advantage in keeping the dots constrained inside their respective grid "cells" is that you know exactly what dot is in which area and don't have to iterate through all dots to find the closest one to a given point. This makes rendering pretty efficient. So far, at least.
  Details E-Mail
Crapadilla
lvl 52 Filter Weaver and Official "Filter Forge Seer"

Posts: 4365
Filters: 65
Quote
Picking the color of the cell from image, average of the three corner values


Nice!

Barycentric gradient shading in the works? smile;)
--- Crapadilla says: "Damn you, stupid redundant feature requests!" ;)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
Barycentric gradient shading in the works?


Naturally smile:D
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Speaking of "naturally", I just realized that the direction in which the rectangular shapes should be divided should be based on the Delaunay method, ie. splitting the rectangle into two triangles by cutting it between those two opposite corners the angles of which total more than 180 degrees. Naturally.

Resulting in a sort of semi-Delaunay triangulation.
  Details E-Mail
Crapadilla
lvl 52 Filter Weaver and Official "Filter Forge Seer"

Posts: 4365
Filters: 65
To avoid those very long/thin triangles, I gather?
--- Crapadilla says: "Damn you, stupid redundant feature requests!" ;)
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Come to think of it, the current version (before splitting the rectangles into triangles) is already a good basis for a new noise type of "Rectangulation". With suitable shading, it would be a new basic noise type that is different from the built-in noises.
  Details E-Mail
ThreeDee
Lost in Space

Posts: 1672
Filters: 112
Quote
To avoid those very long/thin triangles, I gather?


Well, the method pretty much already takes care of that, since no point moves outside its own square domain, but essentially yes, it would always be the "fatter" triangulation of the two options. Also, the Delaunay condition ensures that no concave rectangles are split in the wrong direction -- the wrong direction results in lines outside the shape rather than two triangles, like those that can be seen in my first image.

  Details E-Mail
CFandM
ForgeSmith

Posts: 4761
Filters: 266
Looking very, very interesting... smile:) smile:hammer:
Stupid things happen to computers for stupid reasons at stupid times!
  Details E-Mail
Sphinx.
Filter Optimizer

Posts: 1750
Filters: 39
  Details E-Mail

Join Our Community!

Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!

33,711 Registered Users
+18 new in 30 days!

153,533 Posts
+38 new in 30 days!

15,348 Topics
+73 new in year!

Create an Account

Online Users Last minute:

20 unregistered users.