File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed
jme3-core/src/main/resources/Common/MatDefs/Light
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,10 @@ varying vec3 wPosition;
84
84
#ifdef LIGHTMAP
85
85
uniform sampler2D m_LightMap;
86
86
#endif
87
+
88
+ #ifdef AO_STRENGTH
89
+ uniform float m_AoStrength;
90
+ #endif
87
91
88
92
#if defined(NORMALMAP) || defined(PARALLAXMAP)
89
93
uniform sampler2D m_NormalMap;
@@ -237,6 +241,12 @@ void main(){
237
241
ao = aoRoughnessMetallicValue.rrr;
238
242
#endif
239
243
244
+ #ifdef AO_STRENGTH
245
+ ao = 1.0 + m_AoStrength * (ao - 1.0 );
246
+ // sanity check
247
+ ao = clamp (ao, 0.0 , 1.0 );
248
+ #endif
249
+
240
250
float ndotv = max ( dot ( normal, viewDir ),0.0 );
241
251
for ( int i = 0 ;i < NB_LIGHTS; i+= 3 ){
242
252
vec4 lightColor = g_LightData[i];
Original file line number Diff line number Diff line change @@ -70,6 +70,10 @@ MaterialDef PBR Lighting {
70
70
// Set to Use Lightmap
71
71
Texture2D LightMap
72
72
73
+ // A scalar multiplier controlling the amount of occlusion applied.
74
+ // A value of `0.0` means no occlusion. A value of `1.0` means full occlusion.
75
+ Float AoStrength
76
+
73
77
// Set to use TexCoord2 for the lightmap sampling
74
78
Boolean SeparateTexCoord
75
79
// the light map is a grayscale ao map, only the r channel will be read.
@@ -162,6 +166,7 @@ MaterialDef PBR Lighting {
162
166
VERTEX_COLOR : UseVertexColor
163
167
AO_MAP: LightMapAsAOMap
164
168
AO_PACKED_IN_MR_MAP : AoPackedInMRMap
169
+ AO_STRENGTH : AoStrength
165
170
NUM_MORPH_TARGETS: NumberOfMorphTargets
166
171
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
167
172
HORIZON_FADE: HorizonFade
Original file line number Diff line number Diff line change @@ -673,6 +673,12 @@ public Material readMaterial(int materialIndex) throws IOException {
673
673
} else {
674
674
adapter .setParam ("occlusionTexture" , readTexture (matData .getAsJsonObject ("occlusionTexture" )));
675
675
}
676
+
677
+ Float occlusionStrength = occlusionJson != null ? getAsFloat (occlusionJson , "strength" ) : null ;
678
+ if (occlusionStrength != null ) {
679
+ adapter .setParam ("occlusionStrength" , occlusionStrength );
680
+ }
681
+
676
682
adapter .setParam ("emissiveTexture" , readTexture (matData .getAsJsonObject ("emissiveTexture" )));
677
683
678
684
return adapter .getMaterial ();
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ public PBRMaterialAdapter() {
42
42
addParamMapping ("normalTexture" , "NormalMap" );
43
43
addParamMapping ("normalScale" , "NormalScale" );
44
44
addParamMapping ("occlusionTexture" , "LightMap" );
45
+ addParamMapping ("occlusionStrength" , "AoStrength" );
45
46
addParamMapping ("emissiveTexture" , "EmissiveMap" );
46
47
addParamMapping ("emissiveFactor" , "Emissive" );
47
48
addParamMapping ("alphaMode" , "alpha" );
You can’t perform that action at this time.
0 commit comments