Skip to content

Commit

Permalink
add 2x/4x transfer modes; remove 4x/16x replacement modes and replace…
Browse files Browse the repository at this point in the history
… them with tile_ratio_exp MML
  • Loading branch information
treellama committed Sep 30, 2023
1 parent c3f7c3d commit 4f83ed7
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Source_Files/GameWorld/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ enum /* object transfer modes (high-level) */
_xfer_reverse_fast_horizontal_slide,
_xfer_reverse_vertical_slide,
_xfer_reverse_fast_vertical_slide,
_xfer_4x_replacement, // scales texture by 4x in hardware; 1x software
_xfer_16x_replacement, // scales texture by 16x in hardware; 1x software
_xfer_2x, // scales texture by 2x
_xfer_4x, // scales texture by 4x

NUMBER_OF_TRANSFER_MODES
};
Expand Down
4 changes: 2 additions & 2 deletions Source_Files/Lua/lua_mnemonics.h
Original file line number Diff line number Diff line change
Expand Up @@ -913,8 +913,8 @@ const lang_def Lua_TransferMode_Mnemonics[] = {
{"reverse fast horizontal slide", 23},
{"reverse vertical slide", 24},
{"reverse fast vertical slide", 25},
{"4x replacement", 26},
{"16x replacement", 27},
{"2x", 26},
{"4x", 27},
{0, 0}
};

Expand Down
1 change: 1 addition & 0 deletions Source_Files/RenderMain/OGL_Subst_Texture_Def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ void parse_mml_opengl_texture(const InfoTree& root)
root.read_attr("glow_bloom_shift", def.GlowBloomShift);
root.read_attr("landscape_bloom", def.LandscapeBloom);
root.read_attr("minimum_glow_intensity", def.MinGlowIntensity);
root.read_attr("tile_ratio_exp", def.TileRatioExp);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Source_Files/RenderMain/OGL_Subst_Texture_Def.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@
struct OGL_TextureOptions: public OGL_TextureOptionsBase
{
bool VoidVisible; // Can see the void through texture if semitransparent
short TileRatioExp; // Tile replacement walls to 2^n x 2^n WU

// Parameters for mapping substitute sprites (inhabitants, weapons in hand)

OGL_TextureOptions():
VoidVisible(false) {}
VoidVisible(false),TileRatioExp{0} {}
};


Expand Down
3 changes: 2 additions & 1 deletion Source_Files/RenderMain/OGL_Textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class TextureManager

// The width of a landscape texture will be 2^(-Landscape_AspRatExp) * (the height)
short Landscape_AspRatExp;

// Sets up all the texture stuff:
bool Setup();

Expand All @@ -238,6 +238,7 @@ class TextureManager
float GlowBloomScale() {return (TxtrOptsPtr->GlowBloomScale);}
float GlowBloomShift() {return (TxtrOptsPtr->GlowBloomShift);}
float LandscapeBloom() {return (TxtrOptsPtr->LandscapeBloom);}
int TileRatio() { return (1 << TxtrOptsPtr->TileRatioExp); }

// Scaling and offset of the current texture;
// important for sprites, which will be padded to make them OpenGL-friendly.
Expand Down
29 changes: 24 additions & 5 deletions Source_Files/RenderMain/RenderRasterize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,14 @@ void RenderRasterizerClass::render_node_floor_or_ceiling(

/* setup the other parameters of the textured polygon */
textured_polygon.flags= 0;
if (surface->transfer_mode == _xfer_2x)
{
textured_polygon.flags |= _SCALE_2X_BIT;
}
else if (surface->transfer_mode == _xfer_4x)
{
textured_polygon.flags |= _SCALE_4X_BIT;
}
textured_polygon.origin.x= view->origin.x + surface->origin.x;
textured_polygon.origin.y= view->origin.y + surface->origin.y;
textured_polygon.origin.z= adjusted_height;
Expand Down Expand Up @@ -511,16 +519,27 @@ void RenderRasterizerClass::render_node_side(
{
world_distance dx= surface->p1.i - surface->p0.i;
world_distance dy= surface->p1.j - surface->p0.j;
world_distance x0= WORLD_FRACTIONAL_PART(surface->texture_definition->x0);
world_distance y0= WORLD_FRACTIONAL_PART(surface->texture_definition->y0);

auto scale = WORLD_ONE;
if (surface->transfer_mode == _xfer_2x)
{
scale *= 2;
}
else if (surface->transfer_mode == _xfer_4x)
{
scale *= 4;
}

world_distance x0= surface->texture_definition->x0 % scale;
world_distance y0= surface->texture_definition->y0 % scale;

/* calculate texture origin and direction */
world_distance divisor = surface->length;
if (divisor == 0)
divisor = 1;
textured_polygon.vector.i= (WORLD_ONE*dx)/divisor;
textured_polygon.vector.j= (WORLD_ONE*dy)/divisor;
textured_polygon.vector.k= -WORLD_ONE;
textured_polygon.vector.i= (scale*dx)/divisor;
textured_polygon.vector.j= (scale*dy)/divisor;
textured_polygon.vector.k= -scale;
textured_polygon.origin.x= surface->p0.i - (x0*dx)/divisor;
textured_polygon.origin.y= surface->p0.j - (x0*dy)/divisor;
textured_polygon.origin.z= surface->h1 + y0;
Expand Down
20 changes: 10 additions & 10 deletions Source_Files/RenderMain/RenderRasterize_Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,14 @@ void RenderRasterize_Shader::render_node_floor_or_ceiling(clipping_window_data *

switch (surface->transfer_mode)
{
case _xfer_4x_replacement:
scale = 4 * WORLD_ONE;
case _xfer_2x:
scale = 2 * WORLD_ONE * TMgr->TileRatio();
break;
case _xfer_16x_replacement:
scale = 16 * WORLD_ONE;
case _xfer_4x:
scale = 4 * WORLD_ONE * TMgr->TileRatio();
break;
default:
scale = WORLD_ONE;
scale = WORLD_ONE * TMgr->TileRatio();
break;
}

Expand Down Expand Up @@ -799,14 +799,14 @@ void RenderRasterize_Shader::render_node_side(clipping_window_data *window, vert
uint16 div;
switch (surface->transfer_mode)
{
case _xfer_4x_replacement:
div = 4 * WORLD_ONE;
case _xfer_2x:
div = 2 * WORLD_ONE * TMgr->TileRatio();
break;
case _xfer_16x_replacement:
div = 16 * WORLD_ONE;
case _xfer_4x:
div = 4 * WORLD_ONE * TMgr->TileRatio();
break;
default:
div = WORLD_ONE;
div = WORLD_ONE * TMgr->TileRatio();;
break;
}

Expand Down
6 changes: 4 additions & 2 deletions Source_Files/RenderMain/scottish_textures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,13 @@ static void _pretexture_horizontal_polygon_lines(
source_y= ((screen_x*hcosine + dhsine)/screen_y)*polygon->origin.z + (polygon->origin.y<<TRIG_SHIFT);
source_dy= (hcosine*polygon->origin.z)/screen_y;
}

auto bits = HORIZONTAL_FREE_BITS - (polygon->flags & _SCALE_BITS);

/* voodoo so x,y texture wrapping is handled automatically by downshifting
(subtract one from HORIZONTAL_FREE_BITS to double scale) */
data->source_x= source_x<<HORIZONTAL_FREE_BITS, data->source_dx= source_dx<<HORIZONTAL_FREE_BITS;
data->source_y= source_y<<HORIZONTAL_FREE_BITS, data->source_dy= source_dy<<HORIZONTAL_FREE_BITS;
data->source_x= source_x<<bits, data->source_dx= source_dx<<bits;
data->source_y= source_y<<bits, data->source_dy= source_dy<<bits;


/* get shading table (with absolute value of depth) */
Expand Down
5 changes: 5 additions & 0 deletions Source_Files/RenderMain/scottish_textures.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ struct point2d
/* ignore multiple shading tables if set */
#define _SHADELESS_BIT 0x8000

// for scaling floor/ceiling
#define _SCALE_2X_BIT 0x0001
#define _SCALE_4X_BIT 0x0002
#define _SCALE_BITS 0x0003

class OGL_ModelData;

struct rectangle_definition
Expand Down
4 changes: 2 additions & 2 deletions docs/Lua.html
Original file line number Diff line number Diff line change
Expand Up @@ -3580,9 +3580,9 @@ <h4>Mnemonics</h4>
</li>
<li>"reverse fast vertical slide" <span class="version">git</span>
</li>
<li>"4x replacement" <span class="version">git</span>
<li>"2x" <span class="version">git</span>
</li>
<li>"16x replacement" <span class="version">git</span>
<li>"4x" <span class="version">git</span>
</li>
</ul></div>
<div class="end-mnemonics"></div>
Expand Down
4 changes: 2 additions & 2 deletions docs/Lua.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3632,8 +3632,8 @@
<mnemonic name="reverse fast horizontal slide" version="git"/>
<mnemonic name="reverse vertical slide" version="git"/>
<mnemonic name="reverse fast vertical slide" version="git"/>
<mnemonic name="4x replacement" version="git"/>
<mnemonic name="16x replacement" version="git"/>
<mnemonic name="2x" version="git"/>
<mnemonic name="4x" version="git"/>
</mnemonics>
</enum>
<enum name="weapon_type">
Expand Down
7 changes: 7 additions & 0 deletions docs/MML.html
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,7 @@ <h3><a name="opengl">OpenGL-Rendering Element: &lt;opengl&gt;</a></h3>
<li>glow_bloom_scale: when rendering bloom effects in the shader renderer, scale the glow image's light level by this amount. (default: 1 -- full intensity during bloom effect)
<li>glow_bloom_shift: when rendering bloom effects in the shader renderer, add this value to the glow image's light level after scaling. (default: 0)
<li>landscape_bloom: when rendering bloom effects in the shader renderer, AND when the texture is used as a landscape, scale the image's light level by this amount. Note that glow images are not currently supported for landscapes. (default: 0.5)
<li>tile_ratio_exp: when applied to walls, scale replacement image up to cover 2^n x 2^n tiles. (default: 0, cover 1x1 tiles)
</ul>
<p>
Note: all resulting values will be pegged to the range 0 to 1.
Expand Down Expand Up @@ -2748,6 +2749,12 @@ <h3><a name="appendix2">Appendix 2: Lists of Entity Types</a></h3>
<li>Wander
<li>Fast Wander
<li>Big Landscape
<li>Reverse Horizontal Slide
<li>Reverse Fast Horizontal Slide
<li>Reverse Vertical Slide
<li>Reverse Fast Vertical Slide
<li>2x
<li>4x
</ol>
<p>

Expand Down

0 comments on commit 4f83ed7

Please sign in to comment.