Skip to content
Open
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
24 changes: 23 additions & 1 deletion sloth.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ def __addKeywords(self, shader):
if shader["meta"]["diffuseAlpha"]:
keywords.setdefault("surfaceparm", set())
keywords["surfaceparm"].add("trans")
keywords["cull"] = {"none"}

if options["alphaShadows"]:
keywords["surfaceparm"].add("alphashadow")
Expand Down Expand Up @@ -606,6 +605,27 @@ def __expandLightShaders(self, setname):
# add new shaders (adds back original shader under new name, without addition map)
self.sets[setname].update(newShaders)

def __expandTranslucentShaders(self, setname):
"Replaces every shader with a diffuse map having an alpha channel with a set of shaders"
"with culling enabled or disabled."

newShaders = dict()

for shadername in self.sets[setname]:
shader = self.sets[setname][shadername]

if shader["meta"]["diffuseAlpha"]:
shader = self.sets[setname][shadername]

newShader = copy.deepcopy(shader)
newShader["keywords"]["cull"] = {"none"}
newShaders[shadername] = newShader

newShader = copy.deepcopy(shader)
newShaders[shadername + "_cull"] = newShader
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems backwards, the one named "cull" is the version with "no culling"?

Maybe "onesided"/"twosided" would be a clearer terminology.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. It's backward. Fixed.


self.sets[setname].pop(shadername)
self.sets[setname].update(newShaders)

def __readAliases(self, path):
filepath = os.path.join(path,"sloth-alias.txt")
Expand Down Expand Up @@ -724,6 +744,8 @@ def generateSet(self, path, setname = None, cutextension = None):
# expand relevant shaders into multiple light emitting ones
self.__expandLightShaders(setname)

self.__expandTranslucentShaders(setname)

numShaders = str(len(self.sets[setname]))

self.verbose(setname+": Added "+numShaders+" shaders for "+numVariants+" texture variants.")
Expand Down