More shader write fixes
This commit is contained in:
parent
8f82e3a0d8
commit
5278226b4c
|
@ -65,7 +65,7 @@ def make_finalize(con_mesh):
|
|||
# Additional values referenced in cycles
|
||||
# TODO: enable from cycles.py
|
||||
if frag.contains('dotNV') and not frag.contains('float dotNV'):
|
||||
frag.prepend('float dotNV = max(dot(n, vVec), 0.0);')
|
||||
frag.write_init('float dotNV = max(dot(n, vVec), 0.0);')
|
||||
|
||||
write_wpos = False
|
||||
if frag.contains('vVec') and not frag.contains('vec3 vVec'):
|
||||
|
@ -80,7 +80,7 @@ def make_finalize(con_mesh):
|
|||
vert.add_out('vec3 eyeDir')
|
||||
vert.add_uniform('vec3 eye', '_cameraPosition')
|
||||
vert.write('eyeDir = eye - wposition;')
|
||||
frag.prepend_header('vec3 vVec = normalize(eyeDir);')
|
||||
frag.write_attrib('vec3 vVec = normalize(eyeDir);')
|
||||
|
||||
export_wpos = False
|
||||
if frag.contains('wposition') and not frag.contains('vec3 wposition'):
|
||||
|
@ -223,7 +223,7 @@ def make_base(con_mesh, parse_opacity):
|
|||
else:
|
||||
vert.add_out('vec3 wnormal')
|
||||
write_norpos(con_mesh, vert)
|
||||
frag.prepend_header('vec3 n = normalize(wnormal);')
|
||||
frag.write_attrib('vec3 n = normalize(wnormal);')
|
||||
|
||||
if tese != None:
|
||||
tese.add_uniform('mat4 VP', '_viewProjectionMatrix')
|
||||
|
@ -369,7 +369,7 @@ def make_deferred_plus(con_mesh):
|
|||
|
||||
vert.add_out('vec3 wnormal')
|
||||
write_norpos(con_mesh, vert)
|
||||
frag.prepend_header('vec3 n = normalize(wnormal);')
|
||||
frag.write_attrib('vec3 n = normalize(wnormal);')
|
||||
|
||||
frag.add_uniform('float materialID', link='_objectInfoMaterialIndex')
|
||||
|
||||
|
@ -416,7 +416,7 @@ def make_forward_mobile(con_mesh):
|
|||
|
||||
vert.add_out('vec3 wnormal')
|
||||
write_norpos(con_mesh, vert)
|
||||
frag.prepend_header('vec3 n = normalize(wnormal);')
|
||||
frag.write_attrib('vec3 n = normalize(wnormal);')
|
||||
|
||||
frag.add_include('std/math.glsl')
|
||||
frag.add_include('std/brdf.glsl')
|
||||
|
|
|
@ -27,4 +27,4 @@ def interpolate(tese, var, size, normalize=False, declare_out=False):
|
|||
else:
|
||||
s += '{0}{1} = {1}_0 + {1}_1 + {1}_2;\n'.format(prep, var)
|
||||
|
||||
tese.prepend_header(s)
|
||||
tese.write_attrib(s)
|
||||
|
|
|
@ -12,8 +12,8 @@ class Shader:
|
|||
self.uniforms = []
|
||||
self.functions = {}
|
||||
self.main = ''
|
||||
self.main_pre = ''
|
||||
self.main_header = ''
|
||||
self.main_init = ''
|
||||
self.main_normal = ''
|
||||
self.main_textures = ''
|
||||
self.main_attribs = ''
|
||||
self.header = ''
|
||||
|
@ -63,17 +63,14 @@ class Shader:
|
|||
|
||||
def contains(self, s):
|
||||
return s in self.main or \
|
||||
s in self.main_pre or \
|
||||
s in self.main_header or \
|
||||
s in self.main_init or \
|
||||
s in self.main_normal or \
|
||||
s in self.ins or \
|
||||
s in self.main_textures or \
|
||||
s in self.main_attribs
|
||||
|
||||
def prepend(self, s):
|
||||
self.main_pre = s + '\n' + self.main_pre
|
||||
|
||||
def prepend_header(self, s):
|
||||
self.main_header = s + '\n' + self.main_header
|
||||
def write_init(self, s):
|
||||
self.main_init = s + '\n' + self.main_init
|
||||
|
||||
def write(self, s):
|
||||
if self.lock:
|
||||
|
@ -81,9 +78,9 @@ class Shader:
|
|||
if self.write_textures > 0:
|
||||
self.main_textures += '\t' * 1 + s + '\n'
|
||||
elif self.write_normal > 0:
|
||||
self.main_header += '\t' * 1 + s + '\n'
|
||||
self.main_normal += '\t' * 1 + s + '\n'
|
||||
elif self.write_pre:
|
||||
self.main_pre += '\t' * 1 + s + '\n'
|
||||
self.main_init += '\t' * 1 + s + '\n'
|
||||
else:
|
||||
self.main += '\t' * self.tab + s + '\n'
|
||||
|
||||
|
@ -97,8 +94,8 @@ class Shader:
|
|||
self.vstruct_to_vsin()
|
||||
return self.ins == sh.ins and \
|
||||
self.main == sh.main and \
|
||||
self.main_header == sh.main_header and \
|
||||
self.main_pre == sh.main_pre and \
|
||||
self.main_normal == sh.main_normal and \
|
||||
self.main_init == sh.main_init and \
|
||||
self.main_textures == sh.main_textures and \
|
||||
self.main_attribs == sh.main_attribs
|
||||
|
||||
|
@ -165,8 +162,8 @@ class Shader:
|
|||
s += 'void main() {\n'
|
||||
s += self.main_attribs
|
||||
s += self.main_textures
|
||||
s += self.main_header
|
||||
s += self.main_pre
|
||||
s += self.main_normal
|
||||
s += self.main_init
|
||||
s += self.main
|
||||
s += '}\n'
|
||||
return s
|
||||
|
|
Loading…
Reference in a new issue