Browse Source

3DSMax Exporter - Corrected specular export, support Phong

Made a correction to the way the specular coefficient is exported; this was using the 3DSMax "Glossiness" attribute. It has been corrected to use the 3DSMax material "Specular Level". The "Glossiness" has been correctly remapped to the "Shininess" three.js attribute. 

Additionally included Phong shading, so the three.js Phong material will be used if Phong when used in 3DSMax - without this the bump maps are disregarded as they aren't rendered with Lambert materials (default material when unspecified). Blinn/Metal ShaderType materials will continue to be exported as Lambert.
Rab Hallett 11 years ago
parent
commit
fc65272574
1 changed files with 10 additions and 5 deletions
  1. 10 5
      utils/exporters/max/ThreeJSExporter.ms

+ 10 - 5
utils/exporters/max/ThreeJSExporter.ms

@@ -484,11 +484,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				DumpColor mat.ambient  "colorAmbient"
 				DumpColor mat.specular "colorSpecular"
 
-				t = mat.opacity / 100
-				s = mat.glossiness
+				transparency = mat.opacity / 100
 
-				Format "\"transparency\"  : %,\n" t to:ostream
-				Format "\"specularCoef\"  : %,\n" s to:ostream
+				Format "\"transparency\"  : %,\n" transparency to:ostream
+				Format "\"specularCoef\"  : %,\n" mat.specularLevel to:ostream
+				Format "\"shininess\"  : %,\n" mat.glossiness to:ostream
 
 				-- maps
 
@@ -497,6 +497,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				DumpMap mat.specularMap "mapSpecular"
 				DumpMap mat.bumpMap 	"mapBump"
 				DumpMap mat.opacityMap 	"mapAlpha"
+				
+				if mat.shaderByName == "Phong" then
+				(
+					Format "\"shading\" : \"phong\",\n" to:ostream
+				)
 
 			)
 			else
@@ -1071,4 +1076,4 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	)
 
 )
-createDialog ThreeJSExporter width:300
+createDialog ThreeJSExporter width:300