diff --git a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java index 2c071ae03..06482f21f 100644 --- a/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java +++ b/jme3-core/src/main/java/com/jme3/post/HDRRenderer.java @@ -47,6 +47,10 @@ import com.jme3.ui.Picture; import java.util.Collection; import java.util.logging.Logger; +/** + * @deprecated use the ToneMappingFilter. + */ +@Deprecated public class HDRRenderer implements SceneProcessor { private static final int LUMMODE_NONE = 0x1, diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.frag b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.frag index 38264273a..5c1cca842 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass uniform float m_Size; uniform float m_Scale; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md index fb5d3808a..7c5fddeb6 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/HGaussianBlur.j3md @@ -1,4 +1,4 @@ -MaterialDef Bloom { +MaterialDef HGaussianBlur { MaterialParameters { Int NumSamples @@ -8,8 +8,8 @@ MaterialDef Bloom { } Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: Common/MatDefs/Blur/HGaussianBlur.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Blur/HGaussianBlur.frag WorldParameters { } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.frag b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.frag index b3adfd425..a0d27b7bb 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.frag @@ -1,7 +1,11 @@ -uniform sampler2D m_Texture; +#import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/MultiSample.glsllib" + +uniform COLORTEXTURE m_Texture; uniform float m_SampleDist; uniform float m_SampleStrength; uniform float m_Samples[10]; + varying vec2 texCoord; void main(void) @@ -22,15 +26,14 @@ void main(void) // this is the original colour of this fragment // using only this would result in a nonblurred version - vec4 colorRes = texture2D(m_Texture,texCoord); + vec4 colorRes = getColor(m_Texture,texCoord); vec4 sum = colorRes; // take 10 additional blur samples in the direction towards // the center of the screen - for (int i = 0; i < 10; i++) - { - sum += texture2D( m_Texture, texCoord + dir * m_Samples[i] * m_SampleDist ); + for (int i = 0; i < 10; i++){ + sum += getColor( m_Texture, texCoord + dir * m_Samples[i] * m_SampleDist ); } // we have taken eleven samples @@ -42,6 +45,6 @@ void main(void) t = clamp( t ,0.0,1.0); //0 <= t <= 1 //Blend the original color with the averaged pixels - gl_FragColor =mix( colorRes, sum, t ); + gl_FragColor = mix( colorRes, sum, t ); } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md index 048cd9c7f..e40992696 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur.j3md @@ -10,8 +10,8 @@ MaterialDef Radial Blur { } Technique { - VertexShader GLSL150: Common/MatDefs/Post/Post15.vert - FragmentShader GLSL150: Common/MatDefs/Blur/RadialBlur15.frag + VertexShader GLSL120 GLSL150: Common/MatDefs/Post/Post.vert + FragmentShader GLSL120 GLSL150: Common/MatDefs/Blur/RadialBlur.frag WorldParameters { } @@ -20,12 +20,4 @@ MaterialDef Radial Blur { RESOLVE_MS : NumSamples } } - - Technique { - VertexShader GLSL120: Common/MatDefs/Post/Post.vert - FragmentShader GLSL120: Common/MatDefs/Blur/RadialBlur.frag - - WorldParameters { - } - } } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur15.frag b/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur15.frag deleted file mode 100644 index cc403501b..000000000 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/RadialBlur15.frag +++ /dev/null @@ -1,50 +0,0 @@ -#import "Common/ShaderLib/MultiSample.glsllib" - -uniform COLORTEXTURE m_Texture; -uniform float m_SampleDist; -uniform float m_SampleStrength; -uniform float m_Samples[10]; - -in vec2 texCoord; -out vec4 outFragColor; - -void main(void) -{ - // some sample positions - //float samples[10] = float[](-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08); - - // 0.5,0.5 is the center of the screen - // so substracting texCoord from it will result in - // a vector pointing to the middle of the screen - vec2 dir = 0.5 - texCoord; - - // calculate the distance to the center of the screen - float dist = sqrt(dir.x*dir.x + dir.y*dir.y); - - // normalize the direction (reuse the distance) - dir = dir/dist; - - // this is the original colour of this fragment - // using only this would result in a nonblurred version - vec4 colorRes = getColor(m_Texture,texCoord); - - vec4 sum = colorRes; - - // take 10 additional blur samples in the direction towards - // the center of the screen - for (int i = 0; i < 10; i++){ - sum += getColor( m_Texture, texCoord + dir * m_Samples[i] * m_SampleDist ); - } - - // we have taken eleven samples - sum *= 1.0/11.0; - - // weighten the blur effect with the distance to the - // center of the screen ( further out is blurred more) - float t = dist * m_SampleStrength; - t = clamp( t ,0.0,1.0); //0 <= t <= 1 - - //Blend the original color with the averaged pixels - outFragColor =mix( colorRes, sum, t ); - -} \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.frag b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.frag index b8f13a8a4..5f970379d 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform sampler2D m_Texture; // this should hold the texture rendered by the horizontal blur pass uniform float m_Size; uniform float m_Scale; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md index 78f0c7fa8..68e5d15ba 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Blur/VGaussianBlur.j3md @@ -1,4 +1,4 @@ -MaterialDef Bloom { +MaterialDef VGaussianBlur { MaterialParameters { Int NumSamples @@ -8,8 +8,8 @@ MaterialDef Bloom { } Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: Common/MatDefs/Blur/VGaussianBlur.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Blur/VGaussianBlur.frag WorldParameters { } diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md index 8e0b8d089..6983bfb0a 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Deferred.j3md @@ -1,3 +1,4 @@ +//Don't use this MaterialDef Phong Lighting Deferred { MaterialParameters { diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Glow.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/Glow.frag index a18a22809..f12478950 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Glow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Glow.frag @@ -1,4 +1,4 @@ - +#import "Common/ShaderLib/GLSLCompat.glsllib" #if defined(NEED_TEXCOORD1) varying vec2 texCoord1; #else diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag index 0aa4d3f36..9b8aa2709 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Parallax.glsllib" #import "Common/ShaderLib/Optics.glsllib" #ifndef VERTEX_LIGHTING diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md index 39ff01cbb..bc699e6b1 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.j3md @@ -120,8 +120,8 @@ MaterialDef Phong Lighting { Technique { LightMode SinglePass - VertexShader GLSL100: Common/MatDefs/Light/SPLighting.vert - FragmentShader GLSL100: Common/MatDefs/Light/SPLighting.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/SPLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -159,8 +159,8 @@ MaterialDef Phong Lighting { LightMode MultiPass - VertexShader GLSL100: Common/MatDefs/Light/Lighting.vert - FragmentShader GLSL100: Common/MatDefs/Light/Lighting.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Lighting.frag WorldParameters { WorldViewProjectionMatrix @@ -194,12 +194,10 @@ MaterialDef Phong Lighting { } } - - Technique PreShadow { - VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -226,8 +224,8 @@ MaterialDef Phong Lighting { Technique PostShadow { - VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -258,43 +256,11 @@ MaterialDef Phong Lighting { } } - Technique PostShadow{ - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldMatrix - ViewProjectionMatrix - ViewMatrix - NormalMatrix - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - DISCARD_ALPHA : AlphaDiscardThreshold - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - NUM_BONES : NumberOfBones - INSTANCING : UseInstancing - BACKFACE_SHADOWS: BackfaceShadows - } - - ForcedRenderState { - Blend Modulate - DepthWrite Off - PolyOffset -0.1 0 - } - } Technique PreNormalPass { - VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -312,54 +278,10 @@ MaterialDef Phong Lighting { } - - Technique PreNormalPassDerivative { - - VertexShader GLSL100 : Common/MatDefs/MSSAO/normal.vert - FragmentShader GLSL100 : Common/MatDefs/MSSAO/normal.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - NormalMatrix - ViewProjectionMatrix - ViewMatrix - } - - Defines { - DIFFUSEMAP_ALPHA : DiffuseMap - NUM_BONES : NumberOfBones - INSTANCING : UseInstancing - } - - } - - Technique GBuf { - - VertexShader GLSL100: Common/MatDefs/Light/GBuf.vert - FragmentShader GLSL100: Common/MatDefs/Light/GBuf.frag - - WorldParameters { - WorldViewProjectionMatrix - NormalMatrix - WorldViewMatrix - WorldMatrix - } - - Defines { - VERTEX_COLOR : UseVertexColor - MATERIAL_COLORS : UseMaterialColors - DIFFUSEMAP : DiffuseMap - NORMALMAP : NormalMap - SPECULARMAP : SpecularMap - PARALLAXMAP : ParallaxMap - } - } - Technique Glow { - VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert index df441ed59..395bc1bca 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/Lighting.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" #import "Common/ShaderLib/Skinning.glsllib" #import "Common/ShaderLib/Lighting.glsllib" diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag index 852f66289..2841ed8e3 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag @@ -1,5 +1,5 @@ -#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/PBR.glsllib" #import "Common/ShaderLib/Parallax.glsllib" #import "Common/ShaderLib/Lighting.glsllib" diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md index 84066dcb6..43f3fad51 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md @@ -108,11 +108,11 @@ MaterialDef PBR Lighting { Boolean BackfaceShadows : false } - Technique { + Technique { LightMode SinglePassAndImageBased - VertexShader GLSL110: Common/MatDefs/Light/PBRLighting.vert - FragmentShader GLSL110: Common/MatDefs/Light/PBRLighting.frag + VertexShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.vert + FragmentShader GLSL110 GLSL150: Common/MatDefs/Light/PBRLighting.frag WorldParameters { WorldViewProjectionMatrix @@ -141,12 +141,11 @@ MaterialDef PBR Lighting { } } - Technique PreShadow { - VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag index 3ece6268f..a510fc1db 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Parallax.glsllib" #import "Common/ShaderLib/Optics.glsllib" #ifndef VERTEX_LIGHTING diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert index c607b3891..49cc5b96e 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/SPLighting.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" #import "Common/ShaderLib/Skinning.glsllib" #import "Common/ShaderLib/Lighting.glsllib" diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.frag index 0b4875e2d..83fef5662 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #ifdef POINT_SPRITE # if !defined(GL_ES) && __VERSION__ < 120 # error Point sprite is not supported by the video hardware! diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md index a327f43b9..1d2ed6fd3 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.j3md @@ -18,38 +18,14 @@ MaterialDef Point Sprite { Technique { - VertexShader GLSL100 : Common/MatDefs/Misc/Particle.vert - FragmentShader GLSL120 : Common/MatDefs/Misc/Particle.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldViewMatrix - WorldMatrix - CameraPosition - } - - RenderState { - Blend AlphaAdditive - DepthWrite Off - PointSprite On - } - - Defines { - USE_TEXTURE : Texture - POINT_SPRITE : PointSprite - } - } - - Technique { - - // This technique is used in two cases: + // The GLSL100 technique is used in two cases: // - When the driver doesn't support GLSL 1.2 // - When running on OpenGL ES 2.0 // Point sprite should be used if running on ES2, but crash // if on desktop (because its not supported by HW) - VertexShader GLSL100 : Common/MatDefs/Misc/Particle.vert - FragmentShader GLSL100 : Common/MatDefs/Misc/Particle.frag + VertexShader GLSL100 GLSL100 GLSL150 : Common/MatDefs/Misc/Particle.vert + FragmentShader GLSL100 GLSL120 GLSL150 : Common/MatDefs/Misc/Particle.frag WorldParameters { WorldViewProjectionMatrix @@ -72,25 +48,31 @@ MaterialDef Point Sprite { Technique PreShadow { - VertexShader GLSL100 : Common/MatDefs/Misc/Particle.vert - FragmentShader GLSL100 : Common/MatDefs/Misc/Particle.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix WorldViewMatrix - WorldMatrix - CameraPosition + ViewProjectionMatrix + ViewMatrix } Defines { - USE_TEXTURE : Texture - PRE_SHADOW + COLOR_MAP : ColorMap + DISCARD_ALPHA : AlphaDiscardThreshold + NUM_BONES : NumberOfBones + INSTANCING : UseInstancing } ForcedRenderState { + FaceCull Off + DepthTest On DepthWrite On + PolyOffset 5 3 ColorWrite Off } + } Technique SoftParticles{ @@ -117,7 +99,7 @@ MaterialDef Point Sprite { Technique SoftParticles15{ - VertexShader GLSL100 : Common/MatDefs/Misc/SoftParticle.vert + VertexShader GLSL150 : Common/MatDefs/Misc/SoftParticle.vert FragmentShader GLSL150 : Common/MatDefs/Misc/SoftParticle15.frag WorldParameters { @@ -150,8 +132,8 @@ MaterialDef Point Sprite { Technique Glow { - VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.vert index 705936943..a8d47cf45 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Particle.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 g_WorldViewProjectionMatrix; attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.frag index 93e488230..721b14c51 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" varying vec3 normal; void main(){ diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md index 63b7470b2..a21ffb50b 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.j3md @@ -5,8 +5,8 @@ MaterialDef Debug Normals { } Technique { - VertexShader GLSL100: Common/MatDefs/Misc/ShowNormals.vert - FragmentShader GLSL100: Common/MatDefs/Misc/ShowNormals.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/ShowNormals.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/ShowNormals.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.vert index 93cbdc361..0835a19ec 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/ShowNormals.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.frag b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.frag index 9f5940304..211f48360 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Optics.glsllib" uniform ENVMAP m_Texture; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md index 3d5ab9ea2..0a3b627a3 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.j3md @@ -6,8 +6,8 @@ MaterialDef Sky Plane { Vector3 NormalScale } Technique { - VertexShader GLSL100: Common/MatDefs/Misc/Sky.vert - FragmentShader GLSL100: Common/MatDefs/Misc/Sky.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Sky.frag WorldParameters { ViewMatrix @@ -17,7 +17,7 @@ MaterialDef Sky Plane { Defines { SPHERE_MAP : SphereMap - EQUIRECT_MAP : EquirectMap + EQUIRECT_MAP : EquirectMap } RenderState { diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.vert index c65753d1e..4b5c67eb2 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Sky.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 g_ViewMatrix; uniform mat4 g_ProjectionMatrix; uniform mat4 g_WorldMatrix; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/SoftParticle.vert b/jme3-core/src/main/resources/Common/MatDefs/Misc/SoftParticle.vert index 4f0dfd5bf..87fb6ef0a 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/SoftParticle.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/SoftParticle.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 g_WorldViewProjectionMatrix; attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md index f02348a06..bc5af58a7 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md @@ -56,30 +56,8 @@ MaterialDef Unshaded { } Technique { - VertexShader GLSL150: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL150: Common/MatDefs/Misc/Unshaded.frag - - WorldParameters { - WorldViewProjectionMatrix - ViewProjectionMatrix - ViewMatrix - } - - Defines { - INSTANCING : UseInstancing - SEPARATE_TEXCOORD : SeparateTexCoord - HAS_COLORMAP : ColorMap - HAS_LIGHTMAP : LightMap - HAS_VERTEXCOLOR : VertexColor - HAS_COLOR : Color - NUM_BONES : NumberOfBones - DISCARD_ALPHA : AlphaDiscardThreshold - } - } - - Technique { - VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/Misc/Unshaded.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.frag WorldParameters { WorldViewProjectionMatrix @@ -101,8 +79,8 @@ MaterialDef Unshaded { Technique PreNormalPass { - VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert - FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/SSAO/normal.frag WorldParameters { WorldViewProjectionMatrix @@ -120,8 +98,8 @@ MaterialDef Unshaded { Technique PreShadow { - VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -149,8 +127,8 @@ MaterialDef Unshaded { Technique PostShadow { - VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -181,43 +159,10 @@ MaterialDef Unshaded { } } - Technique PostShadow { - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldMatrix - ViewProjectionMatrix - ViewMatrix - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - DISCARD_ALPHA : AlphaDiscardThreshold - COLOR_MAP : ColorMap - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - NUM_BONES : NumberOfBones - INSTANCING : UseInstancing - BACKFACE_SHADOWS: BackfaceShadows - } - - ForcedRenderState { - Blend Modulate - DepthWrite Off - PolyOffset -0.1 0 - } - } - Technique Glow { - VertexShader GLSL100: Common/MatDefs/Misc/Unshaded.vert - FragmentShader GLSL100: Common/MatDefs/Light/Glow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Misc/Unshaded.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Light/Glow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.frag index 84bac8281..e0b2c79cf 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/BasicShadow.glsllib" uniform SHADOWMAP m_ShadowMap; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md index a07a23de4..4ba381544 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.j3md @@ -6,8 +6,8 @@ MaterialDef Basic Post Shadow { } Technique { - VertexShader GLSL100: Common/MatDefs/Shadow/BasicPostShadow.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/BasicPostShadow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/BasicPostShadow.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/BasicPostShadow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.vert b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.vert index 3f09753f3..84a91ae04 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/BasicPostShadow.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 m_LightViewProjectionMatrix; uniform mat4 g_WorldViewProjectionMatrix; uniform mat4 g_WorldMatrix; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag index 6d1cc7a5a..c71fb3147 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.frag @@ -1,5 +1,5 @@ -#import "Common/ShaderLib/Shadows.glsllib" #import "Common/ShaderLib/GLSLCompat.glsllib" +#import "Common/ShaderLib/Shadows.glsllib" #if defined(PSSM) || defined(FADE) varying float shadowPosition; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md index 928637adf..fd8ea8a24 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.j3md @@ -35,8 +35,8 @@ MaterialDef Post Shadow { } Technique { - VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Shadow/PostShadow.frag WorldParameters { WorldViewProjectionMatrix @@ -61,31 +61,4 @@ MaterialDef Post Shadow { } } - Technique { - VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert - FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag - - WorldParameters { - WorldViewProjectionMatrix - WorldMatrix - } - - Defines { - HARDWARE_SHADOWS : HardwareShadows - FILTER_MODE : FilterMode - PCFEDGE : PCFEdge - SHADOWMAP_SIZE : ShadowMapSize - FADE : FadeInfo - PSSM : Splits - POINTLIGHT : LightViewProjectionMatrix5 - BACKFACE_SHADOWS: BackfaceShadows - } - - RenderState { - Blend Modulate - DepthWrite Off - PolyOffset -0.1 0 - } - } - } \ No newline at end of file diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.vert b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.vert index de4490820..417427155 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadow.vert @@ -1,6 +1,6 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" #import "Common/ShaderLib/Skinning.glsllib" -#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 m_LightViewProjectionMatrix0; uniform mat4 m_LightViewProjectionMatrix1; diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.frag b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.frag index 080666a4e..0e20de0ec 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" varying vec2 texCoord; #ifdef DISCARD_ALPHA diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md index d270e71a9..a76b36310 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.j3md @@ -1,7 +1,7 @@ MaterialDef Pre Shadow { Technique { - VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert - FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag + VertexShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.vert + FragmentShader GLSL100 GLSL150 : Common/MatDefs/Shadow/PreShadow.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.vert b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.vert index 9bb5d3a87..4e3023d7f 100644 --- a/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.vert +++ b/jme3-core/src/main/resources/Common/MatDefs/Shadow/PreShadow.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" #import "Common/ShaderLib/Skinning.glsllib" attribute vec3 inPosition; diff --git a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib index 23a268975..c1ace91d1 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/GLSLCompat.glsllib @@ -23,6 +23,7 @@ out vec4 outFragColor; # define texture1D texture # define texture2D texture # define texture3D texture +# define textureCube texture # define texture2DLod textureLod # define textureCubeLod textureLod # if defined VERTEX_SHADER diff --git a/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib b/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib index 3b06e6441..4ecd33157 100644 --- a/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib +++ b/jme3-core/src/main/resources/Common/ShaderLib/MultiSample.glsllib @@ -15,12 +15,6 @@ uniform int m_NumSamplesDepth; #define DEPTHTEXTURE sampler2D #endif -#if __VERSION__ >= 150 - #define TEXTURE texture -#else - #define TEXTURE texture2D -#endif - // NOTE: Only define multisample functions if multisample is available #if defined(GL_ARB_texture_multisample) vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){ @@ -32,9 +26,9 @@ vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){ return color / float(numSamples); } -vec4 fetchTextureSample(in sampler2DMS tex,in vec2 texC,in int sample){ +vec4 fetchTextureSample(in sampler2DMS tex,in vec2 texC,in int sampleId){ ivec2 iTexC = ivec2(texC * vec2(textureSize(tex))); - return texelFetch(tex, iTexC, sample); + return texelFetch(tex, iTexC, sampleId); } vec4 getColor(in sampler2DMS tex, in vec2 texC){ @@ -52,19 +46,19 @@ vec4 getDepth(in sampler2DMS tex,in vec2 texC){ #endif -vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){ - return TEXTURE(tex,texC); +vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sampleId){ + return texture2D(tex,texC); } vec4 getColor(in sampler2D tex, in vec2 texC){ - return TEXTURE(tex,texC); + return texture2D(tex,texC); } vec4 getColorSingle(in sampler2D tex, in vec2 texC){ - return TEXTURE(tex, texC); + return texture2D(tex, texC); } vec4 getDepth(in sampler2D tex,in vec2 texC){ - return TEXTURE(tex,texC); + return texture2D(tex,texC); } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.frag index 422cf022f..4064855b2 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #extension GL_EXT_gpu_shader4 : enable uniform sampler2D m_Texture; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md index 61e2b79ef..68f329892 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.j3md @@ -8,8 +8,8 @@ MaterialDef FXAA { Float ReduceMul } Technique { - VertexShader GLSL100: Common/MatDefs/Post/FXAA.vert - FragmentShader GLSL100: Common/MatDefs/Post/FXAA.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Post/FXAA.frag WorldParameters { ResolutionInverse } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.vert b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.vert index e0887a638..8d232a405 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.vert +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/FXAA.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" uniform mat4 g_WorldViewProjectionMatrix; uniform vec2 g_ResolutionInverse; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Post.vert b/jme3-effects/src/main/resources/Common/MatDefs/Post/Post.vert index 1d898a6e4..96219f9f0 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Post.vert +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Post.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" attribute vec4 inPosition; attribute vec2 inTexCoord; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.frag index 78a844313..a5a439ada 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.frag @@ -1,17 +1,12 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/MultiSample.glsllib" uniform COLORTEXTURE m_Texture; uniform vec3 m_WhitePoint; -#if __VERSION__ >= 150 -in vec2 texCoord; -out vec4 outFragColor; -#else varying vec2 texCoord; -#endif -vec3 FilmicCurve(in vec3 x) -{ +vec3 FilmicCurve(in vec3 x){ const float A = 0.22; const float B = 0.30; const float C = 0.10; @@ -24,21 +19,27 @@ vec3 FilmicCurve(in vec3 x) // whitePoint should be 11.2 -vec3 ToneMap_Filmic(vec3 color, vec3 whitePoint) -{ +vec3 ToneMap_Filmic(vec3 color, vec3 whitePoint){ return FilmicCurve(color) / FilmicCurve(whitePoint); } -void main() { - // TODO: This is incorrect if multi-sampling is used. - // The tone-mapping should be performed for each sample independently. +vec4 tonemap(int i) { - vec4 texVal = getColor(m_Texture, texCoord); + vec4 texVal = fetchTextureSample(m_Texture, texCoord, i); vec3 toneMapped = ToneMap_Filmic(texVal.rgb, m_WhitePoint); - #if __VERSION__ >= 150 - outFragColor = vec4(toneMapped, texVal.a); + return vec4(toneMapped, texVal.a); +} + + +void main() { + #ifdef RESOLVE_MS + vec4 color = vec4(0.0); + for (int i = 0; i < m_NumSamples; i++){ + color += tonemap(i); + } + gl_FragColor = color / m_NumSamples; #else - gl_FragColor = vec4(toneMapped, texVal.a); + gl_FragColor = tonemap(0); #endif -} \ No newline at end of file +} diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md index d98364130..a77cc36a9 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/ToneMap.j3md @@ -8,8 +8,8 @@ MaterialDef Default GUI { } Technique { - VertexShader GLSL150: Common/MatDefs/Post/Post15.vert - FragmentShader GLSL150: Common/MatDefs/Post/ToneMap.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Post/Post.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Post/ToneMap.frag WorldParameters { } @@ -20,12 +20,4 @@ MaterialDef Default GUI { } - Technique { - VertexShader GLSL100: Common/MatDefs/Post/Post.vert - FragmentShader GLSL100: Common/MatDefs/Post/ToneMap.frag - - WorldParameters { - } - - } } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.frag b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.frag index 82121067b..d21e605cf 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" varying vec3 normal; varying vec2 texCoord; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.vert b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.vert index 3b09ec310..5306667e3 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.vert +++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.vert @@ -1,8 +1,6 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" #import "Common/ShaderLib/Instancing.glsllib" #import "Common/ShaderLib/Skinning.glsllib" -// These are included in the above now -//uniform mat4 g_WorldViewProjectionMatrix; -//uniform mat3 g_NormalMatrix; attribute vec3 inPosition; attribute vec3 inNormal; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md b/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md index 73942f1b1..7ef8775b3 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md +++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/SimpleWater.j3md @@ -18,8 +18,8 @@ MaterialDef Simple Water { } Technique { - VertexShader GLSL100: Common/MatDefs/Water/simple_water.vert - FragmentShader GLSL100: Common/MatDefs/Water/simple_water.frag + VertexShader GLSL100 GLSL150: Common/MatDefs/Water/simple_water.vert + FragmentShader GLSL100 GLSL150: Common/MatDefs/Water/simple_water.frag WorldParameters { WorldViewProjectionMatrix diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.frag b/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.frag index ae9b10875..47923195f 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.frag @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" /* GLSL conversion of Michael Horsch water demo http://www.bonzaisoftware.com/wfs.html diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.vert b/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.vert index b6ec06675..ccc4a4956 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.vert +++ b/jme3-effects/src/main/resources/Common/MatDefs/Water/simple_water.vert @@ -1,3 +1,4 @@ +#import "Common/ShaderLib/GLSLCompat.glsllib" /* GLSL conversion of Michael Horsch water demo http://www.bonzaisoftware.com/wfs.html diff --git a/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java b/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java index 3ab2ae295..d1b9fb857 100644 --- a/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java +++ b/jme3-examples/src/main/java/jme3test/post/TestPostFilters.java @@ -39,15 +39,14 @@ import com.jme3.light.DirectionalLight; import com.jme3.material.Material; import com.jme3.math.*; import com.jme3.post.FilterPostProcessor; -import com.jme3.post.filters.ColorOverlayFilter; -import com.jme3.post.filters.FadeFilter; -import com.jme3.post.filters.RadialBlurFilter; +import com.jme3.post.filters.*; import com.jme3.renderer.Caps; import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.scene.Geometry; import com.jme3.scene.Spatial; import com.jme3.scene.Spatial.CullHint; import com.jme3.scene.shape.Box; +import com.jme3.system.AppSettings; import com.jme3.texture.Texture; import com.jme3.texture.Texture.WrapMode; import com.jme3.util.SkyFactory; @@ -61,17 +60,21 @@ public class TestPostFilters extends SimpleApplication implements ActionListener public static void main(String[] args) { TestPostFilters app = new TestPostFilters(); + AppSettings settings = new AppSettings(true); + settings.setRenderer(AppSettings.LWJGL_OPENGL2); + app.setSettings(settings); app.start(); } public void setupFilters() { if (renderer.getCaps().contains(Caps.GLSL100)) { fpp = new FilterPostProcessor(assetManager); + // fpp.setNumSamples(4); // fpp.setNumSamples(4); - fpp.addFilter(new ColorOverlayFilter(ColorRGBA.LightGray)); + //fpp.addFilter(new ColorOverlayFilter(ColorRGBA.LightGray)); fpp.addFilter(new RadialBlurFilter()); - //fade=new FadeFilter(1.0f); - //fpp.addFilter(fade); + fade = new FadeFilter(1.0f); + fpp.addFilter(fade); viewPort.addProcessor(fpp); @@ -102,7 +105,7 @@ public class TestPostFilters extends SimpleApplication implements ActionListener dl.setColor(new ColorRGBA(.4f, .4f, .4f, 1)); - rootNode.addLight(dl); + // rootNode.addLight(dl); } public void setupFloor() { @@ -131,12 +134,6 @@ public class TestPostFilters extends SimpleApplication implements ActionListener public void simpleInitApp() { cam.setLocation(new Vector3f(-32.295086f, 54.80136f, 79.59805f)); cam.setRotation(new Quaternion(0.074364014f, 0.92519957f, -0.24794696f, 0.27748522f)); - cam.update(); - - cam.setFrustumFar(300); - flyCam.setMoveSpeed(30); - - rootNode.setCullHint(CullHint.Never); setupLighting(); setupSkyBox(); @@ -153,7 +150,7 @@ public class TestPostFilters extends SimpleApplication implements ActionListener } protected void initInput() { - flyCam.setMoveSpeed(3); + flyCam.setMoveSpeed(50); //init input inputManager.addMapping("fadein", new KeyTrigger(KeyInput.KEY_I)); inputManager.addListener(this, "fadein");