forked from EliCDavis/polyform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Screw operation takes UVs, new smooth normals implicit weld. New octr…
…ee functions, new potree functions + fixes, stl fixes
- Loading branch information
Showing
18 changed files
with
496 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package texturing | ||
|
||
import ( | ||
"image" | ||
"image/color" | ||
|
||
"github.com/EliCDavis/polyform/drawing/coloring" | ||
"github.com/EliCDavis/polyform/math/noise" | ||
"github.com/EliCDavis/polyform/nodes" | ||
) | ||
|
||
type SeamlessPerlinNode = nodes.StructNode[image.Image, SeamlessPerlinNodeData] | ||
|
||
type SeamlessPerlinNodeData struct { | ||
Positive nodes.NodeOutput[coloring.WebColor] | ||
Negative nodes.NodeOutput[coloring.WebColor] | ||
} | ||
|
||
func (an SeamlessPerlinNodeData) Process() (image.Image, error) { | ||
dim := 1024 | ||
img := image.NewRGBA(image.Rect(0, 0, dim, dim)) | ||
// normals.Fill(img) | ||
|
||
n := noise.NewTilingNoise(dim, 1/64., 5) | ||
|
||
nR, nG, nB, _ := an.Negative.Value().RGBA() | ||
pR, pG, pB, _ := an.Positive.Value().RGBA() | ||
|
||
rRange := float64(pR>>8) - float64(nR>>8) | ||
gRange := float64(pG>>8) - float64(nG>>8) | ||
bRange := float64(pB>>8) - float64(nB>>8) | ||
|
||
for x := 0; x < dim; x++ { | ||
for y := 0; y < dim; y++ { | ||
val := n.Noise(x, y) | ||
p := (val * 0.5) + 0.5 | ||
|
||
r := uint32(float64(nR) + (rRange * p)) | ||
g := uint32(float64(nG) + (gRange * p)) | ||
b := uint32(float64(nB) + (bRange * p)) | ||
|
||
img.Set(x, y, color.RGBA{ | ||
R: byte(r), // byte(len * 255), | ||
G: byte(g), | ||
B: byte(b), | ||
A: 255, | ||
}) | ||
} | ||
} | ||
return img, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package main | ||
|
||
import ( | ||
"image" | ||
"image/draw" | ||
|
||
"github.com/EliCDavis/polyform/drawing/coloring" | ||
"github.com/EliCDavis/polyform/nodes" | ||
"github.com/fogleman/gg" | ||
) | ||
|
||
type BrushedMetalNode = nodes.StructNode[image.Image, BrushedMetalNodeNodeData] | ||
|
||
type BrushedMetalNodeNodeData struct { | ||
Dimensions nodes.NodeOutput[int] | ||
BaseColor nodes.NodeOutput[coloring.WebColor] | ||
BrushColor nodes.NodeOutput[coloring.WebColor] | ||
BrushSize nodes.NodeOutput[float64] | ||
Count nodes.NodeOutput[int] | ||
} | ||
|
||
func (gnd BrushedMetalNodeNodeData) Process() (image.Image, error) { | ||
dimensions := 512 | ||
if gnd.Dimensions != nil { | ||
dimensions = gnd.Dimensions.Value() | ||
} | ||
img := image.NewRGBA(image.Rect(0, 0, dimensions, dimensions)) | ||
|
||
baseColor := coloring.Grey(200) | ||
if gnd.BaseColor != nil { | ||
baseColor = gnd.BaseColor.Value() | ||
} | ||
draw.Draw(img, img.Bounds(), &image.Uniform{baseColor}, image.Point{}, draw.Src) | ||
|
||
ctx := gg.NewContextForImage(img) | ||
|
||
lineWidth := 1. | ||
if gnd.BrushSize != nil { | ||
lineWidth = gnd.BrushSize.Value() | ||
} | ||
ctx.SetLineWidth(lineWidth) | ||
|
||
bruchColor := coloring.Grey(150) | ||
if gnd.BrushColor != nil { | ||
bruchColor = gnd.BrushColor.Value() | ||
} | ||
ctx.SetColor(bruchColor) | ||
|
||
horizontalLines := 10 | ||
if gnd.Count != nil { | ||
horizontalLines = gnd.Count.Value() | ||
} | ||
|
||
horizontalSpacing := float64(dimensions) / float64(horizontalLines) | ||
for i := 0; i < horizontalLines; i++ { | ||
y := (horizontalSpacing * float64(i)) + (horizontalSpacing / 2) | ||
ctx.DrawLine(0, y, float64(dimensions), y) | ||
} | ||
|
||
ctx.Stroke() | ||
|
||
return ctx.Image(), nil | ||
} |
Oops, something went wrong.