mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
Better iris noise rendering
This commit is contained in:
parent
846fa4722b
commit
f360fadd3f
@ -19,8 +19,10 @@
|
|||||||
package com.volmit.iris.core.command.studio;
|
package com.volmit.iris.core.command.studio;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
||||||
|
import com.volmit.iris.core.tools.IrisWorlds;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.plugin.Command;
|
import com.volmit.iris.util.plugin.Command;
|
||||||
import com.volmit.iris.util.plugin.MortarCommand;
|
import com.volmit.iris.util.plugin.MortarCommand;
|
||||||
|
@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
|
|||||||
import com.volmit.iris.core.IrisDataManager;
|
import com.volmit.iris.core.IrisDataManager;
|
||||||
import com.volmit.iris.core.IrisSettings;
|
import com.volmit.iris.core.IrisSettings;
|
||||||
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
import com.volmit.iris.core.gui.NoiseExplorerGUI;
|
||||||
|
import com.volmit.iris.core.tools.IrisWorlds;
|
||||||
import com.volmit.iris.engine.object.IrisGenerator;
|
import com.volmit.iris.engine.object.IrisGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
@ -38,7 +39,16 @@ public class CommandIrisStudioExplorerGenerator extends MortarCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
public void addTabOptions(VolmitSender sender, String[] args, KList<String> list) {
|
||||||
|
if ((args.length == 0 || args.length == 1) && sender.isPlayer() && IrisWorlds.isIrisWorld(sender.player().getWorld())) {
|
||||||
|
IrisDataManager data = IrisWorlds.access(sender.player().getWorld()).getData();
|
||||||
|
if (data == null) {
|
||||||
|
sender.sendMessage("Issue when loading tab completions. No data found (?)");
|
||||||
|
} else if(args.length == 0) {
|
||||||
|
list.add(data.getGeneratorLoader().getPossibleKeys());
|
||||||
|
}else if(args.length == 1) {
|
||||||
|
list.add(data.getGeneratorLoader().getPossibleKeys(args[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,8 +19,12 @@
|
|||||||
package com.volmit.iris.core.gui;
|
package com.volmit.iris.core.gui;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.engine.hunk.Hunk;
|
||||||
|
import com.volmit.iris.engine.hunk.storage.ArrayHunk;
|
||||||
import com.volmit.iris.engine.noise.CNG;
|
import com.volmit.iris.engine.noise.CNG;
|
||||||
import com.volmit.iris.engine.object.NoiseStyle;
|
import com.volmit.iris.engine.object.NoiseStyle;
|
||||||
|
import com.volmit.iris.engine.parallel.BurstExecutor;
|
||||||
|
import com.volmit.iris.engine.parallel.MultiBurst;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.function.Function2;
|
import com.volmit.iris.util.function.Function2;
|
||||||
import com.volmit.iris.util.math.M;
|
import com.volmit.iris.util.math.M;
|
||||||
@ -34,6 +38,7 @@ import javax.imageio.ImageIO;
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@ -44,7 +49,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
|
|||||||
|
|
||||||
static JComboBox<String> combo;
|
static JComboBox<String> combo;
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
RollingSequence r = new RollingSequence(90);
|
RollingSequence r = new RollingSequence(290);
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
boolean colorMode = true;
|
boolean colorMode = true;
|
||||||
double scale = 1;
|
double scale = 1;
|
||||||
@ -53,9 +58,9 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
|
|||||||
static double ascale = 10;
|
static double ascale = 10;
|
||||||
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
||||||
@SuppressWarnings("CanBeFinal")
|
@SuppressWarnings("CanBeFinal")
|
||||||
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY, "Iris Renderer");
|
MultiBurst gx = new MultiBurst("Iris Noise Renderer", Thread.MAX_PRIORITY, Runtime.getRuntime().availableProcessors());
|
||||||
ReentrantLock l = new ReentrantLock();
|
ReentrantLock l = new ReentrantLock();
|
||||||
int[][] co;
|
BufferedImage img;
|
||||||
int w = 0;
|
int w = 0;
|
||||||
int h = 0;
|
int h = 0;
|
||||||
Function2<Double, Double, Double> generator;
|
Function2<Double, Double, Double> generator;
|
||||||
@ -161,7 +166,7 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||||
int accuracy = hd ? 1 : M.clip((r.getAverage() / 6D), 1D, 128D).intValue();
|
int accuracy = hd ? 1 : M.clip((r.getAverage() / 12D), 2D, 128D).intValue();
|
||||||
accuracy = down ? accuracy * 4 : accuracy;
|
accuracy = down ? accuracy * 4 : accuracy;
|
||||||
int v = 1000;
|
int v = 1000;
|
||||||
|
|
||||||
@ -170,45 +175,41 @@ public class NoiseExplorerGUI extends JPanel implements MouseWheelListener {
|
|||||||
if (getParent().getWidth() != w || getParent().getHeight() != h) {
|
if (getParent().getWidth() != w || getParent().getHeight() != h) {
|
||||||
w = getParent().getWidth();
|
w = getParent().getWidth();
|
||||||
h = getParent().getHeight();
|
h = getParent().getHeight();
|
||||||
co = null;
|
img = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (co == null) {
|
if (img == null) {
|
||||||
co = new int[w][h];
|
img = new BufferedImage(w/accuracy, h/accuracy, BufferedImage.TYPE_INT_RGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < w; x += accuracy) {
|
BurstExecutor e = gx.burst(w);
|
||||||
|
|
||||||
|
for (int x = 0; x < w/accuracy; x ++) {
|
||||||
int xx = x;
|
int xx = x;
|
||||||
|
|
||||||
for (int z = 0; z < h; z += accuracy) {
|
int finalAccuracy = accuracy;
|
||||||
int zz = z;
|
e.queue(() -> {
|
||||||
gx.queue("a", () ->
|
for (int z = 0; z < h/finalAccuracy; z++) {
|
||||||
|
double n = generator != null ? generator.apply(((xx*finalAccuracy) * ascale) + oxp, ((z*finalAccuracy) * ascale) + ozp) : cng.noise(((xx*finalAccuracy) * ascale) + oxp, tz, ((z*finalAccuracy) * ascale) + ozp);
|
||||||
|
n = n > 1 ? 1 : n < 0 ? 0 : n;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
double n = generator != null ? generator.apply((xx * ascale) + oxp, (zz * ascale) + ozp) : cng.noise((xx * ascale) + oxp, tz, (zz * ascale) + ozp);
|
|
||||||
|
|
||||||
if (n > 1 || n < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Color color = colorMode ? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n), 1f - (float) n) : Color.getHSBColor(0f, 0f, (float) n);
|
Color color = colorMode ? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n), 1f - (float) n) : Color.getHSBColor(0f, 0f, (float) n);
|
||||||
int rgb = color.getRGB();
|
int rgb = color.getRGB();
|
||||||
co[xx][zz] = rgb;
|
img.setRGB(xx, z, rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Throwable xxx)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
gx.waitFor("a");
|
e.complete();
|
||||||
|
gg.drawImage(img, 0, 0, getParent().getWidth()*accuracy, getParent().getHeight()*accuracy, (img, infoflags, x, y, width, height) -> true);
|
||||||
if (hd && p.getMilliseconds() > v) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int x = 0; x < getParent().getWidth(); x += accuracy) {
|
|
||||||
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
|
||||||
gg.setColor(new Color(co[x][z]));
|
|
||||||
gg.fillRect(x, z, accuracy, accuracy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.end();
|
p.end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user