shader.py: add API to set texture params
This commit is contained in:
parent
5f55b00710
commit
05c14238f2
|
@ -119,16 +119,29 @@ class ShaderContext:
|
|||
c['link'] = link
|
||||
self.constants.append(c)
|
||||
|
||||
def add_texture_unit(self, ctype, name, link=None, is_image=None):
|
||||
def add_texture_unit(self, name, link=None, is_image=None,
|
||||
addr_u=None, addr_v=None,
|
||||
filter_min=None, filter_mag=None, mipmap_filter=None):
|
||||
for c in self.tunits:
|
||||
if c['name'] == name:
|
||||
return
|
||||
|
||||
c = { 'name': name }
|
||||
if link != None:
|
||||
c = {'name': name}
|
||||
if link is not None:
|
||||
c['link'] = link
|
||||
if is_image != None:
|
||||
if is_image is not None:
|
||||
c['is_image'] = is_image
|
||||
if addr_u is not None:
|
||||
c['addressing_u'] = addr_u
|
||||
if addr_v is not None:
|
||||
c['addressing_v'] = addr_v
|
||||
if filter_min is not None:
|
||||
c['filter_min'] = filter_min
|
||||
if filter_mag is not None:
|
||||
c['filter_mag'] = filter_mag
|
||||
if mipmap_filter is not None:
|
||||
c['mipmap_filter'] = mipmap_filter
|
||||
|
||||
self.tunits.append(c)
|
||||
|
||||
def make_vert(self, custom_name: str = None):
|
||||
|
@ -213,7 +226,10 @@ class Shader:
|
|||
if s not in self.outs:
|
||||
self.outs.append(s)
|
||||
|
||||
def add_uniform(self, s, link=None, included=False):
|
||||
def add_uniform(self, s, link=None, included=False,
|
||||
tex_addr_u=None, tex_addr_v=None,
|
||||
tex_filter_min=None, tex_filter_mag=None,
|
||||
tex_mipmap_filter=None):
|
||||
ar = s.split(' ')
|
||||
# layout(RGBA8) image3D voxels
|
||||
utype = ar[-2]
|
||||
|
@ -224,9 +240,15 @@ class Shader:
|
|||
# Add individual units - mySamplers[0], mySamplers[1]
|
||||
for i in range(int(uname[-2])):
|
||||
uname_array = uname[:-2] + str(i) + ']'
|
||||
self.context.add_texture_unit(utype, uname_array, link=link, is_image=is_image)
|
||||
self.context.add_texture_unit(
|
||||
uname_array, link, is_image,
|
||||
tex_addr_u, tex_addr_v,
|
||||
tex_filter_min, tex_filter_mag, tex_mipmap_filter)
|
||||
else:
|
||||
self.context.add_texture_unit(utype, uname, link=link, is_image=is_image)
|
||||
self.context.add_texture_unit(
|
||||
uname, link, is_image,
|
||||
tex_addr_u, tex_addr_v,
|
||||
tex_filter_min, tex_filter_mag, tex_mipmap_filter)
|
||||
else:
|
||||
# Prefer vec4[] for d3d to avoid padding
|
||||
if ar[0] == 'float' and '[' in ar[1]:
|
||||
|
|
Loading…
Reference in a new issue