Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ varying vec3 wPosition;
#endif

#ifdef EMISSIVE
uniform vec4 m_Emissive;
uniform vec4 m_Emissive;
#endif
#ifdef EMISSIVEMAP
uniform sampler2D m_EmissiveMap;
uniform sampler2D m_EmissiveMap;
#endif
#if defined(EMISSIVE) || defined(EMISSIVEMAP)
uniform float m_EmissivePower;
Expand Down Expand Up @@ -91,7 +91,11 @@ varying vec3 wPosition;
varying vec3 wNormal;

#ifdef DISCARD_ALPHA
uniform float m_AlphaDiscardThreshold;
uniform float m_AlphaDiscardThreshold;
#endif

#ifdef AMBIENT_COLOR
uniform vec4 m_AmbientColor;
#endif

void main(){
Expand Down Expand Up @@ -273,7 +277,7 @@ void main(){
float ndf3 = renderProbe(viewDir, wPosition, normal, norm, Roughness, diffuseColor, specularColor, ndotv, ao, g_LightProbeData3, g_ShCoeffs3, g_PrefEnvMap3, color3);
#endif

#if NB_PROBES >= 2
#if NB_PROBES >= 2
float invNdf = max(1.0 - ndf,0.0);
float invNdf2 = max(1.0 - ndf2,0.0);
float sumNdf = ndf + ndf2;
Expand All @@ -294,6 +298,12 @@ void main(){
weight2 /= weightSum;
weight3 /= weightSum;
#endif

#ifdef AMBIENT_COLOR
color1.rgb *= m_AmbientColor.rgb;
color2.rgb *= m_AmbientColor.rgb;
color3.rgb *= m_AmbientColor.rgb;
#endif
gl_FragColor.rgb += color1 * clamp(weight1,0.0,1.0) + color2 * clamp(weight2,0.0,1.0) + color3 * clamp(weight3,0.0,1.0);

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ MaterialDef PBR Lighting {
Boolean UseVertexColor

Boolean BackfaceShadows : false

//the ambient color
Color AmbientColor
}

Technique {
Expand Down Expand Up @@ -161,6 +164,7 @@ MaterialDef PBR Lighting {
NUM_MORPH_TARGETS: NumberOfMorphTargets
NUM_TARGETS_BUFFERS: NumberOfTargetsBuffers
HORIZON_FADE: HorizonFade
AMBIENT_COLOR : AmbientColor
}
}

Expand Down