[Code] More Realistic Skyboxes

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Post Reply
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

[Code] More Realistic Skyboxes

Post by Ral22 »

One of the most common things I do in Doom is try and replicate features from other games. Some time ago (Two years, to be exact), I set my sights on creating more interesting skyboxes, mostly inspired by the tricks The Ultimate Doomer would do with is. So, in looking at how modern skyboxes in games are done, this script came to me to have more realistic skyboxes that add a greater sense of depth and scale.

By this, I mean that the skybox viewer actor will be slightly affected by the player's movement, giving a sense of depth to the things in the skybox besides the common, non-moving skyboxes we are currently subjected to in the ZDoom engine. It's only a few lines of code, but is easily modified to fit your needs and be implemented in your own maps.

Code: Select all

Script # ENTER
{
    While(TRUE)
    {
        SetActorPosition(S, GetActorX(0)/A+X*65536, GetActorY(0)/B+Y*65536, GetActorZ(0)/C+Z*65536, 0);
        Delay(1);
    }
}
Script Variable Breakdown:
# = Script number or name
S = Skybox Viewpoint Tag
A = X-Axis Sensitivity Modifier
X = Difference between Player and Skybox Viewpoint in map units on the X-Axis(Can be negative, but not equal to zero)
B = Y-Axis Sensitivty Modifier
Y = Difference between Player and Skybox Viewpoint in map units on the Y-Axis (Can be negative, but not equal to zero)
C = Z-Axis Sensivity Modifier
Z = Difference between Player and Skybox Viewpoint in map units on the Z-Axis (Can be negative, but not equal to zero)

For example:

Code: Select all

Script 1 ENTER
{
    While(TRUE)
    {
        SetActorPosition(1, GetActorX(0)/25+960*65536, GetActorY(0)/25-64*65536, GetActorZ(0)/25-50*65536, 0);
        Delay(1);
    }
}
The Skybox Viewpoint's tag is 1. Variables A, B, C have all been set to 25. The closer these variables are to zero, the more loose the skybox viewpoint's movement is, the higher the values, the movement will be more stiff. Variables X, Y, Z have the difference between the Player actor and the Skybox Viewpoint. Please consult the image below for a visual explanation of variables X and Y.
Spoiler:
The number 65536 is for conversion purposes and should never be changed.

NOTE: When placing a Skybox camera, it MUST be set to an angle of zero. Any other angle causes the alignment to be off.(Although setting it to, say, 180 could cause an interesting effect in void-esque maps.)

Here is an example WAD showcasing the script: http://www.mediafire.com/?92inzehbrp394ts

I will edit this post as it needs to be, to fix errors or add on to answer other's questions that they may have. In the meantime, enjoy the example and code. Please, if you have a question, ask.

P.S.- Since I have done this script, all previous skyboxes (All of the standard, non-moving ones) no longer look right to me. I will not be held accountable if this happens to you as well. :wink:
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [Code] More Realistic Skyboxes

Post by Nash »

Neat trick, although it's obviously not multiplayer friendly. ;( Great for those single player mods though!
User avatar
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: [Code] More Realistic Skyboxes

Post by Ral22 »

Yeah, it's only drawback, I think, is a lack of multiplayer support (And it's a little confusing to implement at first, but that gets ironed out in time). Then again, it is one less script that is constantly repeating itself so that should help keep multiplayer running fast. I suppose it could be possible to have a script that checks if it is in multiplayer mode or not, and if so, could terminate this skybox script, thus giving the map competent support for multiple platforms.
User avatar
Yholl
Posts: 1953
Joined: Mon Dec 17, 2012 11:08 am
Location: Here, stupid.

Re: [Code] More Realistic Skyboxes

Post by Yholl »

Oh wow, this is pretty damn cool. Nice work Ral22!
Post Reply

Return to “Script Library”