Deprecate TechniqueDef.isUsingShaders(). Do not use it anywhere in the engine.

experimental
shadowislord 10 years ago
parent 4db0acaca9
commit a7517c17c0
  1. 7
      jme3-core/src/main/java/com/jme3/material/MatParam.java
  2. 2
      jme3-core/src/main/java/com/jme3/material/MatParamTexture.java
  3. 17
      jme3-core/src/main/java/com/jme3/material/Material.java
  4. 8
      jme3-core/src/main/java/com/jme3/material/Technique.java
  5. 7
      jme3-core/src/main/java/com/jme3/material/TechniqueDef.java

@ -130,11 +130,8 @@ public class MatParam implements Savable, Cloneable {
} }
void apply(Renderer r, Technique technique) { void apply(Renderer r, Technique technique) {
TechniqueDef techDef = technique.getDef();
if (techDef.isUsingShaders()) {
technique.updateUniformParam(getPrefixedName(), getVarType(), getValue()); technique.updateUniformParam(getPrefixedName(), getVarType(), getValue());
} }
}
/** /**
* Returns the material parameter value as it would appear in a J3M * Returns the material parameter value as it would appear in a J3M
@ -343,6 +340,10 @@ When arrays can be inserted in J3M files
@Override @Override
public String toString() { public String toString() {
if (value != null) {
return type.name() + " " + name + " : " + getValueAsString(); return type.name() + " " + name + " : " + getValueAsString();
} else {
return type.name() + " " + name;
}
} }
} }

@ -110,10 +110,8 @@ public class MatParamTexture extends MatParam {
public void apply(Renderer r, Technique technique) { public void apply(Renderer r, Technique technique) {
TechniqueDef techDef = technique.getDef(); TechniqueDef techDef = technique.getDef();
r.setTexture(getUnit(), getTextureValue()); r.setTexture(getUnit(), getTextureValue());
if (techDef.isUsingShaders()) {
technique.updateUniformParam(getPrefixedName(), getVarType(), getUnit()); technique.updateUniformParam(getPrefixedName(), getVarType(), getUnit());
} }
}
@Override @Override
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {

@ -150,7 +150,7 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
/** /**
* This method sets the name of the material. * This method sets the name of the material.
* The name is not the same as the asset name. * The name is not the same as the asset name.
* It can be null and there is no guarantee of its uniqness. * It can be null and there is no guarantee of its uniqueness.
* @param name the name of the material * @param name the name of the material
*/ */
public void setName(String name) { public void setName(String name) {
@ -1060,18 +1060,11 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
MatParamTexture texParam = (MatParamTexture) param; MatParamTexture texParam = (MatParamTexture) param;
r.setTexture(0, texParam.getTextureValue()); r.setTexture(0, texParam.getTextureValue());
} else { } else {
if (!techDef.isUsingShaders()) {
continue;
}
technique.updateUniformParam(param.getName(), param.getVarType(), param.getValue()); technique.updateUniformParam(param.getName(), param.getVarType(), param.getValue());
} }
} }
Shader shader = technique.getShader(); r.setShader(technique.getShader());
if (techDef.isUsingShaders()) {
r.setShader(shader);
}
} }
private void clearUniformsSetByCurrent(Shader shader) { private void clearUniformsSetByCurrent(Shader shader) {
@ -1182,11 +1175,11 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
// update camera and world matrices // update camera and world matrices
// NOTE: setWorldTransform should have been called already // NOTE: setWorldTransform should have been called already
if (techDef.isUsingShaders()) {
// reset unchanged uniform flag // reset unchanged uniform flag
clearUniformsSetByCurrent(technique.getShader()); clearUniformsSetByCurrent(technique.getShader());
rm.updateUniformBindings(technique.getWorldBindUniforms()); rm.updateUniformBindings(technique.getWorldBindUniforms());
}
// setup textures and uniforms // setup textures and uniforms
for (int i = 0; i < paramValues.size(); i++) { for (int i = 0; i < paramValues.size(); i++) {
@ -1220,11 +1213,9 @@ public class Material implements CloneableSmartAsset, Cloneable, Savable {
} }
// upload and bind shader // upload and bind shader
if (techDef.isUsingShaders()) {
// any unset uniforms will be set to 0 // any unset uniforms will be set to 0
resetUniformsNotSetByCurrent(shader); resetUniformsNotSetByCurrent(shader);
r.setShader(shader); r.setShader(shader);
}
renderMeshFromGeometry(r, geom); renderMeshFromGeometry(r, geom);
} }

@ -63,11 +63,9 @@ public class Technique /* implements Savable */ {
public Technique(Material owner, TechniqueDef def) { public Technique(Material owner, TechniqueDef def) {
this.owner = owner; this.owner = owner;
this.def = def; this.def = def;
if (def.isUsingShaders()) {
this.worldBindUniforms = new ArrayList<Uniform>(); this.worldBindUniforms = new ArrayList<Uniform>();
this.defines = new DefineList(); this.defines = new DefineList();
} }
}
/** /**
* Serialization only. Do not use. * Serialization only. Do not use.
@ -173,11 +171,6 @@ public class Technique /* implements Savable */ {
* @param assetManager The asset manager to use for loading shaders. * @param assetManager The asset manager to use for loading shaders.
*/ */
public void makeCurrent(AssetManager assetManager, boolean techniqueSwitched, EnumSet<Caps> rendererCaps, RenderManager rm) { public void makeCurrent(AssetManager assetManager, boolean techniqueSwitched, EnumSet<Caps> rendererCaps, RenderManager rm) {
if (!def.isUsingShaders()) {
// No shaders are used, no processing is neccessary.
return;
}
if (techniqueSwitched) { if (techniqueSwitched) {
if (defines.update(owner.getParamsMap(), def)) { if (defines.update(owner.getParamsMap(), def)) {
needReload = true; needReload = true;
@ -188,7 +181,6 @@ public class Technique /* implements Savable */ {
} else { } else {
defines.set("SINGLE_PASS_LIGHTING", VarType.Boolean, null); defines.set("SINGLE_PASS_LIGHTING", VarType.Boolean, null);
} }
} }
if (needReload) { if (needReload) {

@ -208,12 +208,9 @@ public class TechniqueDef implements Savable {
} }
/** /**
* Returns true if this technique uses shaders, false otherwise. * @deprecated jME3 always requires shaders now
*
* @return true if this technique uses shaders, false otherwise.
*
* @see #setShaderFile(java.lang.String, java.lang.String, java.lang.String)
*/ */
@Deprecated
public boolean isUsingShaders(){ public boolean isUsingShaders(){
return usesShaders; return usesShaders;
} }

Loading…
Cancel
Save