Changeset View
Changeset View
Standalone View
Standalone View
render_povray/shading.py
| Context not available. | |||||
| frontDiffuse = min(frontDiffuse, (1.0 - backDiffuse)) | frontDiffuse = min(frontDiffuse, (1.0 - backDiffuse)) | ||||
| # map hardness between 0.0 and 1.0 | # map hardness between 0.0 and 1.0 | ||||
| roughness = ((1.0 - ((material.specular_hardness - 1.0) / 510.0))) | roughness = (1.0 - ((material.specular_hardness - 1.0) / 510.0)) | ||||
| ## scale from 0.0 to 0.1 | ## scale from 0.0 to 0.1 | ||||
| roughness *= 0.1 | roughness *= 0.1 | ||||
| # add a small value because 0.0 is invalid. | # add a small value because 0.0 is invalid. | ||||
| Context not available. | |||||
| # No difference between phong and cook torrence in blender HaHa! | # No difference between phong and cook torrence in blender HaHa! | ||||
| if (material.specular_shader == 'COOKTORR' or | if (material.specular_shader == 'COOKTORR' or | ||||
| material.specular_shader == 'PHONG'): | material.specular_shader == 'PHONG'): | ||||
| tabWrite("phong %.3g\n" % (material.specular_intensity)) | tabWrite("phong %.3g\n" % material.specular_intensity) | ||||
| tabWrite("phong_size %.3g\n" % (material.specular_hardness / 2 + 0.25)) | tabWrite("phong_size %.3g\n" % (material.specular_hardness / 2 + 0.25)) | ||||
| # POV-Ray 'specular' keyword corresponds to a Blinn model, without the ior. | # POV-Ray 'specular' keyword corresponds to a Blinn model, without the ior. | ||||
| Context not available. | |||||
| tabWrite("reflection {\n") | tabWrite("reflection {\n") | ||||
| tabWrite("rgb <%.3g, %.3g, %.3g>\n" % material.mirror_color[:]) | tabWrite("rgb <%.3g, %.3g, %.3g>\n" % material.mirror_color[:]) | ||||
| if material.pov.mirror_metallic: | if material.pov.mirror_metallic: | ||||
| tabWrite("metallic %.3g\n" % (raytrace_mirror.reflect_factor)) | tabWrite("metallic %.3g\n" % raytrace_mirror.reflect_factor) | ||||
| # Blurry reflections for UberPOV | # Blurry reflections for UberPOV | ||||
| if using_uberpov and raytrace_mirror.gloss_factor < 1.0: | if using_uberpov and raytrace_mirror.gloss_factor < 1.0: | ||||
| #tabWrite("#ifdef(unofficial) #if(unofficial = \"patch\") #if(patch(\"upov-reflection-roughness\") > 0)\n") | #tabWrite("#ifdef(unofficial) #if(unofficial = \"patch\") #if(patch(\"upov-reflection-roughness\") > 0)\n") | ||||
| Context not available. | |||||
| texStrg+="#declare f%s=\n"%PATname | texStrg+="#declare f%s=\n"%PATname | ||||
| texStrg+="function{pigment{%s}}\n"%PATname | texStrg+="function{pigment{%s}}\n"%PATname | ||||
| texStrg+="\n" | texStrg+="\n" | ||||
| return(texStrg) | return texStrg | ||||
| def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, lampCount, | def writeTextureInfluence(mater, materialNames, LocalMaterialNames, path_image, lampCount, | ||||
| Context not available. | |||||
| trans = 1.0 - mater.alpha | trans = 1.0 - mater.alpha | ||||
| else: | else: | ||||
| trans = 0.0 | trans = 0.0 | ||||
| if ((mater.specular_color.s == 0.0) or (mater.diffuse_shader == 'MINNAERT')): | if (mater.specular_color.s == 0.0) or (mater.diffuse_shader == 'MINNAERT'): | ||||
| # No layered texture because of aoi pattern used for minnaert and pov can't layer patterned | # No layered texture because of aoi pattern used for minnaert and pov can't layer patterned | ||||
| colored_specular_found = False | colored_specular_found = False | ||||
| else: | else: | ||||
| Context not available. | |||||
| for t in mater.texture_slots: | for t in mater.texture_slots: | ||||
| if t and (t.use and (t.texture is not None)): | if t and (t.use and (t.texture is not None)): | ||||
| # 'NONE' ('NONE' type texture is different from no texture covered above) | # 'NONE' ('NONE' type texture is different from no texture covered above) | ||||
| if (t.texture.type == 'NONE' and t.texture.pov.tex_pattern_type == 'emulator'): | if t.texture.type == 'NONE' and t.texture.pov.tex_pattern_type == 'emulator': | ||||
| continue # move to next slot | continue # move to next slot | ||||
| # PROCEDURAL | # PROCEDURAL | ||||
| elif (t.texture.type != 'IMAGE' and t.texture.type != 'NONE'): | elif t.texture.type != 'IMAGE' and t.texture.type != 'NONE': | ||||
| proceduralFlag=True | proceduralFlag=True | ||||
| image_filename = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(t.texture.name)) | image_filename = "PAT_%s"%string_strip_hyphen(bpy.path.clean_name(t.texture.name)) | ||||
| if image_filename: | if image_filename: | ||||
| Context not available. | |||||
| t_alpha = t | t_alpha = t | ||||
| # RASTER IMAGE | # RASTER IMAGE | ||||
| elif (t.texture.type == 'IMAGE' and t.texture.image and t.texture.pov.tex_pattern_type == 'emulator'): | elif t.texture.type == 'IMAGE' and t.texture.image and t.texture.pov.tex_pattern_type == 'emulator': | ||||
| proceduralFlag=False | proceduralFlag=False | ||||
| #PACKED | #PACKED | ||||
| if t.texture.image.packed_file: | if t.texture.image.packed_file: | ||||
| Context not available. | |||||
| # into each texture map's entry. | # into each texture map's entry. | ||||
| c = 1 | c = 1 | ||||
| while (c <= lampCount): | while c <= lampCount: | ||||
| tabWrite("slope { lampTarget%s }\n" % (c)) | tabWrite("slope { lampTarget%s }\n" % c) | ||||
| tabWrite("texture_map {\n") | tabWrite("texture_map {\n") | ||||
| # Diffuse Fresnel value and factor go up to five, | # Diffuse Fresnel value and factor go up to five, | ||||
| # other kind of values needed: used the number 5 below to remap | # other kind of values needed: used the number 5 below to remap | ||||
| Context not available. | |||||
| tabWrite("}\n") | tabWrite("}\n") | ||||
| if mater.diffuse_shader == 'FRESNEL' and mater.pov.replacement_text == "": | if mater.diffuse_shader == 'FRESNEL' and mater.pov.replacement_text == "": | ||||
| c = 1 | c = 1 | ||||
| while (c <= lampCount): | while c <= lampCount: | ||||
| tabWrite("]\n") | tabWrite("]\n") | ||||
| tabWrite("}\n") | tabWrite("}\n") | ||||
| c += 1 | c += 1 | ||||
| Context not available. | |||||
| # Close first layer of POV "texture" (Blender material) | # Close first layer of POV "texture" (Blender material) | ||||
| tabWrite("}\n") | tabWrite("}\n") | ||||
| if ((mater.specular_color.s > 0.0) and (mater.diffuse_shader != 'MINNAERT')): | if (mater.specular_color.s > 0.0) and (mater.diffuse_shader != 'MINNAERT'): | ||||
| colored_specular_found = True | colored_specular_found = True | ||||
| else: | else: | ||||
| Context not available. | |||||