Comments (13)
I meant more in general. I haven’t worked with PBR materials before and have not yet looked into it. I don’t know what settings or lights you need to supply to make it look good. You have lights, lightprobes, environment maps, ... It’s still a bit unclear for me.
Ah, yes, I can help with this stuff.
You can read about PBR workflow in JME wiki:
https://wiki.jmonkeyengine.org/jme3/advanced/pbr_part1.html#
(it's in 3 parts)
In short, the light probe is the thing that contains environment map data. You can use a pre-generated light probe or generate your own light probe.
Then you can attach the light probe to the root node as you do for regular lights. (you can also add directional (if you want shadow or using have normal map on your models) and ambient light (for adjusting env map lighting i.e day/night lighting).
For generating a light probe you just need to attach a SkyBox into the scene and run this code:
Here is an example code of how to generate and export light probe into j3o:
public class LightProbExporter extends SimpleApplication {
private Timer makeProbeTimer;
@Override
public void simpleInitApp() {
initSky();
initLight();
}
@Override
public void simpleUpdate(float tpf) {
makeProbeTimer.update(tpf);
}
public static void main(String[] args) {
LightProbExporter app = new LightProbExporter();
app.start();
}
private void initLight() {
final EnvironmentCamera envCam = new EnvironmentCamera(256, Vector3f.ZERO);
stateManager.attach(envCam);
makeProbeTimer = new Timer();
makeProbeTimer.schedule(new TimerTask() {
@Override
public void run(long time) {
final LightProbe probe = LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class), rootNode, EnvMapUtils.GenerationType.Fast, new JobProgressAdapter<LightProbe>() {
@Override
public void done(LightProbe result) {
System.out.println("Done rendering env maps");
//Saving
Node probeNode = new Node("lightprobe node");
probeNode.addLight(result);
BinaryExporter ex = new BinaryExporter();
try {
ex.save(probeNode, new File("path to file/probe.j3o"));
System.out.println("Done exporting env maps");
} catch (IOException e) {
e.printStackTrace();
}
//done saving
}
});
((SphereProbeArea) probe.getArea()).setRadius(500);
rootNode.addLight(probe);
makeProbeTimer.setEnable(false);
}
}, 5);
}
private void initSky() {
/*Texture west = assetManager.loadTexture("envmap/fantasy/Sunny_01A_left.tga");
Texture east = assetManager.loadTexture("envmap/fantasy/Sunny_01A_right.tga");
Texture north = assetManager.loadTexture("envmap/fantasy/Sunny_01A_back.tga");
Texture south = assetManager.loadTexture("envmap/fantasy/Sunny_01A_front.tga");
Texture up = assetManager.loadTexture("envmap/fantasy/Sunny_01A_up.tga");
Texture down = assetManager.loadTexture("envmap/fantasy/Sunny_01A_down.tga");*/
//Spatial sky = SkyFactory.createSky(assetManager, west, east, north, south, up, down);
//Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", SkyFactory.EnvMapType.CubeMap);
Spatial sky = SkyFactory.createSky(assetManager, "Textures/sky/outside.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);
}
}
and load it like below:
Node probeNode = (Node) assetManager.loadModel("Scenes/lightprobe/probe.j3o");
LightProbe probe = (LightProbe) probeNode.getLocalLightList().iterator().next();
probe.setPosition(new Vector3f(0, 0, 0));
probe.getArea().setRadius(500);
rootNode.addLight(probe);
from blocks.
Regarding the material parameters, you have BaseColorMap, it's the same DiffuseMap we have in Phong lighting.
You can adjust the metalness of the material using the "Metallic" parameter. It's a float value in [0,1].
You can adjust the roughness of the material using the "Roughness" parameter. It's a float value in [0,1].
You can optionally use Normal and Parallex textures (same as Phong lighting) and MetallicRoughness map.
from blocks.
Awesome explanation, thanks! I’ll try to create an example with this info.
I hope to get this update released soon.
from blocks.
It does work with original PBRLighting material. Maybe something has broken while adapting it for water.
You were correct, there was an issue in the fragment shader, it's fixed.
from blocks.
Could you help me with creating a PBR water material @Ali-RS ? I made some changes to the TypeRegistry
(see #23) so it's possible to load custom materials for a block.
I would like to create a new example showcasing how you can use a PBR material as a type for a block. I guess a water block is an ideal example for this.
from blocks.
Could you help me with creating a PBR water material @Ali-RS ?
Do you mean you need help with the shader side?
tbh, I have not worked with shaders so I am not sure if I can be of any help.
If I am understanding it right, you just copied Lighting material frag and vert shaders and modified it for your water material, can't the same thing be done for PBR too?
from blocks.
I meant more in general. I haven’t worked with PBR materials before and have not yet looked into it. I don’t know what settings or lights you need to supply to make it look good. You have lights, lightprobes, environment maps, ... It’s still a bit unclear for me.
The shader part to simulate waves, I can adapt later.
from blocks.
Also, you can see some PBR examples here:
https://github.com/jMonkeyEngine/jmonkeyengine/tree/master/jme3-examples/src/main/java/jme3test/light/pbr
And here are some pre-generated light probes:
lightprobes.zip
Please feel free to ask if you have any questions.
from blocks.
You're welcome.
btw, in case you need, here you can download a free water texture:
https://lowlypoly.com/collections/free/products/stylized-water-texture
Some useful tips:
-
For an emissive map to work in PBR you need to set up the bloom filter to
GlowMode.Scene
bloom = new BloomFilter(BloomFilter.GlowMode.Scene);
-
https://hub.jmonkeyengine.org/t/pbr-height-and-ambient-occlusion/39759
(Parallax maping result is just ugly IMO ;)
from blocks.
@rvandoosselaer I forgot to mention that you also need to add this in simpleInitApp()
:
// Configure the scene for PBR
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePassAndImageBased);
renderManager.setSinglePassLightBatchSize(10);
from blocks.
I committed a PBR test case in the examples subproject.
If you have remarks or improvements please let me know.
Will test some more myself (still need to test with a ‘spritesheet’ texture) and begin preparing for a release.
I did notice that the parallax mapping doesn’t appear to be working.
from blocks.
Thanks, going to try it soon :)
from blocks.
Just tried it, looks very nice :)
I did notice that the parallax mapping doesn’t appear to be working.
It does work with original PBRLighting material. Maybe something has broken while adapting it for water.
from blocks.
Related Issues (20)
- Update AppSettings on examples
- Create a FluidFilterDebug state
- Chunk should have a public constructor so that it supports inheritance HOT 3
- Chunk.createNode() crashes with an internal error HOT 3
- What's the best way to store block states? HOT 2
- prioritize chunkmanager queue's
- BlocksConfig.setShapeRegistry() doesn't update the chunk mesh generator. [version 1.5.1] HOT 2
- All the blocks in a Chunk become the placed block HOT 2
- Add GSON support HOT 1
- Toon foam effect HOT 1
- Issue in class file, which is not present in github code. HOT 6
- Disable default blocks, shapes and types registeration HOT 5
- Both package services have shut down HOT 3
- Add debug grid
- Update wiki and jmonkey store
- Add cylinder block HOT 1
- Use Sio2 com.simsilica.thread.* classes for handling job work HOT 3
- Create liquid implementation
- Sub-blocks / Micro-blocks HOT 3
- getChunk method HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blocks.