Single monochrome texture working

This commit is contained in:
Daniele Verducci (Slimpenguin) 2023-01-06 11:08:06 +01:00
parent adf11abd16
commit f6ce668aef

View File

@ -44,12 +44,16 @@ MAP_SIZE = 16
DOF = 2*MAP_SIZE # Depth Of Field DOF = 2*MAP_SIZE # Depth Of Field
TEXTURE = [ TEXTURE = [
1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1,
0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1,
1, 0, 0, 0, 1, 0, 0, 1,
1, 0, 0, 0, 0, 1, 0, 1,
1, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
] ]
TEXTURE_SIZE = 4 TEXTURE_SIZE = 8
class Main: class Main:
@ -291,13 +295,15 @@ class Main:
textureSegmentLength = lineHeight / TEXTURE_SIZE textureSegmentLength = lineHeight / TEXTURE_SIZE
textureSegmentStart = lineOffset + textureColumnPixel * textureSegmentLength textureSegmentStart = lineOffset + textureColumnPixel * textureSegmentLength
textureSegmentEnd = textureSegmentStart + textureSegmentLength textureSegmentEnd = textureSegmentStart + textureSegmentLength
# Obtain texture value in the pixel representing the current segment # Obtain texture value in the pixel representing the current segment and calculate shading
texColumn = 1
texel = TEXTURE[texColumn + textureColumnPixel * TEXTURE_SIZE]
# Calculate shading
shading = 255
if vertDist > horizDist: if vertDist > horizDist:
texColumn = int(rayX / (MAP_SCALE / TEXTURE_SIZE) % TEXTURE_SIZE)
shading = 127 shading = 127
else:
texColumn = int(rayY / (MAP_SCALE / TEXTURE_SIZE) % TEXTURE_SIZE)
shading = 255
texel = TEXTURE[texColumn + textureColumnPixel * TEXTURE_SIZE]
# Calculate color resulting from texture pixel value + shading # Calculate color resulting from texture pixel value + shading
color = sdl2.ext.Color(texel*shading,texel*shading,texel*shading,255) color = sdl2.ext.Color(texel*shading,texel*shading,texel*shading,255)
# Clipping # Clipping