# 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
define_list_fix
Rémy Bouquet 8 years ago
commit c50b4dbeaa
  1. 2
      jme3-core/src/main/java/com/jme3/math/Triangle.java
  2. 2
      jme3-core/src/main/java/com/jme3/renderer/Camera.java
  3. 7
      jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
  4. 25
      jme3-core/src/main/java/com/jme3/texture/FrameBuffer.java
  5. 4
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.frag
  6. 33
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md
  7. 4
      jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.vert
  8. 4
      jme3-ios/src/main/java/com/jme3/system/ios/IosHarness.java
  9. 21
      jme3-lwjgl/src/main/java/com/jme3/input/lwjgl/LwjglMouseInput.java

@ -44,7 +44,7 @@ import java.io.IOException;
* @author Mark Powell
* @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;

@ -991,7 +991,7 @@ public class Camera implements Savable, Cloneable {
* Returns the pseudo distance from the given position to the near
* plane of the camera. This is used for render queue sorting.
* @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) {
return worldPlane[NEAR_PLANE].pseudoDistance(pos);

@ -1648,7 +1648,6 @@ public final class GLRenderer implements Renderer {
if (fb.getNumColorBuffers() == 0) {
// make sure to select NONE as draw buf
// no color buffer attached.
if (gl2 != null) {
if (context.boundDrawBuf != NONE) {
gl2.glDrawBuffer(GL.GL_NONE);
context.boundDrawBuf = NONE;
@ -1657,7 +1656,6 @@ public final class GLRenderer implements Renderer {
gl2.glReadBuffer(GL.GL_NONE);
context.boundReadBuf = NONE;
}
}
} else {
if (fb.getNumColorBuffers() > limits.get(Limits.FrameBufferAttachments)) {
throw new RendererException("Framebuffer has more color "
@ -1675,7 +1673,6 @@ public final class GLRenderer implements Renderer {
+ " by the video hardware!");
}
if (context.boundDrawBuf != MRT_OFF + fb.getNumColorBuffers()) {
intBuf16.clear();
for (int i = 0; i < fb.getNumColorBuffers(); i++) {
intBuf16.put(GLFbo.GL_COLOR_ATTACHMENT0_EXT + i);
@ -1684,11 +1681,10 @@ public final class GLRenderer implements Renderer {
intBuf16.flip();
glext.glDrawBuffers(intBuf16);
context.boundDrawBuf = MRT_OFF + fb.getNumColorBuffers();
}
} else {
RenderBuffer rb = fb.getColorBuffer(fb.getTargetIndex());
// select this draw buffer
if (gl2 != null) {
if (context.boundDrawBuf != rb.getSlot()) {
gl2.glDrawBuffer(GLFbo.GL_COLOR_ATTACHMENT0_EXT + 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();
}
/**
* 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.
* 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.
*
* @param tex The texture to add.
* @see #addColorBuffer(com.jme3.texture.Image.Format)
*/
public void addColorTexture(Texture2D tex) {
if (id != -1)

@ -9,7 +9,9 @@ varying vec2 texCoord;
varying vec2 texCoord2;
#endif
#ifndef BASECOLORMAP
varying vec4 Color;
#endif
uniform vec4 g_LightData[NB_LIGHTS];
@ -122,7 +124,7 @@ void main(){
float Metallic = max(m_Metallic, 0.0);
#endif
float alpha = Color.a * albedo.a;
float alpha = albedo.a;
#ifdef DISCARD_ALPHA
if(alpha < m_AlphaDiscardThreshold){

@ -154,7 +154,6 @@ MaterialDef PBR Lighting {
}
Defines {
COLOR_MAP : ColorMap
DISCARD_ALPHA : AlphaDiscardThreshold
NUM_BONES : NumberOfBones
INSTANCING : UseInstancing
@ -187,7 +186,7 @@ MaterialDef PBR Lighting {
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
COLOR_MAP : ColorMap
SHADOWMAP_SIZE : ShadowMapSize
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
@ -219,7 +218,6 @@ MaterialDef PBR Lighting {
FILTER_MODE : FilterMode
PCFEDGE : PCFEdge
DISCARD_ALPHA : AlphaDiscardThreshold
COLOR_MAP : ColorMap
SHADOWMAP_SIZE : ShadowMapSize
FADE : FadeInfo
PSSM : Splits
@ -249,29 +247,6 @@ MaterialDef PBR Lighting {
}
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
INSTANCING : UseInstancing
}
@ -292,12 +267,6 @@ MaterialDef PBR Lighting {
Defines {
VERTEX_COLOR : UseVertexColor
MATERIAL_COLORS : UseMaterialColors
V_TANGENT : VTangent
MINNAERT : Minnaert
WARDISO : WardIso
DIFFUSEMAP : DiffuseMap
NORMALMAP : NormalMap
SPECULARMAP : SpecularMap
PARALLAXMAP : ParallaxMap

@ -13,7 +13,9 @@ varying vec2 texCoord;
attribute vec2 inTexCoord2;
#endif
#ifndef BASECOLORMAP
varying vec4 Color;
#endif
attribute vec3 inPosition;
attribute vec2 inTexCoord;
@ -59,7 +61,9 @@ void main(){
wTangent = vec4(TransformWorldNormal(modelSpaceTan),inTangent.w);
#endif
#ifndef BASECOLORMAP
Color = m_BaseColor;
#endif
#ifdef VERTEX_COLOR
Color *= inColor;

@ -31,7 +31,7 @@
*/
package com.jme3.system.ios;
import com.jme3.app.Application;
import com.jme3.app.LegacyApplication;
import com.jme3.system.JmeSystem;
/**
@ -39,7 +39,7 @@ import com.jme3.system.JmeSystem;
*/
public abstract class IosHarness extends ObjcNativeObject {
protected Application app;
protected LegacyApplication app;
public IosHarness(long appDelegate) {
super(appDelegate);

@ -39,6 +39,8 @@ import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.system.lwjgl.LwjglAbstractDisplay;
import com.jme3.system.lwjgl.LwjglTimer;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.lwjgl.LWJGLException;
@ -57,6 +59,12 @@ public class LwjglMouseInput implements MouseInput {
private boolean supportHardwareCursor = false;
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;
public LwjglMouseInput(LwjglAbstractDisplay context){
@ -132,6 +140,13 @@ public class LwjglMouseInput implements MouseInput {
return;
Mouse.destroy();
// Destroy the cursor cache
for (Cursor cursor : cursorMap.values()) {
cursor.destroy();
}
cursorMap.clear();
logger.fine("Mouse destroyed.");
}
@ -155,6 +170,8 @@ public class LwjglMouseInput implements MouseInput {
try {
Cursor newCursor = null;
if (jmeCursor != null) {
newCursor = cursorMap.get(jmeCursor);
if (newCursor == null) {
newCursor = new Cursor(
jmeCursor.getWidth(),
jmeCursor.getHeight(),
@ -163,6 +180,10 @@ public class LwjglMouseInput implements MouseInput {
jmeCursor.getNumImages(),
jmeCursor.getImagesData(),
jmeCursor.getImagesDelay());
// Add to cache
cursorMap.put(jmeCursor, newCursor);
}
}
Mouse.setNativeCursor(newCursor);
} catch (LWJGLException ex) {

Loading…
Cancel
Save