Skip to content

Commit

Permalink
feat: Fix emission?
Browse files Browse the repository at this point in the history
  • Loading branch information
koerismo committed Oct 17, 2024
1 parent 669724c commit c185076
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/module/core/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def export(src: Material) -> list[Texture]:
bumpmap = bumpmap.convert('uint8', clip=True)
textures.append(Texture(bumpmap, '_bump', compressed=False))

if (MaterialMode.has_selfillum(src.mode) or MaterialMode.is_pbr(src.mode)) and src.emit:
illum_mask = src.emit.convert('uint8', clip=True)
textures.append(Texture(illum_mask, '_emit'))

if MaterialMode.is_pbr(src.mode):
mrao = texops.make_mrao(src)
mrao = mrao.convert('uint8')
Expand Down
7 changes: 0 additions & 7 deletions src/module/core/texops.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@ def make_basecolor(mat: Material) -> Image:
envmask = make_envmask(mat)
basetexture = Image.merge((r, g, b, envmask))

# Emission as basetexture alpha
# TODO: Burn emission color into image when using VLG/LMG
if MaterialMode.embed_selfillum(mat.mode):
assert mat.emit != None, 'An emissive texture is required for this mode!'
emitmask = mat.emit.copy().grayscale()
basetexture = Image.merge((r, g, b, emitmask))

return basetexture


Expand Down
7 changes: 2 additions & 5 deletions src/module/core/vmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ def write(*args: str):

if MaterialMode.has_selfillum(mat.mode):
write( '',
' $selfillum 1')

# Mask is always embedded in basetexture alpha, so we don't need this.
# write(
# f' $selfillummask "{mat.name}_emit"' )
' $selfillum 1',
f' $selfillummask "{mat.name}_emit"')

write('}')
return '\n'.join(vmt)
2 changes: 1 addition & 1 deletion src/module/gui/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def getImage(role: ImageRole) -> Image|None:
albedo=texops.normalize(albedo, detailSize, mode='RGB'),
roughness=texops.normalize(roughness, detailSize, mode='L'),
metallic=texops.normalize(metallic, detailSize, mode='L'),
emit=texops.normalize(emit, detailSize, mode='L') if emit else None,
emit=texops.normalize(emit, detailSize) if emit else None,
ao=texops.normalize(ao, detailSize, mode='L') if ao else None,
normal=texops.normalize(normal, detailSize, mode='RGB'),
height=texops.normalize(height, detailSize, mode='L') if height else None,
Expand Down

0 comments on commit c185076

Please sign in to comment.