本文整理汇总了Java中com.jme3.terrain.noise.ShaderUtils类的典型用法代码示例。如果您正苦于以下问题:Java ShaderUtils类的具体用法?Java ShaderUtils怎么用?Java ShaderUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShaderUtils类属于com.jme3.terrain.noise包,在下文中一共展示了ShaderUtils类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createFractalGenerator
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
private Basis createFractalGenerator() {
final FractalSum fractalSum = new FractalSum();
fractalSum.setRoughness(getRoughness());
fractalSum.setFrequency(getFrequency());
fractalSum.setAmplitude(getBrushPower());
fractalSum.setLacunarity(getLacunarity()); // make it greater than 1.0f
fractalSum.setOctaves(getOctaves());
fractalSum.setScale(max(min(getScale(), 1.0F), 0F)); //0.02125f
fractalSum.addModulator((NoiseModulator) in -> ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1));
final FilteredBasis ground = new FilteredBasis(fractalSum);
final PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.2f);//0.119 the higher, the slower it is
final OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
final SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.1f); // 0.7
final IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:35,代码来源:RoughTerrainToolControl.java
示例2: createNoiseGenerator
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
private FilteredBasis createNoiseGenerator()
{
FractalSum base = new FractalSum();
base.setRoughness(0.7f);
base.setFrequency(1.0f);
base.setAmplitude(1.0f);
base.setLacunarity(3.12f);
base.setOctaves(8);
base.setScale(0.02125f);
base.addModulator(new NoiseModulator()
{
@Override public float value(float... in)
{
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.119f);
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.7f);
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:jayfella,项目名称:World,代码行数:40,代码来源:Example_NoiseHeightMap.java
示例3: value
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
@Override
public float value(final float x, final float y, final float z) {
float total = 0;
for (float f = this.frequency, a = this.amplitude; f < this.maxFreq; f *= this.lacunarity, a *= this.roughness) {
total += this.basis.value(this.scale * x * f, this.scale * y * f, this.scale * z * f) * a;
}
return ShaderUtils.clamp(total, -1, 1);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:11,代码来源:FractalSum.java
示例4: value
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
@Override
public float value(final float... in) {
if (in[0] >= 4) {
return 0;
}
in[0] = in[0] * this.sampleRate + 0.5f;
int i = ShaderUtils.floor(in[0]);
if (i >= 4 * this.sampleRate + 1) {
return 0;
}
return this.table[i];
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:13,代码来源:CatRom2.java
示例5: noise
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
static public float noise(float x, float y, float z) {
int X = ShaderUtils.floor(x), // FIND UNIT CUBE THAT
Y = ShaderUtils.floor(y), // CONTAINS POINT.
Z = ShaderUtils.floor(z);
x -= X; // FIND RELATIVE X,Y,Z
y -= Y; // OF POINT IN CUBE.
z -= Z;
X = X & 255;
Y = Y & 255;
Z = Z & 255;
float u = ImprovedNoise.fade(x), // COMPUTE FADE CURVES
v = ImprovedNoise.fade(y), // FOR EACH OF X,Y,Z.
w = ImprovedNoise.fade(z);
int A = ImprovedNoise.p[X] + Y;
int AA = ImprovedNoise.p[A] + Z;
int AB = ImprovedNoise.p[A + 1] + Z;
int B = ImprovedNoise.p[X + 1] + Y;
int BA = ImprovedNoise.p[B] + Z;
int BB = ImprovedNoise.p[B + 1] + Z;
return ImprovedNoise.lerp(
w,
ImprovedNoise.lerp(
v,
ImprovedNoise.lerp(u, ImprovedNoise.grad3(ImprovedNoise.p[AA], x, y, z),
ImprovedNoise.grad3(ImprovedNoise.p[BA], x - 1, y, z)), // BLENDED
ImprovedNoise.lerp(u, ImprovedNoise.grad3(ImprovedNoise.p[AB], x, y - 1, z), // RESULTS
ImprovedNoise.grad3(ImprovedNoise.p[BB], x - 1, y - 1, z))),// FROM
ImprovedNoise.lerp(v,
ImprovedNoise.lerp(u, ImprovedNoise.grad3(ImprovedNoise.p[AA + 1], x, y, z - 1), // CORNERS
ImprovedNoise.grad3(ImprovedNoise.p[BA + 1], x - 1, y, z - 1)), // OF
ImprovedNoise.lerp(u, ImprovedNoise.grad3(ImprovedNoise.p[AB + 1], x, y - 1, z - 1),
ImprovedNoise.grad3(ImprovedNoise.p[BB + 1], x - 1, y - 1, z - 1))));
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:35,代码来源:ImprovedNoise.java
示例6: filter
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
@Override
public FloatBuffer filter(float sx, float sy, float base, FloatBuffer data, int workSize) {
float[] arr = data.array();
int origSize = (int) Math.ceil(workSize / (2 * this.magnitude + 1));
int offset = (workSize - origSize) / 2;
Logger.getLogger(PerturbFilter.class.getCanonicalName()).info(
"Found origSize : " + origSize + " and offset: " + offset + " for workSize : " + workSize + " and magnitude : "
+ this.magnitude);
float[] retval = new float[workSize * workSize];
float[] perturbx = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base, workSize).array();
float[] perturby = new FractalSum().setOctaves(8).setScale(5f).getBuffer(sx, sy, base + 1, workSize).array();
for (int y = 0; y < workSize; y++) {
for (int x = 0; x < workSize; x++) {
// Perturb our coordinates
float noisex = perturbx[y * workSize + x];
float noisey = perturby[y * workSize + x];
int px = (int) (origSize * noisex * this.magnitude);
int py = (int) (origSize * noisey * this.magnitude);
float c00 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x - px, workSize)];
float c01 = arr[this.wrap(y - py, workSize) * workSize + this.wrap(x + px, workSize)];
float c10 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x - px, workSize)];
float c11 = arr[this.wrap(y + py, workSize) * workSize + this.wrap(x + px, workSize)];
float c0 = ShaderUtils.mix(c00, c01, noisex);
float c1 = ShaderUtils.mix(c10, c11, noisex);
retval[y * workSize + x] = ShaderUtils.mix(c0, c1, noisey);
}
}
return FloatBuffer.wrap(retval);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:PerturbFilter.java
示例7: createFractalGenerator
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
private Basis createFractalGenerator(RoughExtraToolParams params, float weight) {
FractalSum base = new FractalSum();
base.setRoughness(params.roughness);
base.setFrequency(params.frequency);
base.setAmplitude(weight);
base.setLacunarity(params.lacunarity <= 1 ? 1.1f : params.lacunarity); // make it greater than 1.0f
base.setOctaves(params.octaves);
float scale = params.scale;
if (scale > 1.0f)
scale = 1.0f;
if (scale < 0)
scale = 0;
base.setScale(scale);//0.02125f
base.addModulator(new NoiseModulator() {
@Override
public float value(float... in) {
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.2f);//0.119 the higher, the slower it is
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.1f); // 0.7
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
return ground;
}
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:44,代码来源:RoughTerrainToolAction.java
示例8: createWorldWithNoise
import com.jme3.terrain.noise.ShaderUtils; //导入依赖的package包/类
private void createWorldWithNoise()
{
NoiseBasedWorld newWorld = new NoiseBasedWorld(app, bulletAppState.getPhysicsSpace(), tileSize, blockSize);
newWorld.setWorldHeight(192f);
newWorld.setViewDistance(2);
// newWorld.setViewDistance(14, 1, 2, 1);
newWorld.setCacheTime(5000);
Material terrainMaterial = createTerrainMaterial();
newWorld.setMaterial(terrainMaterial);
// create a noise generator
FractalSum base = new FractalSum();
base.setRoughness(0.7f);
base.setFrequency(1.0f);
base.setAmplitude(1.0f);
base.setLacunarity(3.12f);
base.setOctaves(8);
base.setScale(0.02125f);
base.addModulator(new NoiseModulator()
{
@Override
public float value(float... in) {
return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);
}
});
FilteredBasis ground = new FilteredBasis(base);
PerturbFilter perturb = new PerturbFilter();
perturb.setMagnitude(0.119f);
OptimizedErode therm = new OptimizedErode();
therm.setRadius(5);
therm.setTalus(0.011f);
SmoothFilter smooth = new SmoothFilter();
smooth.setRadius(1);
smooth.setEffect(0.7f);
IterativeFilter iterate = new IterativeFilter();
iterate.addPreFilter(perturb);
iterate.addPostFilter(smooth);
iterate.setFilter(therm);
iterate.setIterations(1);
ground.addPreFilter(iterate);
newWorld.setFilteredBasis(ground);
this.world = newWorld;
}
开发者ID:jayfella,项目名称:TerrainWorld,代码行数:57,代码来源:Main.java
注:本文中的com.jme3.terrain.noise.ShaderUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论