From 6ad716a57537104779b26b0bed89826a0a0f0888 Mon Sep 17 00:00:00 2001 From: Ryan McDonough Date: Thu, 12 Jan 2023 00:45:30 -0500 Subject: [PATCH] Update AfflictionLib.glsllib (#1905) This PR goes along with my last PR cleaning up the AdvancedPBRTerrain.j3md shader. The method getTriPlanarBlendFromTexArray() was put into this glsllib that contains all of the other commonly used functions for the pbr terrain shaders. --- .../Common/MatDefs/Terrain/AfflictionLib.glsllib | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AfflictionLib.glsllib b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AfflictionLib.glsllib index 8718cd3842..2c96614adb 100644 --- a/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AfflictionLib.glsllib +++ b/jme3-terrain/src/main/resources/Common/MatDefs/Terrain/AfflictionLib.glsllib @@ -11,6 +11,16 @@ vec4 getTriPlanarBlend(in vec4 coords, in vec3 blending, in sampler2D map, in fl return tex; } +vec4 getTriPlanarBlendFromTexArray(in vec4 coords, in vec3 blending, in int idInTexArray, in float scale, in sampler2DArray texArray) { + vec4 col1 = texture2DArray( texArray, vec3((coords.yz * scale), idInTexArray ) ); + vec4 col2 = texture2DArray( texArray, vec3((coords.xz * scale), idInTexArray ) ); + vec4 col3 = texture2DArray( texArray, vec3((coords.xy * scale), idInTexArray ) ); + // blend the results of the 3 planar projections. + vec4 tex = col1 * blending.x + col2 * blending.y + col3 * blending.z; + + return tex; +} + //used for mixing normal map normals with the world normals. texture slots without a normal map use wNormal as their blending value instead vec3 calculateTangentsAndApplyToNormals(in vec3 normalIn, in vec3 worldNorm){