Blocks

@remy_vd I tried PBR water with this 1 x 8 tiled texture (512 x 4096):

Here is how material looks like:

Material water-pbr : Blocks/MatDefs/Water-pbr.j3md {

    MaterialParameters {
        // PBR
        Metallic: 0
        Roughness: 1
        BaseColor: 1.0 1.0 1.0 0.7
        BaseColorMap: water-pbr/water-tile.jpg

        // custom
        WaveSpeed : 1.5
        WaveHeight : 0.05
        WaveSize : 10
        TextureScrollSpeed : 10
        numTilesX : 1
        numTilesY : 8
        OffsetY: -0.1
    }

    AdditionalRenderState {
        Blend Alpha
    }
}

But it seems texture does not scroll at all.

Note, when I set numTilesY to something other than 8 then I can see texture is scrolling.

Will appreciate if you can take a look at it.

Thanks

Hi @Ali_RS,

Iā€™ll take a look at it this afternoon.

1 Like

Thank you. :slightly_smiling_face:

Never mind, now I see why this is happening. :man_facepalming:
All the 8 tiles in texture look just the same.

1 Like

That would explain a lot :wink:

Ok, added these lines into vertex shader and made a moving water effect. :slightly_smiling_face:

texCoordAni.x = (float(texCoordAni.x + tileDistance));
texCoordAni.y = (float(texCoordAni.y + tileDistance));

Also needed to set wrapping to WrapRepeat_S WrapRepeat_T in material:

        BaseColorMap: WrapRepeat_S WrapRepeat_T water-pbr/water_base_color.png
        NormalMap: WrapRepeat_S WrapRepeat_T water-pbr/water_normal.png
        RoughnessMap: WrapRepeat_S WrapRepeat_T water-pbr/water_roughness.png
        ParallaxMap: WrapRepeat_S WrapRepeat_T water-pbr/water_parallax.png
        EmissiveMap: WrapRepeat_S WrapRepeat_T water-pbr/water_emissive.png

Thought you may like to include a similar approach in addition to scrolling approach or even replace with it. This should work fine for seamless textures.

Thanks, Iā€™ll look into it.
Could you post a screenshot or animated gif? Iā€™m always looking for ā€˜actionā€™ screens of people using blocks :wink:

1 Like

Here you are

Before:

After:

I will upload some cool screenshots and videos in the coming days. :slightly_smiling_face:

3 Likes

Nice one! The moving texture is indeed much better.

I added a new Fluid-pbr material definition that can be used to simulate fluid blocks. This material supports waves and texture scrolling instead of the spritesheet approach of the Water-pbr material.

In the following releases the Water and Water-pbr material will become deprecated and be removed at one point.

All is available in the new version v1.4.2.

1 Like

Thanks :slightly_smiling_face:

A minor issue with the water block. Thought you might know what might be the reason.

With large scales, blocks go out of sync on chunk edges. (I am using block scale=3)

Note issue is happening only on the edge of chunks and looks Ok inside of the chunk.

Hm, could be because they are separate geometries thus g_Time goes slowly difference from one chunk to another chunk?

Yes, Iā€™m aware of the issue. But I donā€™t think it has anything to do with the block scale though.
There is a slight deviation from one of the params in the function in the shader, didnā€™t look into it yet :slight_smile:

1 Like

@remy_vd does FileRepository support loading chunks from the class path?
I am planning to put chunks data inside assets.jar (as they are not supposed to be updated at runtime) under the assets/Scenes/[scene name]/chunks.

Hi @Ali_RS,

The FileRepository implementation is based around a java Path and is meant for loading and storing chunks on the filesystem using protobuf.

I guess you can use a classloader and hack around this:

String path = this.getClass().getClassLoader().getResource(<resourceFileName>).toExternalForm();

And wrap the resulting string using a Paths.get() and pass this to the FileRepository. This is all top of my head by the way.

But when you try to use this repository to save chunks to this path (in the assets jar) it will fail.

In your case I would write a ChunkClassLoader that implements the ChunkRepository and only implement the #load() method. You can even use the assetmanager to load chunks.

1 Like

Thank you, will try it out.

Yeah, good idea. Thanks

1 Like

A new version of Blocks is released. Blocks v1.5.0 is pushed to bintray and is available on the jmonkeystore.

Whatā€™s new in this release:

  • upgraded Minie to v1.6
  • use vertex lighting in default block materials
  • added new Fluid materials in favour of the removed deprecated water materials.
  • added a FluidDepthFilter to better simulate fluids in the scene

The complete release notes can be found on github.

A screenshot and video of the PhysicsScene example application:

The ā€˜shorelineā€™ effect of the filter works really well to see the difference between objects above and below water.

12 Likes

The filter looks really cool, great job. :slightly_smiling_face:
And thanks for the new release.

1 Like

What documentation is there for writing custom shapes? I couldnā€™t find much on the GitHub wiki.