Check for uniqueness when adding init statements to shader main() (+ indent)
This commit is contained in:
parent
78d86515dc
commit
13cf5d12a5
|
@ -598,9 +598,8 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
|
|||
# TODO: Fade out fragments near depth buffer here
|
||||
return
|
||||
|
||||
frag.write_init("""
|
||||
vec3 vVec = normalize(eyeDir);
|
||||
float dotNV = max(dot(n, vVec), 0.0);
|
||||
frag.write_init("""vec3 vVec = normalize(eyeDir);
|
||||
\tfloat dotNV = max(dot(n, vVec), 0.0);
|
||||
""")
|
||||
|
||||
sh = tese if tese is not None else vert
|
||||
|
|
|
@ -283,8 +283,12 @@ class Shader:
|
|||
self.main_attribs = self.main_attribs.replace(old, new)
|
||||
self.uniforms = [u.replace(old, new) for u in self.uniforms]
|
||||
|
||||
def write_init(self, s):
|
||||
self.main_init = s + '\n' + self.main_init
|
||||
def write_init(self, s, unique=True):
|
||||
"""Prepend to the main function. If `unique` is true (default), look for other occurences first."""
|
||||
if unique and self.contains(s):
|
||||
return
|
||||
|
||||
self.main_init = '\t' + s + '\n' + self.main_init
|
||||
|
||||
def write(self, s):
|
||||
if self.lock:
|
||||
|
|
Loading…
Reference in a new issue