Merge remote-tracking branch 'github/master' into master-original
This commit is contained in:
commit
911b99330b
@ -812,13 +812,47 @@ public final class Bone implements Savable {
|
|||||||
output.writeSavableArrayList(children, "children", null);
|
output.writeSavableArrayList(children, "children", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the rotation of the bone in object space.
|
||||||
|
* Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
|
||||||
|
* @param rot
|
||||||
|
*/
|
||||||
public void setLocalRotation(Quaternion rot){
|
public void setLocalRotation(Quaternion rot){
|
||||||
if (!userControl) {
|
if (!userControl) {
|
||||||
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
||||||
}
|
}
|
||||||
this.localRot = rot;
|
this.localRot.set(rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the position of the bone in object space.
|
||||||
|
* Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
|
||||||
|
* @param pos
|
||||||
|
*/
|
||||||
|
public void setLocalTranslation(Vector3f pos){
|
||||||
|
if (!userControl) {
|
||||||
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
||||||
|
}
|
||||||
|
this.localPos.set(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the scale of the bone in object space.
|
||||||
|
* Warning: you need to call {@link #setUserControl(boolean)} with true to be able to do that operation
|
||||||
|
* @param scale the scale to apply
|
||||||
|
*/
|
||||||
|
public void setLocalScale(Vector3f scale){
|
||||||
|
if (!userControl) {
|
||||||
|
throw new IllegalStateException("User control must be on bone to allow user transforms");
|
||||||
|
}
|
||||||
|
this.localScale.set(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns true if this bone can be directly manipulated by the user.
|
||||||
|
* @see #setUserControl(boolean)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean hasUserControl(){
|
public boolean hasUserControl(){
|
||||||
return userControl;
|
return userControl;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class SpotLight extends Light {
|
|||||||
this();
|
this();
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
setDirection(direction);
|
setDirection(direction);
|
||||||
this.spotRange = range;
|
setSpotRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +133,7 @@ public class SpotLight extends Light {
|
|||||||
computeAngleParameters();
|
computeAngleParameters();
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
setDirection(direction);
|
setDirection(direction);
|
||||||
this.spotRange = range;
|
setSpotRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +158,7 @@ public class SpotLight extends Light {
|
|||||||
computeAngleParameters();
|
computeAngleParameters();
|
||||||
setPosition(position);
|
setPosition(position);
|
||||||
setDirection(direction);
|
setDirection(direction);
|
||||||
this.spotRange = range;
|
setSpotRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -942,8 +942,7 @@ final public class FastMath {
|
|||||||
* Converts a single precision (32 bit) floating point value
|
* Converts a single precision (32 bit) floating point value
|
||||||
* into half precision (16 bit).
|
* into half precision (16 bit).
|
||||||
*
|
*
|
||||||
* <p>Source: <a href="http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf">
|
* <p>Source: <a href="ftp://www.fox-toolkit.org/pub/fasthalffloatconversion.pdf</a>
|
||||||
* http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf</a><br><strong>broken link</strong>
|
|
||||||
*
|
*
|
||||||
* @param half The half floating point value as a short.
|
* @param half The half floating point value as a short.
|
||||||
* @return floating point value of the half.
|
* @return floating point value of the half.
|
||||||
@ -982,9 +981,9 @@ final public class FastMath {
|
|||||||
return 0x7bff;
|
return 0x7bff;
|
||||||
} else if (flt < -65504f) {
|
} else if (flt < -65504f) {
|
||||||
return (short) (0x7bff | 0x8000);
|
return (short) (0x7bff | 0x8000);
|
||||||
} else if (flt > 0f && flt < 5.96046E-8f) {
|
} else if (flt > 0f && flt < 3.054738E-5f) {
|
||||||
return 0x0001;
|
return 0x0001;
|
||||||
} else if (flt < 0f && flt > -5.96046E-8f) {
|
} else if (flt < 0f && flt > -3.054738E-5f) {
|
||||||
return (short) 0x8001;
|
return (short) 0x8001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +202,11 @@ public enum Caps {
|
|||||||
*/
|
*/
|
||||||
FloatTexture,
|
FloatTexture,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports integer textures
|
||||||
|
*/
|
||||||
|
IntegerTexture,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports floating point FBO color buffers (Format.RGB16F)
|
* Supports floating point FBO color buffers (Format.RGB16F)
|
||||||
*/
|
*/
|
||||||
|
@ -54,6 +54,34 @@ public interface GL3 extends GL2 {
|
|||||||
public static final int GL_TEXTURE_SWIZZLE_B = 0x8E44;
|
public static final int GL_TEXTURE_SWIZZLE_B = 0x8E44;
|
||||||
public static final int GL_TEXTURE_SWIZZLE_G = 0x8E43;
|
public static final int GL_TEXTURE_SWIZZLE_G = 0x8E43;
|
||||||
public static final int GL_TEXTURE_SWIZZLE_R = 0x8E42;
|
public static final int GL_TEXTURE_SWIZZLE_R = 0x8E42;
|
||||||
|
public static final int GL_R8I = 33329;
|
||||||
|
public static final int GL_R8UI = 33330;
|
||||||
|
public static final int GL_R16I = 33331;
|
||||||
|
public static final int GL_R16UI = 33332;
|
||||||
|
public static final int GL_R32I = 33333;
|
||||||
|
public static final int GL_R32UI = 33334;
|
||||||
|
public static final int GL_RG8I = 33335;
|
||||||
|
public static final int GL_RG8UI = 33336;
|
||||||
|
public static final int GL_RG16I = 33337;
|
||||||
|
public static final int GL_RG16UI = 33338;
|
||||||
|
public static final int GL_RG32I = 33339;
|
||||||
|
public static final int GL_RG32UI = 33340;
|
||||||
|
public static final int GL_RGBA32UI = 36208;
|
||||||
|
public static final int GL_RGB32UI = 36209;
|
||||||
|
public static final int GL_RGBA16UI = 36214;
|
||||||
|
public static final int GL_RGB16UI = 36215;
|
||||||
|
public static final int GL_RGBA8UI = 36220;
|
||||||
|
public static final int GL_RGB8UI = 36221;
|
||||||
|
public static final int GL_RGBA32I = 36226;
|
||||||
|
public static final int GL_RGB32I = 36227;
|
||||||
|
public static final int GL_RGBA16I = 36232;
|
||||||
|
public static final int GL_RGB16I = 36233;
|
||||||
|
public static final int GL_RGBA8I = 36238;
|
||||||
|
public static final int GL_RGB8I = 36239;
|
||||||
|
public static final int GL_RED_INTEGER = 36244;
|
||||||
|
public static final int GL_RG_INTEGER = 33320;
|
||||||
|
public static final int GL_RGB_INTEGER = 36248;
|
||||||
|
public static final int GL_RGBA_INTEGER = 36249;
|
||||||
|
|
||||||
public void glBindFragDataLocation(int param1, int param2, String param3); /// GL3+
|
public void glBindFragDataLocation(int param1, int param2, String param3); /// GL3+
|
||||||
public void glBindVertexArray(int param1); /// GL3+
|
public void glBindVertexArray(int param1); /// GL3+
|
||||||
|
@ -233,6 +233,37 @@ public final class GLImageFormats {
|
|||||||
formatComp(formatToGL, Format.ETC1, GLExt.GL_ETC1_RGB8_OES, GL.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
formatComp(formatToGL, Format.ETC1, GLExt.GL_ETC1_RGB8_OES, GL.GL_RGB, GL.GL_UNSIGNED_BYTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Integer formats
|
||||||
|
if(caps.contains(Caps.IntegerTexture)) {
|
||||||
|
format(formatToGL, Format.R8I, GL3.GL_R8I, GL3.GL_RED_INTEGER, GL.GL_BYTE);
|
||||||
|
format(formatToGL, Format.R8UI, GL3.GL_R8UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_BYTE);
|
||||||
|
format(formatToGL, Format.R16I, GL3.GL_R16I, GL3.GL_RED_INTEGER, GL.GL_SHORT);
|
||||||
|
format(formatToGL, Format.R16UI, GL3.GL_R16UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_SHORT);
|
||||||
|
format(formatToGL, Format.R32I, GL3.GL_R32I, GL3.GL_RED_INTEGER, GL.GL_INT);
|
||||||
|
format(formatToGL, Format.R32UI, GL3.GL_R32UI, GL3.GL_RED_INTEGER, GL.GL_UNSIGNED_INT);
|
||||||
|
|
||||||
|
format(formatToGL, Format.RG8I, GL3.GL_RG8I, GL3.GL_RG_INTEGER, GL.GL_BYTE);
|
||||||
|
format(formatToGL, Format.RG8UI, GL3.GL_RG8UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_BYTE);
|
||||||
|
format(formatToGL, Format.RG16I, GL3.GL_RG16I, GL3.GL_RG_INTEGER, GL.GL_SHORT);
|
||||||
|
format(formatToGL, Format.RG16UI, GL3.GL_RG16UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_SHORT);
|
||||||
|
format(formatToGL, Format.RG32I, GL3.GL_RG32I, GL3.GL_RG_INTEGER, GL.GL_INT);
|
||||||
|
format(formatToGL, Format.RG32UI, GL3.GL_RG32UI, GL3.GL_RG_INTEGER, GL.GL_UNSIGNED_INT);
|
||||||
|
|
||||||
|
format(formatToGL, Format.RGB8I, GL3.GL_RGB8I, GL3.GL_RGB_INTEGER, GL.GL_BYTE);
|
||||||
|
format(formatToGL, Format.RGB8UI, GL3.GL_RGB8UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_BYTE);
|
||||||
|
format(formatToGL, Format.RGB16I, GL3.GL_RGB16I, GL3.GL_RGB_INTEGER, GL.GL_SHORT);
|
||||||
|
format(formatToGL, Format.RGB16UI, GL3.GL_RGB16UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_SHORT);
|
||||||
|
format(formatToGL, Format.RGB32I, GL3.GL_RGB32I, GL3.GL_RGB_INTEGER, GL.GL_INT);
|
||||||
|
format(formatToGL, Format.RGB32UI, GL3.GL_RGB32UI, GL3.GL_RGB_INTEGER, GL.GL_UNSIGNED_INT);
|
||||||
|
|
||||||
|
format(formatToGL, Format.RGBA8I, GL3.GL_RGBA8I, GL3.GL_RGBA_INTEGER, GL.GL_BYTE);
|
||||||
|
format(formatToGL, Format.RGBA8UI, GL3.GL_RGBA8UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_BYTE);
|
||||||
|
format(formatToGL, Format.RGBA16I, GL3.GL_RGBA16I, GL3.GL_RGBA_INTEGER, GL.GL_SHORT);
|
||||||
|
format(formatToGL, Format.RGBA16UI, GL3.GL_RGBA16UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_SHORT);
|
||||||
|
format(formatToGL, Format.RGBA32I, GL3.GL_RGBA32I, GL3.GL_RGBA_INTEGER, GL.GL_INT);
|
||||||
|
format(formatToGL, Format.RGBA32UI, GL3.GL_RGBA32UI, GL3.GL_RGBA_INTEGER, GL.GL_UNSIGNED_INT);
|
||||||
|
}
|
||||||
|
|
||||||
return formatToGL;
|
return formatToGL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,6 +299,10 @@ public final class GLRenderer implements Renderer {
|
|||||||
caps.add(Caps.FloatTexture);
|
caps.add(Caps.FloatTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// integer texture format extensions
|
||||||
|
if(hasExtension("GL_EXT_texture_integer") || caps.contains(Caps.OpenGL30))
|
||||||
|
caps.add(Caps.IntegerTexture);
|
||||||
|
|
||||||
if (hasExtension("GL_OES_depth_texture") || gl2 != null) {
|
if (hasExtension("GL_OES_depth_texture") || gl2 != null) {
|
||||||
caps.add(Caps.DepthTexture);
|
caps.add(Caps.DepthTexture);
|
||||||
|
|
||||||
|
@ -9,9 +9,6 @@ package com.jme3.scene;
|
|||||||
public abstract class GeometryGroupNode extends Node {
|
public abstract class GeometryGroupNode extends Node {
|
||||||
|
|
||||||
public static int getGeometryStartIndex(Geometry geom) {
|
public static int getGeometryStartIndex(Geometry geom) {
|
||||||
if (geom.startIndex == -1) {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
return geom.startIndex;
|
return geom.startIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ import com.jme3.material.Technique;
|
|||||||
import com.jme3.material.TechniqueDef;
|
import com.jme3.material.TechniqueDef;
|
||||||
import com.jme3.shader.Shader.ShaderType;
|
import com.jme3.shader.Shader.ShaderType;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the base for a shader generator using the ShaderNodes system,
|
* This class is the base for a shader generator using the ShaderNodes system,
|
||||||
@ -60,6 +61,10 @@ public abstract class ShaderGenerator {
|
|||||||
* the technique def to use for the shader generation
|
* the technique def to use for the shader generation
|
||||||
*/
|
*/
|
||||||
protected TechniqueDef techniqueDef = null;
|
protected TechniqueDef techniqueDef = null;
|
||||||
|
/**
|
||||||
|
* Extension pattern
|
||||||
|
*/
|
||||||
|
Pattern extensions = Pattern.compile("(#extension.*\\s+)");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a shaderGenerator
|
* Build a shaderGenerator
|
||||||
@ -142,7 +147,23 @@ public abstract class ShaderGenerator {
|
|||||||
|
|
||||||
sourceDeclaration.append(source);
|
sourceDeclaration.append(source);
|
||||||
|
|
||||||
return sourceDeclaration.toString();
|
return moveExtensionsUp(sourceDeclaration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parses the source and moves all the extensions at the top of the shader source as having extension declarations
|
||||||
|
* in the middle of a shader is against the specs and not supported by all drivers.
|
||||||
|
* @param sourceDeclaration
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String moveExtensionsUp(StringBuilder sourceDeclaration) {
|
||||||
|
Matcher m = extensions.matcher( sourceDeclaration.toString());
|
||||||
|
StringBuilder finalSource = new StringBuilder();
|
||||||
|
while(m.find()){
|
||||||
|
finalSource.append(m.group());
|
||||||
|
}
|
||||||
|
finalSource.append(m.replaceAll(""));
|
||||||
|
return finalSource.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,7 +94,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|||||||
protected CompareMode shadowCompareMode = CompareMode.Hardware;
|
protected CompareMode shadowCompareMode = CompareMode.Hardware;
|
||||||
protected Picture[] dispPic;
|
protected Picture[] dispPic;
|
||||||
protected RenderState forcedRenderState = new RenderState();
|
protected RenderState forcedRenderState = new RenderState();
|
||||||
protected Boolean renderBackFacesShadows;
|
protected Boolean renderBackFacesShadows = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true if the fallback material should be used, otherwise false
|
* true if the fallback material should be used, otherwise false
|
||||||
@ -725,7 +725,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the shadow edges thickness. default is 1, setting it to lower values
|
* Sets the shadow edges thickness. default is 10, setting it to lower values
|
||||||
* can help to reduce the jagged effect of the shadow edges
|
* can help to reduce the jagged effect of the shadow edges
|
||||||
*
|
*
|
||||||
* @param edgesThickness
|
* @param edgesThickness
|
||||||
|
@ -145,7 +145,7 @@ public class DirectionalLightShadowRenderer extends AbstractShadowRenderer {
|
|||||||
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
|
float frustumNear = Math.max(viewCam.getFrustumNear(), 0.001f);
|
||||||
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
|
ShadowUtil.updateFrustumPoints(viewCam, frustumNear, zFar, 1.0f, points);
|
||||||
|
|
||||||
//shadowCam.setDirection(direction);
|
shadowCam.setFrustumFar(zFar);
|
||||||
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp());
|
shadowCam.getRotation().lookAt(light.getDirection(), shadowCam.getUp());
|
||||||
shadowCam.update();
|
shadowCam.update();
|
||||||
shadowCam.updateViewProjection();
|
shadowCam.updateViewProjection();
|
||||||
|
@ -465,7 +465,7 @@ public class ShadowUtil {
|
|||||||
shadowCam.setProjectionMatrix(null);
|
shadowCam.setProjectionMatrix(null);
|
||||||
|
|
||||||
if (ortho) {
|
if (ortho) {
|
||||||
shadowCam.setFrustum(-1, 1, -1, 1, 1, -1);
|
shadowCam.setFrustum(-shadowCam.getFrustumFar(), shadowCam.getFrustumFar(), -1, 1, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create transform to rotate points to viewspace
|
// create transform to rotate points to viewspace
|
||||||
|
@ -510,15 +510,18 @@ public class FrameBuffer extends NativeObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The first color buffer attached to this FrameBuffer, or null
|
* @return The color buffer with the index set by {@link #setTargetIndex(int), or null
|
||||||
* if no color buffers are attached.
|
* if no color buffers are attached.
|
||||||
|
* If MRT is disabled, the first color buffer is returned.
|
||||||
*/
|
*/
|
||||||
public RenderBuffer getColorBuffer() {
|
public RenderBuffer getColorBuffer() {
|
||||||
if (colorBufs.isEmpty())
|
if (colorBufs.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
if (colorBufIndex<0 || colorBufIndex>=colorBufs.size()) {
|
||||||
return colorBufs.get(0);
|
return colorBufs.get(0);
|
||||||
}
|
}
|
||||||
|
return colorBufs.get(colorBufIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The depth buffer attached to this FrameBuffer, or null
|
* @return The depth buffer attached to this FrameBuffer, or null
|
||||||
|
@ -299,7 +299,33 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
|
|||||||
*
|
*
|
||||||
* Requires {@link Caps#TextureCompressionETC1}.
|
* Requires {@link Caps#TextureCompressionETC1}.
|
||||||
*/
|
*/
|
||||||
ETC1(4, false, true, false);
|
ETC1(4, false, true, false),
|
||||||
|
|
||||||
|
R8I(8),
|
||||||
|
R8UI(8),
|
||||||
|
R16I(16),
|
||||||
|
R16UI(16),
|
||||||
|
R32I(32),
|
||||||
|
R32UI(32),
|
||||||
|
RG8I(16),
|
||||||
|
RG8UI(16),
|
||||||
|
RG16I(32),
|
||||||
|
RG16UI(32),
|
||||||
|
RG32I(64),
|
||||||
|
RG32UI(64),
|
||||||
|
RGB8I(24),
|
||||||
|
RGB8UI(24),
|
||||||
|
RGB16I(48),
|
||||||
|
RGB16UI(48),
|
||||||
|
RGB32I(96),
|
||||||
|
RGB32UI(96),
|
||||||
|
RGBA8I(32),
|
||||||
|
RGBA8UI(32),
|
||||||
|
RGBA16I(64),
|
||||||
|
RGBA16UI(64),
|
||||||
|
RGBA32I(128),
|
||||||
|
RGBA32UI(128)
|
||||||
|
;
|
||||||
|
|
||||||
private int bpp;
|
private int bpp;
|
||||||
private boolean isDepth;
|
private boolean isDepth;
|
||||||
|
@ -698,9 +698,11 @@ public class ListSort<T> {
|
|||||||
System.arraycopy(arr, iterB, arr, dest, lengthB);
|
System.arraycopy(arr, iterB, arr, dest, lengthB);
|
||||||
// The last element of run A belongs at the end of the merge.
|
// The last element of run A belongs at the end of the merge.
|
||||||
arr[dest + lengthB] = tempArray[iterA];
|
arr[dest + lengthB] = tempArray[iterA];
|
||||||
} else if(lengthA== 0){
|
} else if(lengthA == 0){
|
||||||
throw new UnsupportedOperationException("Compare function result changed! " +
|
throw new UnsupportedOperationException("Compare function result changed! " +
|
||||||
"Make sure you do not modify the scene from another thread!");
|
"Make sure you do not modify the scene from"
|
||||||
|
+ " another thread and that the comparisons are not based"
|
||||||
|
+ " on NaN values.");
|
||||||
} else {//Fail label
|
} else {//Fail label
|
||||||
System.arraycopy(tempArray, iterA, arr, dest, lengthA);
|
System.arraycopy(tempArray, iterA, arr, dest, lengthA);
|
||||||
}
|
}
|
||||||
|
@ -226,23 +226,7 @@ public class TangentBinormalGenerator {
|
|||||||
processTriangleData(mesh, vertices, approxTangents,splitMirrored);
|
processTriangleData(mesh, vertices, approxTangents,splitMirrored);
|
||||||
|
|
||||||
//if the mesh has a bind pose, we need to generate the bind pose for the tangent buffer
|
//if the mesh has a bind pose, we need to generate the bind pose for the tangent buffer
|
||||||
if (mesh.getBuffer(Type.BindPosePosition) != null) {
|
TangentUtils.generateBindPoseTangentsIfNecessary(mesh);
|
||||||
|
|
||||||
VertexBuffer tangents = mesh.getBuffer(Type.Tangent);
|
|
||||||
if (tangents != null) {
|
|
||||||
VertexBuffer bindTangents = new VertexBuffer(Type.BindPoseTangent);
|
|
||||||
bindTangents.setupData(Usage.CpuOnly,
|
|
||||||
4,
|
|
||||||
Format.Float,
|
|
||||||
BufferUtils.clone(tangents.getData()));
|
|
||||||
|
|
||||||
if (mesh.getBuffer(Type.BindPoseTangent) != null) {
|
|
||||||
mesh.clearBuffer(Type.BindPoseTangent);
|
|
||||||
}
|
|
||||||
mesh.setBuffer(bindTangents);
|
|
||||||
tangents.setUsage(Usage.Stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generate(Mesh mesh, boolean approxTangents) {
|
public static void generate(Mesh mesh, boolean approxTangents) {
|
||||||
|
29
jme3-core/src/main/java/com/jme3/util/TangentUtils.java
Normal file
29
jme3-core/src/main/java/com/jme3/util/TangentUtils.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package com.jme3.util;
|
||||||
|
|
||||||
|
import com.jme3.scene.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Nehon on 03/10/2016.
|
||||||
|
*/
|
||||||
|
public class TangentUtils {
|
||||||
|
|
||||||
|
public static void generateBindPoseTangentsIfNecessary(Mesh mesh){
|
||||||
|
if (mesh.getBuffer(VertexBuffer.Type.BindPosePosition) != null) {
|
||||||
|
|
||||||
|
VertexBuffer tangents = mesh.getBuffer(VertexBuffer.Type.Tangent);
|
||||||
|
if (tangents != null) {
|
||||||
|
VertexBuffer bindTangents = new VertexBuffer(VertexBuffer.Type.BindPoseTangent);
|
||||||
|
bindTangents.setupData(VertexBuffer.Usage.CpuOnly,
|
||||||
|
4,
|
||||||
|
VertexBuffer.Format.Float,
|
||||||
|
BufferUtils.clone(tangents.getData()));
|
||||||
|
|
||||||
|
if (mesh.getBuffer(VertexBuffer.Type.BindPoseTangent) != null) {
|
||||||
|
mesh.clearBuffer(VertexBuffer.Type.BindPoseTangent);
|
||||||
|
}
|
||||||
|
mesh.setBuffer(bindTangents);
|
||||||
|
tangents.setUsage(VertexBuffer.Usage.Stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,9 @@ package com.jme3.util.mikktspace;
|
|||||||
|
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Geometry;
|
import com.jme3.scene.*;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.util.*;
|
||||||
import com.jme3.scene.Spatial;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -84,6 +84,7 @@ public class MikktspaceTangentGenerator {
|
|||||||
if(!genTangSpaceDefault(context)){
|
if(!genTangSpaceDefault(context)){
|
||||||
Logger.getLogger(MikktspaceTangentGenerator.class.getName()).log(Level.SEVERE, "Failed to generate tangents for geometry " + g.getName());
|
Logger.getLogger(MikktspaceTangentGenerator.class.getName()).log(Level.SEVERE, "Failed to generate tangents for geometry " + g.getName());
|
||||||
}
|
}
|
||||||
|
TangentUtils.generateBindPoseTangentsIfNecessary(g.getMesh());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
#import "Common/ShaderLib/PBR.glsllib"
|
||||||
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
#import "Common/ShaderLib/GLSLCompat.glsllib"
|
||||||
#import "Common/ShaderLib/Parallax.glsllib"
|
#import "Common/ShaderLib/Parallax.glsllib"
|
||||||
#import "Common/ShaderLib/PBR.glsllib"
|
|
||||||
#import "Common/ShaderLib/Lighting.glsllib"
|
#import "Common/ShaderLib/Lighting.glsllib"
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ void main(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FADE
|
#ifdef FADE
|
||||||
shadow = max(0.0,mix(shadow,1.0,(shadowPosition - m_FadeInfo.x) * m_FadeInfo.y));
|
shadow = max(0.0, mix(shadow, 1.0, max(0.0, (shadowPosition - m_FadeInfo.x) * m_FadeInfo.y)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
|
shadow = shadow * m_ShadowIntensity + (1.0 - m_ShadowIntensity);
|
||||||
|
@ -136,11 +136,6 @@ vec4 main_multiSample(in int numSample){
|
|||||||
|
|
||||||
void main(){
|
void main(){
|
||||||
|
|
||||||
#if !defined( RENDER_SHADOWS )
|
|
||||||
outFragColor = fetchTextureSample(m_Texture,texCoord,0);
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RESOLVE_MS
|
#ifdef RESOLVE_MS
|
||||||
vec4 color = vec4(0.0);
|
vec4 color = vec4(0.0);
|
||||||
for (int i = 0; i < m_NumSamples; i++){
|
for (int i = 0; i < m_NumSamples; i++){
|
||||||
|
@ -33,11 +33,11 @@ package jme3test.light.pbr;
|
|||||||
|
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.bounding.BoundingSphere;
|
import com.jme3.bounding.BoundingSphere;
|
||||||
|
import com.jme3.environment.util.*;
|
||||||
import com.jme3.light.LightProbe;
|
import com.jme3.light.LightProbe;
|
||||||
import com.jme3.environment.LightProbeFactory;
|
import com.jme3.environment.LightProbeFactory;
|
||||||
import com.jme3.environment.EnvironmentCamera;
|
import com.jme3.environment.EnvironmentCamera;
|
||||||
import com.jme3.environment.generation.JobProgressAdapter;
|
import com.jme3.environment.generation.JobProgressAdapter;
|
||||||
import com.jme3.environment.util.LightsDebugState;
|
|
||||||
import com.jme3.input.ChaseCamera;
|
import com.jme3.input.ChaseCamera;
|
||||||
import com.jme3.input.KeyInput;
|
import com.jme3.input.KeyInput;
|
||||||
import com.jme3.input.controls.ActionListener;
|
import com.jme3.input.controls.ActionListener;
|
||||||
@ -71,6 +71,10 @@ public class TestPBRLighting extends SimpleApplication {
|
|||||||
TestPBRLighting app = new TestPBRLighting();
|
TestPBRLighting app = new TestPBRLighting();
|
||||||
app.start();
|
app.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Node tex;
|
||||||
|
private Node tex2;
|
||||||
|
|
||||||
private Geometry model;
|
private Geometry model;
|
||||||
private DirectionalLight dl;
|
private DirectionalLight dl;
|
||||||
private Node modelNode;
|
private Node modelNode;
|
||||||
@ -135,7 +139,17 @@ public class TestPBRLighting extends SimpleApplication {
|
|||||||
@Override
|
@Override
|
||||||
public void onAction(String name, boolean isPressed, float tpf) {
|
public void onAction(String name, boolean isPressed, float tpf) {
|
||||||
if (name.equals("debug") && isPressed) {
|
if (name.equals("debug") && isPressed) {
|
||||||
//envCam.toggleDebug();
|
if (tex == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tex.getParent() == null && tex2.getParent() == null) {
|
||||||
|
guiNode.attachChild(tex);
|
||||||
|
} else if (tex2.getParent() == null){
|
||||||
|
tex.removeFromParent();
|
||||||
|
guiNode.attachChild(tex2);
|
||||||
|
} else {
|
||||||
|
tex2.removeFromParent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("up") && isPressed) {
|
if (name.equals("up") && isPressed) {
|
||||||
@ -183,6 +197,8 @@ public class TestPBRLighting extends SimpleApplication {
|
|||||||
@Override
|
@Override
|
||||||
public void done(LightProbe result) {
|
public void done(LightProbe result) {
|
||||||
System.err.println("Done rendering env maps");
|
System.err.println("Done rendering env maps");
|
||||||
|
tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
|
||||||
|
tex2 = EnvMapUtils.getCubeMapCrossDebugView(result.getIrradianceMap(), assetManager);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((BoundingSphere)probe.getBounds()).setRadius(100);
|
((BoundingSphere)probe.getBounds()).setRadius(100);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user