Skip to content

Commit

Permalink
read: Clarify openage usage of alpha values.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Feb 28, 2023
1 parent 757883a commit dc5c6b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 9 additions & 3 deletions openage/convert/value_object/read/media/slp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,9 @@ cdef numpy.ndarray determine_rgba_matrix(vector[vector[pixel]] &image_matrix,
r, g, b = 0, 0, 0
alpha = 255 - (px_val << 2)

# Only odd alphas are used in openage; even alphas are used for commands
# change alpha values to match openage texture formats
# even alphas are used for commands marking *special* pixels (player color, etc.)
# odd alphas are used for normal pixels (= displayed as-is with transparency)
alpha = alpha | 0x01

else:
Expand Down Expand Up @@ -1611,7 +1613,9 @@ cdef numpy.ndarray determine_rgba_matrix32(vector[vector[pixel32]] &image_matrix
b = px.b
alpha = px.a

# Only odd alphas are used in openage; even alphas are used for commands
# change alpha values to match openage texture formats
# even alphas are used for commands marking *special* pixels (player color, etc.)
# odd alphas are used for normal pixels (= displayed as-is with transparency)
alpha = alpha | 0x01

elif px_type == color_transparent:
Expand All @@ -1624,7 +1628,9 @@ cdef numpy.ndarray determine_rgba_matrix32(vector[vector[pixel32]] &image_matrix
r, g, b = 0, 0, 0
alpha = 255 - (px.r << 2)

# Only odd alphas are used in openage; even alphas are used for commands
# change alpha values to match openage texture formats
# even alphas are used for commands marking *special* pixels (player color, etc.)
# odd alphas are used for normal pixels (= displayed as-is with transparency)
alpha = alpha | 0x01

else:
Expand Down
4 changes: 3 additions & 1 deletion openage/convert/value_object/read/media/smp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,9 @@ cdef numpy.ndarray determine_rgba_matrix(vector[vector[pixel]] &image_matrix,
elif px_type == color_shadow:
r, g, b, alpha = 0, 0, 0, px_index

# Only odd alphas are used in openage; even alphas are used for commands
# change alpha values to match openage texture formats
# even alphas are used for commands marking *special* pixels (player color, etc.)
# odd alphas are used for normal pixels (= displayed as-is with transparency)
alpha = alpha | 0x01

else:
Expand Down
4 changes: 3 additions & 1 deletion openage/convert/value_object/read/media/smx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,9 @@ cdef numpy.ndarray determine_rgba_matrix(vector[vector[pixel]] &image_matrix,
elif px_type == color_shadow:
r, g, b, alpha = 0, 0, 0, px_index

# Only odd alphas are used in openage; even alphas are used for commands
# change alpha values to match openage texture formats
# even alphas are used for commands marking *special* pixels (player color, etc.)
# odd alphas are used for normal pixels (= displayed as-is with transparency)
alpha = alpha | 0x01

else:
Expand Down

0 comments on commit dc5c6b5

Please sign in to comment.