From f421e2a876c96e9402f490b7faf17141991eedad Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sat, 3 Sep 2011 22:39:02 +0000 Subject: [PATCH] * Removed shiny check in Lighting.frag (for ATI Radeon X1600 and similar) * Applying default values for materials inside old J3O files * Default shininess in TerrainLighting git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8163 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../Common/MatDefs/Light/Lighting.frag | 5 ++--- .../core/com/jme3/effect/ParticleEmitter.java | 1 - engine/src/core/com/jme3/material/Material.java | 17 ++++++++++++++++- .../com/jme3/niftygui/RenderDeviceJme.java | 2 -- .../com/jme3/niftygui/RenderFontJme.java | 2 -- .../Common/MatDefs/Terrain/TerrainLighting.j3md | 3 ++- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag index 2fb50f985..a07be92a4 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag @@ -93,9 +93,8 @@ float lightComputeDiffuse(in vec3 norm, in vec3 lightdir, in vec3 viewdir){ } float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in float shiny){ - if (shiny <= 1.0){ - return 0.0; - } + // NOTE: check for shiny <= 1 removed since shininess is now + // 1.0 by default (uses matdefs default vals) #ifdef LOW_QUALITY // Blinn-Phong // Note: preferably, H should be computed in the vertex shader diff --git a/engine/src/core/com/jme3/effect/ParticleEmitter.java b/engine/src/core/com/jme3/effect/ParticleEmitter.java index f96bec6da..df580c788 100644 --- a/engine/src/core/com/jme3/effect/ParticleEmitter.java +++ b/engine/src/core/com/jme3/effect/ParticleEmitter.java @@ -44,7 +44,6 @@ import com.jme3.export.OutputCapsule; import com.jme3.math.ColorRGBA; import com.jme3.math.FastMath; import com.jme3.math.Matrix3f; -import com.jme3.math.Quaternion; import com.jme3.math.Vector3f; import com.jme3.renderer.Camera; import com.jme3.renderer.RenderManager; diff --git a/engine/src/core/com/jme3/material/Material.java b/engine/src/core/com/jme3/material/Material.java index 6f02dbe69..3b88254be 100644 --- a/engine/src/core/com/jme3/material/Material.java +++ b/engine/src/core/com/jme3/material/Material.java @@ -81,6 +81,8 @@ import java.util.logging.Logger; */ public class Material implements Asset, Cloneable, Savable, Comparable { + public static final int SAVABLE_VERSION = 1; + private static final Logger logger = Logger.getLogger(Material.class.getName()); private static final RenderState additiveLight = new RenderState(); private static final RenderState depthOnly = new RenderState(); @@ -1046,6 +1048,7 @@ public class Material implements Asset, Cloneable, Savable, Comparable boolean enableVcolor = false; boolean separateTexCoord = false; + boolean applyDefaults = false; if (im.getFormatVersion() == 0) { // Enable compatibility with old models @@ -1069,6 +1072,9 @@ public class Material implements Asset, Cloneable, Savable, Comparable separateTexCoord = true; } } + applyDefaults = true; + }else if (ic.getSavableVersion(Material.class) == 0){ + applyDefaults = true; } def = (MaterialDef) im.getAssetManager().loadAsset(new AssetKey(defName)); @@ -1093,7 +1099,16 @@ public class Material implements Asset, Cloneable, Savable, Comparable param.setName(checkSetParam(param.getVarType(), param.getName())); paramValues.put(param.getName(), param); } - + + if (applyDefaults){ + // compatability with old versions where default vars were + // not available + for (MatParam param : def.getMaterialParams()){ + if (param.getValue() != null && paramValues.get(param.getName()) == null){ + setParam(param.getName(), param.getVarType(), param.getValue()); + } + } + } if (enableVcolor) { setBoolean("VertexColor", true); } diff --git a/engine/src/niftygui/com/jme3/niftygui/RenderDeviceJme.java b/engine/src/niftygui/com/jme3/niftygui/RenderDeviceJme.java index 22906a4e5..c711a9aff 100644 --- a/engine/src/niftygui/com/jme3/niftygui/RenderDeviceJme.java +++ b/engine/src/niftygui/com/jme3/niftygui/RenderDeviceJme.java @@ -187,9 +187,7 @@ public class RenderDeviceJme implements RenderDevice { RenderFontJme jmeFont = (RenderFontJme) font; BitmapText text = jmeFont.getText(); - // WARNING: Not compatible with OpenGL1 implementations.. niftyMat.setColor("Color", convertColor(color, tempColor)); - niftyMat.setBoolean("UseTex", true); niftyMat.getAdditionalRenderState().setBlendMode(convertBlend()); text.setMaterial(niftyMat); diff --git a/engine/src/niftygui/com/jme3/niftygui/RenderFontJme.java b/engine/src/niftygui/com/jme3/niftygui/RenderFontJme.java index 744d45403..e95b2f53d 100644 --- a/engine/src/niftygui/com/jme3/niftygui/RenderFontJme.java +++ b/engine/src/niftygui/com/jme3/niftygui/RenderFontJme.java @@ -34,8 +34,6 @@ package com.jme3.niftygui; import com.jme3.font.BitmapFont; import com.jme3.font.BitmapText; -import com.jme3.texture.Texture; -import com.jme3.texture.Texture2D; import de.lessvoid.nifty.spi.render.RenderFont; public class RenderFontJme implements RenderFont { diff --git a/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.j3md b/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.j3md index cc4dae1bb..0c48999ac 100644 --- a/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.j3md +++ b/engine/src/terrain/Common/MatDefs/Terrain/TerrainLighting.j3md @@ -1,3 +1,4 @@ +// NOTE: Doesn't support OpenGL1 MaterialDef Terrain Lighting { MaterialParameters { @@ -21,7 +22,7 @@ MaterialDef Terrain Lighting { Color Specular // Specular power/shininess - Float Shininess + Float Shininess : 1 // Texture map #0 Texture2D DiffuseMap