Merge remote-tracking branch 'origin/master' into in-pass-shadows
This commit is contained in:
commit
d50fb09efb
@ -2203,14 +2203,16 @@ public final class GLRenderer implements Renderer {
|
|||||||
// For OpenGL3 and up.
|
// For OpenGL3 and up.
|
||||||
// We'll generate mipmaps via glGenerateMipmapEXT (see below)
|
// We'll generate mipmaps via glGenerateMipmapEXT (see below)
|
||||||
}
|
}
|
||||||
} else if (img.hasMipmaps()) {
|
} else if (caps.contains(Caps.OpenGL20)) {
|
||||||
// Image already has mipmaps, set the max level based on the
|
if (img.hasMipmaps()) {
|
||||||
// number of mipmaps we have.
|
// Image already has mipmaps, set the max level based on the
|
||||||
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
|
// number of mipmaps we have.
|
||||||
} else {
|
gl.glTexParameteri(target, GL2.GL_TEXTURE_MAX_LEVEL, img.getMipMapSizes().length - 1);
|
||||||
// Image does not have mipmaps and they are not required.
|
} else {
|
||||||
// Specify that that the texture has no mipmaps.
|
// Image does not have mipmaps and they are not required.
|
||||||
gl.glTexParameteri(target, GL.GL_TEXTURE_MAX_LEVEL, 0);
|
// Specify that that the texture has no mipmaps.
|
||||||
|
gl.glTexParameteri(target, GL2.GL_TEXTURE_MAX_LEVEL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check if graphics card doesn't support multisample textures
|
// Check if graphics card doesn't support multisample textures
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
|
#extension GL_ARB_texture_multisample : enable
|
||||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||||
#import "Common/ShaderLib/MultiSample.glsllib"
|
|
||||||
|
|
||||||
uniform COLORTEXTURE m_Texture;
|
vec3 FilmicCurve(in vec3 x) {
|
||||||
uniform vec3 m_WhitePoint;
|
|
||||||
|
|
||||||
varying vec2 texCoord;
|
|
||||||
|
|
||||||
vec3 FilmicCurve(in vec3 x){
|
|
||||||
const float A = 0.22;
|
const float A = 0.22;
|
||||||
const float B = 0.30;
|
const float B = 0.30;
|
||||||
const float C = 0.10;
|
const float C = 0.10;
|
||||||
@ -19,27 +14,40 @@ vec3 FilmicCurve(in vec3 x){
|
|||||||
|
|
||||||
// whitePoint should be 11.2
|
// whitePoint should be 11.2
|
||||||
|
|
||||||
vec3 ToneMap_Filmic(vec3 color, vec3 whitePoint){
|
vec3 ToneMap_Filmic(vec3 color, vec3 whitePoint) {
|
||||||
return FilmicCurve(color) / FilmicCurve(whitePoint);
|
return FilmicCurve(color) / FilmicCurve(whitePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 tonemap(int i) {
|
uniform vec3 m_WhitePoint;
|
||||||
|
varying vec2 texCoord;
|
||||||
|
|
||||||
vec4 texVal = fetchTextureSample(m_Texture, texCoord, i);
|
#ifdef NUM_SAMPLES
|
||||||
vec3 toneMapped = ToneMap_Filmic(texVal.rgb, m_WhitePoint);
|
|
||||||
|
|
||||||
return vec4(toneMapped, texVal.a);
|
uniform sampler2DMS m_Texture;
|
||||||
|
|
||||||
|
vec4 ToneMap_TextureFilmic() {
|
||||||
|
ivec2 iTexC = ivec2(texCoord * vec2(textureSize(m_Texture)));
|
||||||
|
vec4 color = vec4(0.0);
|
||||||
|
for (int i = 0; i < NUM_SAMPLES; i++) {
|
||||||
|
vec4 hdrColor = texelFetch(m_Texture, iTexC, i);
|
||||||
|
vec3 ldrColor = FilmicCurve(hdrColor.rgb);
|
||||||
|
color += vec4(ldrColor, hdrColor.a);
|
||||||
|
}
|
||||||
|
color.rgb /= FilmicCurve(m_WhitePoint);
|
||||||
|
return color / float(NUM_SAMPLES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
uniform sampler2D m_Texture;
|
||||||
|
|
||||||
|
vec4 ToneMap_TextureFilmic() {
|
||||||
|
vec4 texVal = texture2D(m_Texture, texCoord);
|
||||||
|
return vec4(ToneMap_Filmic(texVal.rgb, m_WhitePoint), texVal.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
#ifdef RESOLVE_MS
|
gl_FragColor = ToneMap_TextureFilmic();
|
||||||
vec4 color = vec4(0.0);
|
|
||||||
for (int i = 0; i < m_NumSamples; i++){
|
|
||||||
color += tonemap(i);
|
|
||||||
}
|
|
||||||
gl_FragColor = color / m_NumSamples;
|
|
||||||
#else
|
|
||||||
gl_FragColor = tonemap(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,7 @@ MaterialDef Default GUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
RESOLVE_MS : NumSamples
|
NUM_SAMPLES : NumSamples
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -35,7 +35,6 @@ import com.jme3.math.FastMath;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.management.JMException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <code>MidpointDisplacementHeightMap</code> generates an heightmap based on
|
* <code>MidpointDisplacementHeightMap</code> generates an heightmap based on
|
||||||
@ -72,11 +71,11 @@ public class MidpointDisplacementHeightMap extends AbstractHeightMap {
|
|||||||
* typically a good choice
|
* typically a good choice
|
||||||
* @param seed
|
* @param seed
|
||||||
* A seed to feed the random number generator.
|
* A seed to feed the random number generator.
|
||||||
* @throw JMException if size is not a power of two plus one.
|
* @throw IllegalArgumentException if size is not a power of two plus one.
|
||||||
*/
|
*/
|
||||||
public MidpointDisplacementHeightMap(int size, float range, float persistence, long seed) throws Exception {
|
public MidpointDisplacementHeightMap(int size, float range, float persistence, long seed) {
|
||||||
if (size < 0 || !FastMath.isPowerOfTwo(size - 1)) {
|
if (size < 0 || !FastMath.isPowerOfTwo(size - 1)) {
|
||||||
throw new JMException("The size is negative or not of the form 2^N +1"
|
throw new IllegalArgumentException("The size is negative or not of the form 2^N +1"
|
||||||
+ " (a power of two plus one)");
|
+ " (a power of two plus one)");
|
||||||
}
|
}
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user