mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 19:19:07 +00:00
Image maps working mostly
This commit is contained in:
@@ -97,7 +97,7 @@ public class IrisGeneratorStyle {
|
||||
{
|
||||
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D/zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
|
||||
if (fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
@@ -18,12 +18,16 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IrisImage extends IrisRegistrant {
|
||||
private BufferedImage image;
|
||||
@@ -125,4 +129,24 @@ public class IrisImage extends IrisRegistrant {
|
||||
public void scanForErrors(JSONObject p, VolmitSender sender) {
|
||||
|
||||
}
|
||||
|
||||
public void writeDebug(IrisImageChannel channel) {
|
||||
|
||||
|
||||
try {
|
||||
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
|
||||
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
for(int i = 0; i < getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < getHeight(); j++)
|
||||
{
|
||||
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB());
|
||||
}
|
||||
}
|
||||
ImageIO.write(b, "png", at);
|
||||
Iris.warn("Debug image written to " + at.getPath() + " for channel " + channel.name());
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.project.SchemaBuilder;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
@@ -43,7 +44,7 @@ import lombok.experimental.Accessors;
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents a carving configuration")
|
||||
@Desc("Represents an image map")
|
||||
@Data
|
||||
public class IrisImageMap {
|
||||
@RegistryListResource(IrisImage.class)
|
||||
@@ -69,11 +70,19 @@ public class IrisImageMap {
|
||||
@Desc("Center 0,0 to the center of the image instead of the top left.")
|
||||
private boolean centered = true;
|
||||
|
||||
private AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
|
||||
public double getNoise(IrisData data, int x, int z)
|
||||
{
|
||||
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
|
||||
IrisImage i = imageCache.aquire(() -> {
|
||||
IrisImage ii = data.getImageLoader().load(image);
|
||||
return ii;
|
||||
});
|
||||
if(i == null)
|
||||
{
|
||||
Iris.error("NULL IMAGE FOR " + image);
|
||||
}
|
||||
|
||||
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx,zz) -> rawNoise(i, xx, zz));
|
||||
}
|
||||
|
||||
@@ -85,7 +94,7 @@ public class IrisImageMap {
|
||||
z = isTiled() ? z % i.getHeight() : z;
|
||||
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;
|
||||
z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z;
|
||||
double v = i.getValue(getChannel(), (int)(x/coordinateScale), (int)(z/coordinateScale));
|
||||
double v = i.getValue(getChannel(), (int)x, (int)z);
|
||||
return isInverted() ? 1D - v : v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user