Johann Woelper 10 tahun lalu
induk
melakukan
a9063689de
3 mengubah file dengan 24 tambahan dan 12 penghapusan
  1. 19 9
      lmapper/bake.py
  2. 4 2
      lmapper/scene_all.rib
  3. 1 1
      lmapper/shaders/lm_disp.sl

+ 19 - 9
lmapper/bake.py

@@ -9,7 +9,9 @@ platform = sys.platform
 
 SHADERS = 'shaders'
 TEXTURES = 'textures'
-RES = 8192
+RES = 2048
+
+# /// ENV SETUP
 
 os.environ['DL_SHADERS_PATH'] = os.path.join(root, SHADERS)
 os.environ['DL_TEXTURES_PATH'] = os.path.join(root, TEXTURES)
@@ -17,10 +19,16 @@ os.environ['DL_TEXTURES_PATH'] = os.path.join(root, TEXTURES)
 if platform == 'linux2':
     print 'running linux'
     DELIGHT = '/usr/local/3delight-12.0.19/Linux-x86_64'
-    os.environ['DELIGHT'] = DELIGHT
-    sys.path.append(os.path.join(DELIGHT, 'bin'))
+    #os.environ['DELIGHT'] = DELIGHT
+    #sys.path.append(os.path.join(DELIGHT, 'bin'))
 elif platform == 'darwin':
-    os.environ['DELIGHT'] = '/Applications/3Delight'
+    DELIGHT = '/Applications/3Delight'
+
+os.environ['DELIGHT'] = DELIGHT
+sys.path.append(os.path.join(DELIGHT, 'bin'))
+DELIGHT_BIN_FOLDER = os.path.join(DELIGHT, 'bin')
+DELIGHT_BIN = os.path.join(DELIGHT_BIN_FOLDER, 'renderdl')
+TDLMAKE_BIN = os.path.join(DELIGHT_BIN_FOLDER, 'tdlmake')
 
 
 def cleanup():
@@ -38,11 +46,11 @@ def gen_includes(heightmap, disp_factor=1):
     
     for file in glob.glob('receiver/*'):
         basename = os.path.splitext(os.path.basename(file))[0]
+        dispsettings  = '\n\tDisplacement "lm_disp" "float offset" [.01] \n\t"float Km" [{2}] "string texname" ["textures/tweaked_heightmap.tdl"]'
+
         include = 'AttributeBegin\
         \n\tSurface "lm_bake" "string bakefile" ["{0}"] "string texColName" [""] "string texSpecName" [""] "float Ka" [0.5] "float Kd" [0.4] "float Ks" [0.5] "float roughness" [0.1]\
         \n\tAttribute "displacementbound" "sphere" [{3}]\
-        \n\tDisplacement "lm_disp" "float offset" [.01]\
-        \n\t"float Km" [{2}] "string texname" ["textures/tweaked_heightmap.tdl"]\
         \n\tReadArchive "{1}"]\
         \nAttributeEnd'.format(basename, file, disp_factor, disp_bound)
         includes.append(include)
@@ -52,9 +60,9 @@ def bake_post_render(root, res=RES):
     for bakefile in glob.glob(os.path.join(root, '*.bake')):
         bake_target = os.path.splitext(bakefile)[0]
         # tdlmake converts bake files to tdl only
-        cmd = ['tdlmake', '-nomipmap', '-progress', '-bakeres', str(res) + 'x' + str(res), bakefile, bake_target + '.tdl']
+        cmd = [TDLMAKE_BIN, '-nomipmap', '-progress', '-bakeres', str(res) + 'x' + str(res), bakefile, bake_target + '.tdl']
         subprocess.call(cmd)
-        cmd = ['tdlmake', '-nomipmap', '-progress', bake_target + '.tdl', bake_target + '.tif']
+        cmd = [TDLMAKE_BIN, '-nomipmap', '-progress', bake_target + '.tdl', bake_target + '.tif']
         subprocess.call(cmd)
 
 for include in  gen_includes('textures/tweaked_heightmap.tdl', 200):
@@ -62,7 +70,9 @@ for include in  gen_includes('textures/tweaked_heightmap.tdl', 200):
 
 cleanup()
 
-subprocess.call(['renderdl', '-res', str(RES), str(RES), '-id','-progress', 'options.rib'])
+
+
+subprocess.call([DELIGHT_BIN, '-res', str(RES), str(RES), '-id', '-progress', 'options.rib'])
 bake_post_render(root)
 
 

+ 4 - 2
lmapper/scene_all.rib

@@ -11,9 +11,11 @@
         # define meshes to bake / include in lighting simulation
 
 		AttributeBegin
-            Surface "lm_bake" "string bakefile" ["receiver"] "string texColName" [""] "string texSpecName" [""] "float Ka" [0.5] "float Kd" [0.4] "float Ks" [0.5] "float roughness" [0.1]
+            Surface "lm_bake" "string bakefile" ["receiver"] "float Ka" [0.5] "float Kd" [0.4] "float Ks" [0.5] "float roughness" [0.1]
             Attribute "displacementbound" "sphere" [210]
-            Displacement "lm_disp" "float offset" [.01] "float Km" [200] "string texname" ["textures/tweaked_heightmap.tdl"]
+            Displacement "lm_disp" "float offset" [0] "float Km" [0] "string texname" [""]
+            
+            #Displacement "lm_disp" "float offset" [0] "float Km" [10] "string texname" ["textures/height.tif"]
             ReadArchive "include.rib"
         AttributeEnd
     

+ 1 - 1
lmapper/shaders/lm_disp.sl

@@ -6,7 +6,7 @@ As with all baking-compatible
 shaders, one should not use 
 the faceforward() call.
 
-In-House disp worklflow is 0.5-based, meaning
+In-House disp workflow is 0.5-based, meaning
 that a magnitude of 0.5 does nothing, 0 goes inward,
 1 goes outward.
 *****************************/