mirror of
https://github.com/ZDoom/gzdoom-last-svn.git
synced 2025-05-30 00:41:19 +00:00
- complete overhaul of sky positioning code to make it work for all sizes >= 200.
- added skyrotatevector2. - Update to ZDoom r1976 git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@622 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
parent
5eea8bac2e
commit
5ebc18b0fc
14 changed files with 618 additions and 287 deletions
|
@ -1,3 +1,17 @@
|
|||
November 12, 2009
|
||||
- Improved sky stretching a bit: It now only stretches the sky as tall as it
|
||||
needs to be: 228 pixels, not 256. It no longer stretches horizontally,
|
||||
either.
|
||||
|
||||
The reason it stretches to 228 and not 200 pixels is because Doom shifted
|
||||
its sky texture down 28 pixels. By stretching to 228 pixels, we can keep
|
||||
the sky tiled at the same height on the horizon. Skies 200 pixels tall
|
||||
(or more) will continue to tile at the center of the screen when looking
|
||||
directly ahead.
|
||||
- Cleaned up win32/i_system.cpp.
|
||||
- Put back the previous event-driven ticker, except now the timer isn't
|
||||
started until the first time it is needed.
|
||||
|
||||
November 11, 2009
|
||||
- Modified the event-driven ticks to use the same code for calculating the
|
||||
time as the polled timer so that the timer does not start running until the
|
||||
|
|
|
@ -87,11 +87,13 @@
|
|||
#ifndef STAT
|
||||
#define STAT_NEW(map)
|
||||
#define STAT_END(newl)
|
||||
#define STAT_SAVE(arc, hub)
|
||||
#define STAT_READ(png)
|
||||
#define STAT_WRITE(f)
|
||||
#else
|
||||
void STAT_NEW(const char *lev);
|
||||
void STAT_END(const char *newl);
|
||||
void STAT_SAVE(FArchive &arc, bool hubload);
|
||||
void STAT_READ(PNGHandle *png);
|
||||
void STAT_WRITE(FILE *f);
|
||||
#endif
|
||||
|
||||
EXTERN_CVAR (Float, sv_gravity)
|
||||
|
@ -1524,7 +1526,6 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad)
|
|||
}
|
||||
}
|
||||
screen->EndSerialize(arc);
|
||||
STAT_SAVE(arc, hubLoad);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1645,6 +1646,7 @@ void G_WriteSnapshots (FILE *file)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
STAT_WRITE(file);
|
||||
for (i = 0; i < wadlevelinfos.Size(); i++)
|
||||
{
|
||||
if (wadlevelinfos[i].snapshot)
|
||||
|
@ -1795,6 +1797,7 @@ void G_ReadSnapshots (PNGHandle *png)
|
|||
arc << pnum;
|
||||
}
|
||||
}
|
||||
STAT_READ(png);
|
||||
png->File->ResetFilePtr();
|
||||
}
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ struct FGLROptions : public FOptionalMapinfoData
|
|||
int lightmode;
|
||||
SBYTE nocoloredspritelighting;
|
||||
FVector3 skyrotatevector;
|
||||
FVector3 skyrotatevector2;
|
||||
};
|
||||
|
||||
DEFINE_MAP_OPTION(fogdensity, false)
|
||||
|
@ -266,6 +267,22 @@ DEFINE_MAP_OPTION(skyrotate, false)
|
|||
opt->skyrotatevector.MakeUnit();
|
||||
}
|
||||
|
||||
DEFINE_MAP_OPTION(skyrotate2, false)
|
||||
{
|
||||
FGLROptions *opt = info->GetOptData<FGLROptions>("gl_renderer");
|
||||
|
||||
parse.ParseAssign();
|
||||
parse.sc.MustGetFloat();
|
||||
opt->skyrotatevector2.X = (float)parse.sc.Float;
|
||||
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
|
||||
parse.sc.MustGetFloat();
|
||||
opt->skyrotatevector2.Y = (float)parse.sc.Float;
|
||||
if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(",");
|
||||
parse.sc.MustGetFloat();
|
||||
opt->skyrotatevector2.Z = (float)parse.sc.Float;
|
||||
opt->skyrotatevector2.MakeUnit();
|
||||
}
|
||||
|
||||
void InitGLRMapinfoData()
|
||||
{
|
||||
FGLROptions *opt = level.info->GetOptData<FGLROptions>("gl_renderer", false);
|
||||
|
|
|
@ -14,6 +14,7 @@ struct GLRenderSettings
|
|||
SBYTE map_nocoloredspritelighting;
|
||||
|
||||
FVector3 skyrotatevector;
|
||||
FVector3 skyrotatevector2;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ static PalEntry outsidefogcolor;
|
|||
static int outsidefogdensity;
|
||||
int skyfog;
|
||||
|
||||
CVAR (Float, gl_light_ambient, 20.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE);
|
||||
CVAR(Bool,gl_enhanced_nightvision,true,CVAR_ARCHIVE)
|
||||
|
||||
|
@ -223,7 +223,7 @@ int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon)
|
|||
light=gl_light_ambient;
|
||||
if (rellight<0) rellight>>=1;
|
||||
}
|
||||
return clamp(quickertoint(light+rellight), 0, 255);
|
||||
return clamp(light+rellight, 0, 255);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -57,6 +57,7 @@ struct GLSkyInfo
|
|||
FTextureID skytexno1;
|
||||
bool mirrored;
|
||||
bool doublesky;
|
||||
bool sky2;
|
||||
PalEntry fadecolor; // if this isn't made part of the dome things will become more complicated when sky fog is used.
|
||||
|
||||
bool operator==(const GLSkyInfo & inf)
|
||||
|
|
|
@ -155,6 +155,7 @@ void GLWall::SkyTexture(int sky1,ASkyViewpoint * skyboxx, bool ceiling)
|
|||
{
|
||||
skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, true);
|
||||
skyinfo.skytexno1=sky2texture;
|
||||
skyinfo.sky2 = true;
|
||||
skyinfo.x_offset[0] = GLRenderer->mSky2Pos;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -243,14 +243,14 @@ static void RenderSkyHemisphere(int hemi, bool mirror)
|
|||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
CVAR(Float, skyoffset, -40, 0) // temporary workaround
|
||||
|
||||
static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror, int CM_Index)
|
||||
{
|
||||
int texh;
|
||||
|
||||
// Sky stretching is rather pointless with the GL renderer now that it can handle all sky heights.
|
||||
bool skystretch = false; // (r_stretchsky && !(level.flags & LEVEL_FORCENOSKYSTRETCH));
|
||||
|
||||
// 57 worls units roughly represent one sky texel for the glTranslate call.
|
||||
const float skyoffsetfactor = 57;
|
||||
|
||||
if (tex)
|
||||
{
|
||||
|
@ -259,23 +259,19 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float
|
|||
texw = tex->TextureWidth(GLUSE_TEXTURE);
|
||||
texh = tex->TextureHeight(GLUSE_TEXTURE);
|
||||
|
||||
if (texh>190 && skystretch) texh=190;
|
||||
|
||||
gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f);
|
||||
|
||||
yAdd = y_offset/texh;
|
||||
yMult=1.0f;
|
||||
|
||||
if (texh<=180) // && skystretch)
|
||||
if (texh < 200)
|
||||
{
|
||||
yMult=1.0f;
|
||||
if (!skystretch)
|
||||
gl.Scalef(1.f, texh/230.f, 1.f);
|
||||
gl.Translatef(0.f, -1250.f, 0.f);
|
||||
gl.Scalef(1.f, texh/230.f, 1.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
yMult= 180.0f/texh;
|
||||
if (!skystretch && texh > 190)
|
||||
gl.Scalef(1.f, 230.f/240.f, 1.f);
|
||||
gl.Translatef(0.f, (200-texh+skyoffset)*skyoffsetfactor, 0.f);
|
||||
gl.Scalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,20 +297,6 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float
|
|||
|
||||
RenderSkyHemisphere(SKYHEMI_UPPER, mirror);
|
||||
|
||||
if(tex)
|
||||
{
|
||||
yAdd = y_offset/texh;
|
||||
|
||||
if (texh<=180)
|
||||
{
|
||||
yMult=1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
yAdd+=180.0f/texh;
|
||||
}
|
||||
}
|
||||
|
||||
if (tex && !secondlayer)
|
||||
{
|
||||
PalEntry pe = tex->tex->GetSkyCapColor(true);
|
||||
|
@ -346,13 +328,17 @@ static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float
|
|||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int CM_Index)
|
||||
static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, int CM_Index, bool sky2)
|
||||
{
|
||||
FSkyBox * sb = static_cast<FSkyBox*>(gltex->tex);
|
||||
int faces;
|
||||
FMaterial * tex;
|
||||
|
||||
gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y);
|
||||
if (!sky2)
|
||||
gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y);
|
||||
else
|
||||
gl.Rotatef(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y);
|
||||
|
||||
gl.Color3f(R, G ,B);
|
||||
|
||||
if (sb->faces[5])
|
||||
|
@ -565,15 +551,13 @@ void GLSkyPortal::DrawContents()
|
|||
}
|
||||
else R=G=B=1.f;
|
||||
|
||||
RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index);
|
||||
RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], CM_Index, origin->sky2);
|
||||
gl_RenderState.EnableAlphaTest(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false;
|
||||
|
||||
gl.Translatef(0.f, -1250.f, 0.f);
|
||||
|
||||
if (origin->texture[0])
|
||||
{
|
||||
gl_RenderState.SetTextureMode(TM_OPAQUE);
|
||||
|
|
|
@ -66,7 +66,7 @@ EXTERN_CVAR(Bool, gl_render_precise)
|
|||
EXTERN_CVAR(Bool, gl_sprite_blend)
|
||||
EXTERN_CVAR(Bool, gl_fakecontrast)
|
||||
EXTERN_CVAR (Bool, gl_lights_additive)
|
||||
EXTERN_CVAR (Float, gl_light_ambient)
|
||||
EXTERN_CVAR (Int, gl_light_ambient)
|
||||
EXTERN_CVAR(Int, gl_billboard_mode)
|
||||
EXTERN_CVAR(Int, gl_particles_style)
|
||||
EXTERN_CVAR(Int, gl_texture_hqresize)
|
||||
|
|
|
@ -823,7 +823,7 @@ static void R_DrawSky (visplane_t *pl)
|
|||
if (pl->minx > pl->maxx)
|
||||
return;
|
||||
|
||||
dc_iscale = skyiscale >> skystretch;
|
||||
dc_iscale = skyiscale;
|
||||
|
||||
clearbuf (swall+pl->minx, pl->maxx-pl->minx+1, dc_iscale<<2);
|
||||
|
||||
|
@ -864,7 +864,7 @@ static void R_DrawSky (visplane_t *pl)
|
|||
}
|
||||
else
|
||||
{ // The texture does not tile nicely
|
||||
frontyScale = DivScale16 (skyscale << skystretch, frontyScale);
|
||||
frontyScale = DivScale16 (skyscale, frontyScale);
|
||||
frontiScale = DivScale32 (1, frontyScale);
|
||||
R_DrawSkyStriped (pl);
|
||||
}
|
||||
|
@ -1328,9 +1328,9 @@ void R_DrawSkyPlane (visplane_t *pl)
|
|||
skyflip = l->args[2] ? 0u : ~0u;
|
||||
|
||||
frontcyl = MAX(frontskytex->GetWidth(), frontskytex->xScale >> (16 - 10));
|
||||
if (skystretch && frontskytex->GetScaledWidth() < 512)
|
||||
if (skystretch)
|
||||
{
|
||||
frontcyl >>= 1;
|
||||
skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,9 +43,8 @@ FTextureID skyflatnum;
|
|||
FTextureID sky1texture, sky2texture;
|
||||
fixed_t skytexturemid;
|
||||
fixed_t skyscale;
|
||||
int skystretch;
|
||||
fixed_t skyheight;
|
||||
fixed_t skyiscale;
|
||||
bool skystretch;
|
||||
|
||||
fixed_t sky1cyl, sky2cyl;
|
||||
double sky1pos, sky2pos;
|
||||
|
@ -68,7 +67,7 @@ extern fixed_t freelookviewheight;
|
|||
|
||||
void R_InitSkyMap ()
|
||||
{
|
||||
fixed_t fskyheight;
|
||||
int skyheight;
|
||||
FTexture *skytex1, *skytex2;
|
||||
|
||||
skytex1 = TexMan[sky1texture];
|
||||
|
@ -83,27 +82,30 @@ void R_InitSkyMap ()
|
|||
sky2texture = sky1texture;
|
||||
}
|
||||
|
||||
fskyheight = skytex1->GetHeight() << FRACBITS;
|
||||
if (skytex1->GetScaledHeight() <= 128)
|
||||
// Skies between [128,200) are stretched to 200 pixels. Shorter skies do
|
||||
// not stretch because it is assumed they are meant to tile, and taller
|
||||
// skies do not stretch because they provide enough information for no
|
||||
// repetition when looking all the way up.
|
||||
skyheight = skytex1->GetScaledHeight();
|
||||
if (skyheight < 200)
|
||||
{
|
||||
skytexturemid = r_Yaspect/2*FRACUNIT;
|
||||
skystretch = (r_stretchsky
|
||||
&& skyheight >= 128
|
||||
&& level.IsFreelookAllowed()
|
||||
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
|
||||
// The sky is shifted down from center so that it is entirely visible
|
||||
// when looking straight ahead.
|
||||
skytexturemid = -28*FRACUNIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
skytexturemid = 199 * skytex1->yScale;
|
||||
skystretch = 0;
|
||||
// At heights above 600 pixels, the sky is drawn slightly too low.
|
||||
if (SCREENHEIGHT > 600)
|
||||
{
|
||||
skytexturemid += FRACUNIT;
|
||||
}
|
||||
// The sky is directly centered so that it is entirely visible when
|
||||
// looking fully up.
|
||||
skytexturemid = 0;
|
||||
skystretch = false;
|
||||
}
|
||||
skyheight = fskyheight << skystretch;
|
||||
|
||||
if (viewwidth && viewheight)
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = (r_Yaspect*FRACUNIT) / ((freelookviewheight * viewwidth) / viewwidth);
|
||||
skyscale = (((freelookviewheight * viewwidth) / viewwidth) << FRACBITS) /
|
||||
|
@ -113,26 +115,18 @@ void R_InitSkyMap ()
|
|||
skyscale = Scale (skyscale, 2048, FieldOfView);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale = Scale(skyscale, SKYSTRETCH_HEIGHT, skyheight);
|
||||
skyiscale = Scale(skyiscale, skyheight, SKYSTRETCH_HEIGHT);
|
||||
skytexturemid = Scale(skytexturemid, skyheight, SKYSTRETCH_HEIGHT);
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||
// the texture as the cylinder's circumfrence.
|
||||
sky1cyl = MAX(skytex1->GetWidth(), skytex1->xScale >> (16 - 10));
|
||||
sky2cyl = MAX(skytex2->GetWidth(), skytex2->xScale >> (16 - 10));
|
||||
|
||||
// If we are stretching short skies, we also stretch them horizontally by halving the
|
||||
// circumfrence of the sky cylinder, unless the texture is 512 or more pixels wide,
|
||||
// in which case we only stretch it vertically.
|
||||
if (skystretch)
|
||||
{
|
||||
if (skytex1->GetScaledWidth() < 512)
|
||||
{
|
||||
sky1cyl >>= 1;
|
||||
}
|
||||
if (skytex2->GetScaledWidth() < 512)
|
||||
{
|
||||
sky2cyl >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,11 @@ extern fixed_t sky1cyl, sky2cyl;
|
|||
extern FTextureID sky1texture, sky2texture;
|
||||
extern double sky1pos, sky2pos;
|
||||
extern fixed_t skytexturemid;
|
||||
extern int skystretch;
|
||||
extern fixed_t skyiscale;
|
||||
extern fixed_t skyscale;
|
||||
extern fixed_t skyheight;
|
||||
extern bool skystretch;
|
||||
|
||||
#define SKYSTRETCH_HEIGHT 228
|
||||
|
||||
// Called whenever the sky changes.
|
||||
void R_InitSkyMap ();
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
// This file was automatically generated by the
|
||||
// updaterevision tool. Do not edit by hand.
|
||||
|
||||
#define ZD_SVN_REVISION_STRING "1962"
|
||||
#define ZD_SVN_REVISION_NUMBER 1962
|
||||
#define ZD_SVN_REVISION_STRING "1976"
|
||||
#define ZD_SVN_REVISION_NUMBER 1976
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue