Bugfix: fix to specular light loading. Taking intensity into consideration. Fix given by: pfannenwender.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10767 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
2bb849a0f3
commit
d6a1b63206
@ -90,7 +90,7 @@ public final class MaterialContext {
|
|||||||
|
|
||||||
int spec_shader = ((Number) structure.getFieldValue("spec_shader")).intValue();
|
int spec_shader = ((Number) structure.getFieldValue("spec_shader")).intValue();
|
||||||
specularShader = SpecularShader.values()[spec_shader];
|
specularShader = SpecularShader.values()[spec_shader];
|
||||||
specularColor = this.readSpecularColor(structure, specularShader);
|
specularColor = this.readSpecularColor(structure);
|
||||||
float shininess = ((Number) structure.getFieldValue("har")).floatValue();//this is (probably) the specular hardness in blender
|
float shininess = ((Number) structure.getFieldValue("har")).floatValue();//this is (probably) the specular hardness in blender
|
||||||
this.shininess = shininess > 0.0f ? shininess : MaterialHelper.DEFAULT_SHININESS;
|
this.shininess = shininess > 0.0f ? shininess : MaterialHelper.DEFAULT_SHININESS;
|
||||||
|
|
||||||
@ -385,26 +385,12 @@ public final class MaterialContext {
|
|||||||
* the material structure filled with data
|
* the material structure filled with data
|
||||||
* @return a specular color used by the material
|
* @return a specular color used by the material
|
||||||
*/
|
*/
|
||||||
private ColorRGBA readSpecularColor(Structure materialStructure, SpecularShader specularShader) {
|
private ColorRGBA readSpecularColor(Structure materialStructure) {
|
||||||
float r = ((Number) materialStructure.getFieldValue("specr")).floatValue();
|
float specularIntensity = ((Number) materialStructure.getFieldValue("spec")).floatValue();
|
||||||
float g = ((Number) materialStructure.getFieldValue("specg")).floatValue();
|
float r = ((Number) materialStructure.getFieldValue("specr")).floatValue() * specularIntensity;
|
||||||
float b = ((Number) materialStructure.getFieldValue("specb")).floatValue();
|
float g = ((Number) materialStructure.getFieldValue("specg")).floatValue() * specularIntensity;
|
||||||
|
float b = ((Number) materialStructure.getFieldValue("specb")).floatValue() * specularIntensity;
|
||||||
float alpha = ((Number) materialStructure.getFieldValue("alpha")).floatValue();
|
float alpha = ((Number) materialStructure.getFieldValue("alpha")).floatValue();
|
||||||
switch (specularShader) {
|
|
||||||
case BLINN:
|
|
||||||
case COOKTORRENCE:
|
|
||||||
case TOON:
|
|
||||||
case WARDISO:// TODO: find what is the proper modification
|
|
||||||
break;
|
|
||||||
case PHONG:// TODO: check if that is correct
|
|
||||||
float spec = ((Number) materialStructure.getFieldValue("spec")).floatValue();
|
|
||||||
r *= spec * 0.5f;
|
|
||||||
g *= spec * 0.5f;
|
|
||||||
b *= spec * 0.5f;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unknown specular shader type: " + specularShader.toString());
|
|
||||||
}
|
|
||||||
return new ColorRGBA(r, g, b, alpha);
|
return new ColorRGBA(r, g, b, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user