Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions sloth.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def __init__(self, verbosity = 0):
self["options"]["editorOpacity"] = 1.0 # in-editor opacity of transparent shaders
self["options"]["alphaTest"] = None # whether to use an alphaFunc/alphaTest keyword or smooth blending (default)
self["options"]["alphaShadows"] = True # whether to add the alphashadows surfaceparm keyword to relevant shaders
self["options"]["rawColorMap"] = False # wether to add the rawColorMap keyword to relevant shader stages
self["options"]["linearColorMap"] = False # wether to add the linearColorMap keyword to relevant shader stages
self["options"]["rawSpecularMap"] = False # wether to add the rawSpecularMap keyword to relevant shader stages
self["options"]["linearSpecularMap"] = False # wether to add the linearSpecularMap keyword to relevant shader stages
self["options"]["renderer"] = self.defaultRenderer


Expand Down Expand Up @@ -237,6 +241,48 @@ def setAlphaShadows(self, value = True):
self.__setAlphaShadows(value)


def __setRawColorMap(self, value, shader = None):
if not shader:
shader = self

shader["options"]["rawColorMap"] = value

def setRawColorMap(self, value = True):
"Whether to add the rawColorMap keyword to relevant shader stages"
self.__setRawColorMap(value)

def __setLinearColorMap(self, value, shader = None):
if not shader:
shader = self

shader["options"]["linearColorMap"] = value

def setLinearColorMap(self, value = True):
"Whether to add the linearColorMap keyword to relevant shader stages"
self.__setLinearColorMap(value)


def __setRawSpecularMap(self, value, shader = None):
if not shader:
shader = self

shader["options"]["rawSpecularMap"] = value

def setRawSpecularMap(self, value = True):
"Whether to add the rawSpecularMap keyword to relevant shader stages"
self.__setRawSpecularMap(value)

def __setLinearSpecularMap(self, value, shader = None):
if not shader:
shader = self

shader["options"]["linearSpecularMap"] = value

def setLinearSpecularMap(self, value = True):
"Whether to add the linearSpecularMap keyword to relevant shader stages"
self.__setLinearSpecularMap(value)


def __addLightColor(self, name, color, shader = None):
if not shader:
shader = self
Expand Down Expand Up @@ -416,6 +462,18 @@ def __parseSlothFile(self, shader, path):
elif option == "alphaShadows":
self.__setAlphaShadows(options.getboolean(option), shader)

elif option == "rawColorMap":
self.__setRawColorMap(options.getboolean(option), shader)

elif option == "linearColorMap":
self.__setLinearColorMap(options.getboolean(option), shader)

elif option == "rawSpecularMap":
self.__setRawSpecularMap(options.getboolean(option), shader)

elif option == "linearSpecularMap":
self.__setLinearSpecularMap(options.getboolean(option), shader)

elif option == "heightNormalsMod":
self.__setHeightNormalsMod(options.getfloat(option), shader)

Expand Down Expand Up @@ -889,6 +947,12 @@ def getShader(self, setname = None, shadername = None):

content += "\t\tdiffuseMap "+getVfsPath("diffuse")+"\n"

if shader["options"]["rawColorMap"]:
content += "\t\trawColorMap\n"

if shader["options"]["linearColorMap"]:
content += "\t\tlinearColorMap\n"

# with alpha channel
if shader["meta"]["diffuseAlpha"]:
if shader["options"]["renderer"] != "daemon":
Expand Down Expand Up @@ -980,6 +1044,12 @@ def getShader(self, setname = None, shadername = None):

content += "\t\tspecularMap "+getVfsPath("specular")+"\n"

if shader["options"]["rawSpecularMap"]:
content += "\t\trawSpecularMap\n"

if shader["options"]["linearSpecularMap"]:
content += "\t\tlinearSpecularMap\n"

elif shader["options"]["renderer"] == "xreal":
content += "\tspecularMap "+getVfsPath("specular")+"\n"

Expand Down