Merge branch 'master' of https://github.com/jMonkeyEngine/jmonkeyengine
# By Nehon (2) and others # Via GitHub (7) and Nehon (1) * 'master' of https://github.com/jMonkeyEngine/jmonkeyengine: Clean up in the PBR j3md file to remove warnings Fix for #502 Minor fix in javadoc for Camera.java class minor cleanup in GLRenderer fixed missing Cloneable in the Triangle. Fix for MTR Framebuffers fixed a typo Using LegacyApplication in the iOS Harness just like it has been done for Android in 3c56afe Fixed wrong alpha handling in the pbr shader Added a cursor cache to avoid cursor disappearing and app crashing when too many cursors are created
This commit is contained in:
commit
c50b4dbeaa
@ -44,7 +44,7 @@ import java.io.IOException;
|
|||||||
* @author Mark Powell
|
* @author Mark Powell
|
||||||
* @author Joshua Slack
|
* @author Joshua Slack
|
||||||
*/
|
*/
|
||||||
public class Triangle extends AbstractTriangle implements Savable, java.io.Serializable {
|
public class Triangle extends AbstractTriangle implements Savable, Cloneable, java.io.Serializable {
|
||||||
|
|
||||||
static final long serialVersionUID = 1;
|
static final long serialVersionUID = 1;
|
||||||
|
|
||||||
|
@ -991,7 +991,7 @@ public class Camera implements Savable, Cloneable {
|
|||||||
* Returns the pseudo distance from the given position to the near
|
* Returns the pseudo distance from the given position to the near
|
||||||
* plane of the camera. This is used for render queue sorting.
|
* plane of the camera. This is used for render queue sorting.
|
||||||
* @param pos The position to compute a distance to.
|
* @param pos The position to compute a distance to.
|
||||||
* @return Distance from the far plane to the point.
|
* @return Distance from the near plane to the point.
|
||||||
*/
|
*/
|
||||||
public float distanceToNearPlane(Vector3f pos) {
|
public float distanceToNearPlane(Vector3f pos) {
|
||||||
return worldPlane[NEAR_PLANE].pseudoDistance(pos);
|
return worldPlane[NEAR_PLANE].pseudoDistance(pos);
|
||||||
|
@ -1648,7 +1648,6 @@ public final class GLRenderer implements Renderer {
|
|||||||
if (fb.getNumColorBuffers() == 0) {
|
if (fb.getNumColorBuffers() == 0) {
|
||||||
// make sure to select NONE as draw buf
|
// make sure to select NONE as draw buf
|
||||||
// no color buffer attached.
|
// no color buffer attached.
|
||||||
if (gl2 != null) {
|
|
||||||
if (context.boundDrawBuf != NONE) {
|
if (context.boundDrawBuf != NONE) {
|
||||||
gl2.glDrawBuffer(GL.GL_NONE);
|
gl2.glDrawBuffer(GL.GL_NONE);
|
||||||
context.boundDrawBuf = NONE;
|
context.boundDrawBuf = NONE;
|
||||||
@ -1657,7 +1656,6 @@ public final class GLRenderer implements Renderer {
|
|||||||
gl2.glReadBuffer(GL.GL_NONE);
|
gl2.glReadBuffer(GL.GL_NONE);
|
||||||
context.boundReadBuf = NONE;
|
context.boundReadBuf = NONE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (fb.getNumColorBuffers() > limits.get(Limits.FrameBufferAttachments)) {
|
if (fb.getNumColorBuffers() > limits.get(Limits.FrameBufferAttachments)) {
|
||||||
throw new RendererException("Framebuffer has more color "
|
throw new RendererException("Framebuffer has more color "
|
||||||
@ -1675,7 +1673,6 @@ public final class GLRenderer implements Renderer {
|
|||||||
+ " by the video hardware!");
|
+ " by the video hardware!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.boundDrawBuf != MRT_OFF + fb.getNumColorBuffers()) {
|
|
||||||
intBuf16.clear();
|
intBuf16.clear();
|
||||||
for (int i = 0; i < fb.getNumColorBuffers(); i++) {
|
for (int i = 0; i < fb.getNumColorBuffers(); i++) {
|
||||||
intBuf16.put(GLFbo.GL_COLOR_ATTACHMENT0_EXT + i);
|
intBuf16.put(GLFbo.GL_COLOR_ATTACHMENT0_EXT + i);
|
||||||
@ -1684,11 +1681,10 @@ public final class GLRenderer implements Renderer {
|
|||||||
intBuf16.flip();
|
intBuf16.flip();
|
||||||
glext.glDrawBuffers(intBuf16);
|
glext.glDrawBuffers(intBuf16);
|
||||||
context.boundDrawBuf = MRT_OFF + fb.getNumColorBuffers();
|
context.boundDrawBuf = MRT_OFF + fb.getNumColorBuffers();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
RenderBuffer rb = fb.getColorBuffer(fb.getTargetIndex());
|
RenderBuffer rb = fb.getColorBuffer(fb.getTargetIndex());
|
||||||
// select this draw buffer
|
// select this draw buffer
|
||||||
if (gl2 != null) {
|
|
||||||
if (context.boundDrawBuf != rb.getSlot()) {
|
if (context.boundDrawBuf != rb.getSlot()) {
|
||||||
gl2.glDrawBuffer(GLFbo.GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
|
gl2.glDrawBuffer(GLFbo.GL_COLOR_ATTACHMENT0_EXT + rb.getSlot());
|
||||||
context.boundDrawBuf = rb.getSlot();
|
context.boundDrawBuf = rb.getSlot();
|
||||||
@ -1696,7 +1692,6 @@ public final class GLRenderer implements Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,6 +363,30 @@ public class FrameBuffer extends NativeObject {
|
|||||||
colorBufs.clear();
|
colorBufs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a color buffer without a texture bound to it.
|
||||||
|
* If MRT is enabled, then each subsequently added texture or buffer can be
|
||||||
|
* rendered to through a shader that writes to the array <code>gl_FragData</code>.
|
||||||
|
* If MRT is not enabled, then the index set with {@link FrameBuffer#setTargetIndex(int) }
|
||||||
|
* is rendered to by the shader.
|
||||||
|
*
|
||||||
|
* @param format the format of the color buffer
|
||||||
|
* @see #addColorTexture(com.jme3.texture.Texture2D)
|
||||||
|
*/
|
||||||
|
public void addColorBuffer(Image.Format format){
|
||||||
|
if (id != -1)
|
||||||
|
throw new UnsupportedOperationException("FrameBuffer already initialized.");
|
||||||
|
|
||||||
|
if (format.isDepthFormat())
|
||||||
|
throw new IllegalArgumentException("Color buffer format must be color/luminance.");
|
||||||
|
|
||||||
|
RenderBuffer colorBuf = new RenderBuffer();
|
||||||
|
colorBuf.slot = colorBufs.size();
|
||||||
|
colorBuf.format = format;
|
||||||
|
|
||||||
|
colorBufs.add(colorBuf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a color texture to use for this framebuffer.
|
* Add a color texture to use for this framebuffer.
|
||||||
* If MRT is enabled, then each subsequently added texture can be
|
* If MRT is enabled, then each subsequently added texture can be
|
||||||
@ -371,6 +395,7 @@ public class FrameBuffer extends NativeObject {
|
|||||||
* is rendered to by the shader.
|
* is rendered to by the shader.
|
||||||
*
|
*
|
||||||
* @param tex The texture to add.
|
* @param tex The texture to add.
|
||||||
|
* @see #addColorBuffer(com.jme3.texture.Image.Format)
|
||||||
*/
|
*/
|
||||||
public void addColorTexture(Texture2D tex) {
|
public void addColorTexture(Texture2D tex) {
|
||||||
if (id != -1)
|
if (id != -1)
|
||||||
|
@ -9,7 +9,9 @@ varying vec2 texCoord;
|
|||||||
varying vec2 texCoord2;
|
varying vec2 texCoord2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BASECOLORMAP
|
||||||
varying vec4 Color;
|
varying vec4 Color;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform vec4 g_LightData[NB_LIGHTS];
|
uniform vec4 g_LightData[NB_LIGHTS];
|
||||||
|
|
||||||
@ -122,7 +124,7 @@ void main(){
|
|||||||
float Metallic = max(m_Metallic, 0.0);
|
float Metallic = max(m_Metallic, 0.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float alpha = Color.a * albedo.a;
|
float alpha = albedo.a;
|
||||||
|
|
||||||
#ifdef DISCARD_ALPHA
|
#ifdef DISCARD_ALPHA
|
||||||
if(alpha < m_AlphaDiscardThreshold){
|
if(alpha < m_AlphaDiscardThreshold){
|
||||||
|
@ -154,7 +154,6 @@ MaterialDef PBR Lighting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
COLOR_MAP : ColorMap
|
|
||||||
DISCARD_ALPHA : AlphaDiscardThreshold
|
DISCARD_ALPHA : AlphaDiscardThreshold
|
||||||
NUM_BONES : NumberOfBones
|
NUM_BONES : NumberOfBones
|
||||||
INSTANCING : UseInstancing
|
INSTANCING : UseInstancing
|
||||||
@ -187,7 +186,7 @@ MaterialDef PBR Lighting {
|
|||||||
FILTER_MODE : FilterMode
|
FILTER_MODE : FilterMode
|
||||||
PCFEDGE : PCFEdge
|
PCFEDGE : PCFEdge
|
||||||
DISCARD_ALPHA : AlphaDiscardThreshold
|
DISCARD_ALPHA : AlphaDiscardThreshold
|
||||||
COLOR_MAP : ColorMap
|
SHADOWMAP_SIZE : ShadowMapSize
|
||||||
SHADOWMAP_SIZE : ShadowMapSize
|
SHADOWMAP_SIZE : ShadowMapSize
|
||||||
FADE : FadeInfo
|
FADE : FadeInfo
|
||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
@ -219,7 +218,6 @@ MaterialDef PBR Lighting {
|
|||||||
FILTER_MODE : FilterMode
|
FILTER_MODE : FilterMode
|
||||||
PCFEDGE : PCFEdge
|
PCFEDGE : PCFEdge
|
||||||
DISCARD_ALPHA : AlphaDiscardThreshold
|
DISCARD_ALPHA : AlphaDiscardThreshold
|
||||||
COLOR_MAP : ColorMap
|
|
||||||
SHADOWMAP_SIZE : ShadowMapSize
|
SHADOWMAP_SIZE : ShadowMapSize
|
||||||
FADE : FadeInfo
|
FADE : FadeInfo
|
||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
@ -249,29 +247,6 @@ MaterialDef PBR Lighting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
DIFFUSEMAP_ALPHA : DiffuseMap
|
|
||||||
NUM_BONES : NumberOfBones
|
|
||||||
INSTANCING : UseInstancing
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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
|
NUM_BONES : NumberOfBones
|
||||||
INSTANCING : UseInstancing
|
INSTANCING : UseInstancing
|
||||||
}
|
}
|
||||||
@ -292,12 +267,6 @@ MaterialDef PBR Lighting {
|
|||||||
|
|
||||||
Defines {
|
Defines {
|
||||||
VERTEX_COLOR : UseVertexColor
|
VERTEX_COLOR : UseVertexColor
|
||||||
MATERIAL_COLORS : UseMaterialColors
|
|
||||||
V_TANGENT : VTangent
|
|
||||||
MINNAERT : Minnaert
|
|
||||||
WARDISO : WardIso
|
|
||||||
|
|
||||||
DIFFUSEMAP : DiffuseMap
|
|
||||||
NORMALMAP : NormalMap
|
NORMALMAP : NormalMap
|
||||||
SPECULARMAP : SpecularMap
|
SPECULARMAP : SpecularMap
|
||||||
PARALLAXMAP : ParallaxMap
|
PARALLAXMAP : ParallaxMap
|
||||||
|
@ -13,7 +13,9 @@ varying vec2 texCoord;
|
|||||||
attribute vec2 inTexCoord2;
|
attribute vec2 inTexCoord2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BASECOLORMAP
|
||||||
varying vec4 Color;
|
varying vec4 Color;
|
||||||
|
#endif
|
||||||
|
|
||||||
attribute vec3 inPosition;
|
attribute vec3 inPosition;
|
||||||
attribute vec2 inTexCoord;
|
attribute vec2 inTexCoord;
|
||||||
@ -59,7 +61,9 @@ void main(){
|
|||||||
wTangent = vec4(TransformWorldNormal(modelSpaceTan),inTangent.w);
|
wTangent = vec4(TransformWorldNormal(modelSpaceTan),inTangent.w);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BASECOLORMAP
|
||||||
Color = m_BaseColor;
|
Color = m_BaseColor;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef VERTEX_COLOR
|
#ifdef VERTEX_COLOR
|
||||||
Color *= inColor;
|
Color *= inColor;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.system.ios;
|
package com.jme3.system.ios;
|
||||||
|
|
||||||
import com.jme3.app.Application;
|
import com.jme3.app.LegacyApplication;
|
||||||
import com.jme3.system.JmeSystem;
|
import com.jme3.system.JmeSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +39,7 @@ import com.jme3.system.JmeSystem;
|
|||||||
*/
|
*/
|
||||||
public abstract class IosHarness extends ObjcNativeObject {
|
public abstract class IosHarness extends ObjcNativeObject {
|
||||||
|
|
||||||
protected Application app;
|
protected LegacyApplication app;
|
||||||
|
|
||||||
public IosHarness(long appDelegate) {
|
public IosHarness(long appDelegate) {
|
||||||
super(appDelegate);
|
super(appDelegate);
|
||||||
|
@ -39,6 +39,8 @@ import com.jme3.input.event.MouseButtonEvent;
|
|||||||
import com.jme3.input.event.MouseMotionEvent;
|
import com.jme3.input.event.MouseMotionEvent;
|
||||||
import com.jme3.system.lwjgl.LwjglAbstractDisplay;
|
import com.jme3.system.lwjgl.LwjglAbstractDisplay;
|
||||||
import com.jme3.system.lwjgl.LwjglTimer;
|
import com.jme3.system.lwjgl.LwjglTimer;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.lwjgl.LWJGLException;
|
import org.lwjgl.LWJGLException;
|
||||||
@ -57,6 +59,12 @@ public class LwjglMouseInput implements MouseInput {
|
|||||||
private boolean supportHardwareCursor = false;
|
private boolean supportHardwareCursor = false;
|
||||||
private boolean cursorVisible = true;
|
private boolean cursorVisible = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We need to cache the cursors
|
||||||
|
* (https://github.com/jMonkeyEngine/jmonkeyengine/issues/537)
|
||||||
|
*/
|
||||||
|
private Map<JmeCursor, Cursor> cursorMap = new HashMap<JmeCursor, Cursor>();
|
||||||
|
|
||||||
private int curX, curY, curWheel;
|
private int curX, curY, curWheel;
|
||||||
|
|
||||||
public LwjglMouseInput(LwjglAbstractDisplay context){
|
public LwjglMouseInput(LwjglAbstractDisplay context){
|
||||||
@ -132,6 +140,13 @@ public class LwjglMouseInput implements MouseInput {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Mouse.destroy();
|
Mouse.destroy();
|
||||||
|
|
||||||
|
// Destroy the cursor cache
|
||||||
|
for (Cursor cursor : cursorMap.values()) {
|
||||||
|
cursor.destroy();
|
||||||
|
}
|
||||||
|
cursorMap.clear();
|
||||||
|
|
||||||
logger.fine("Mouse destroyed.");
|
logger.fine("Mouse destroyed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +170,8 @@ public class LwjglMouseInput implements MouseInput {
|
|||||||
try {
|
try {
|
||||||
Cursor newCursor = null;
|
Cursor newCursor = null;
|
||||||
if (jmeCursor != null) {
|
if (jmeCursor != null) {
|
||||||
|
newCursor = cursorMap.get(jmeCursor);
|
||||||
|
if (newCursor == null) {
|
||||||
newCursor = new Cursor(
|
newCursor = new Cursor(
|
||||||
jmeCursor.getWidth(),
|
jmeCursor.getWidth(),
|
||||||
jmeCursor.getHeight(),
|
jmeCursor.getHeight(),
|
||||||
@ -163,6 +180,10 @@ public class LwjglMouseInput implements MouseInput {
|
|||||||
jmeCursor.getNumImages(),
|
jmeCursor.getNumImages(),
|
||||||
jmeCursor.getImagesData(),
|
jmeCursor.getImagesData(),
|
||||||
jmeCursor.getImagesDelay());
|
jmeCursor.getImagesDelay());
|
||||||
|
|
||||||
|
// Add to cache
|
||||||
|
cursorMap.put(jmeCursor, newCursor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Mouse.setNativeCursor(newCursor);
|
Mouse.setNativeCursor(newCursor);
|
||||||
} catch (LWJGLException ex) {
|
} catch (LWJGLException ex) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user