Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Apply shaders to achieve Doom Style skies?

Author
Message
Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 11:07
Hi guys,
I've written up a wrapper for the good old Duke Nukem 3D maps.
I'd like to create different skies in my maps similar to those we find in old Doom/ Duke Nukem 3D games. I believe the term used back then was 'parallaxed' graphics - simply an image tossed on the screen without no projection - scrolling background was used in Doom where the skies where moving upward.

The bottom line I thought was very simply to do away with the UV mapping and projection of an object, and just draw the texture flat on the screen where the object is located - however I am at a complete loss as to how to achieve the effect.

The effect is very similar to the "EnvironmentPassThru" shader from the NVIDIA shader library http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html

Can anybody toss me in the right direction?
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 11:12
Can you not just use texture backdrop to achieve this effect?

I'm pretty sure when I tried it, it just looked like the Doom skies when I put a static image onto it.

Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 11:32
Ah, fr@k, I forgot to descibe why that doesn't work.
The thing with the backdrop is two-fold:

1/ In both Doom and Duke you have parts of the map behind the 'parallaxed' surfaces - if I do the backdrop trick, those parts of the map would be visible, flying in the sky - I need the objects to block out everything behind them.

2/ I'd like to have different textures parallaxed.

However - yes, the effect is almost the same - why I did not describe it like that in the first place is beyond me
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 11:42
I'm not really sure I understand what you mean when you say parallaxed surfaces.

The Doom sky was just one image that got pasted behind everything else, it had no parallax effect on anything.

Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 12:28
Well, it has nothing to do with the parallax effect you'd usually do by shaders, that's for sure.

But no, that effect didn't pass the image behind 'everything' only the objects between the viewer and the surface - given it was a raycast engine, everything behind the wall/ surface was not considered to be visible.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 12:40


I think I need a diagram or something. xD

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jan 2011 12:48
I'm as confused as COwbox here. How can the sky be in front of anything?

Perhaps you don't mean the sky after all?
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 12:54 Edited at: 4th Jan 2011 16:16
Aye I think that's part of what I'm misunderstanding. - That and the use of the word parallax. :S (I know what I know parallax to mean and I can't picture it in a Doom sky context to be honest.)

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Jan 2011 13:47 Edited at: 4th Jan 2011 14:00
Manson, maybe you could find a screen shot in Doom of what you're talking about?

Quote: " I believe the term used back then was 'parallaxed' graphics - simply an image tossed on the screen without no projection"

That's not really what parallax means. It's the illusion that objects further away move slower. For instance, in a side-scrolling game, you might have a bunch of trees scrolling by in the background, but behind that you'd have lets say maybe a mountain scene that scrolls at half the speed, giving you the illusion the mountains are further away than the trees.

If that's what you're trying to do with different sky textures then you'd probably want to have multiple textured planes. But like the rest of everyone, I'm not sure what you mean when you say some objects would be behind it.

"Only the educated are free" ~Epictetus
"Imagination is more important than knowledge..." ~Einstein
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Jan 2011 14:19
Parallax-The apparent displacement of an object as seen from two different points that are not on a line with the object...

So basically faking a 2D sky in this way would be to move the 2D sky image by a percentage of the camera movement to make it look like the sky is a certain distance away and not just a static image, right?

In 3D you would get the same effect by using a skybox/sphere scaled to a certain size which moves a small amount as the player moves giving the effect that it isn't a static background.

Not sure how good that would look but is that what you are trying to achieve?

Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 14:23 Edited at: 4th Jan 2011 14:31
Thanks a lot for helping me out here - it's actually a lot more difficult to explain than I'd first thought - you guys have been out if the DOS games for too long

Anyway, neither of the games exports screenshots to something I can convert to bitmaps, so my best shot to explain this would be some old youtube video: http://www.youtube.com/watch?v=uotZa38Y8KU

The thing is that what appears to be the backdrop is just a flat surface, where the texture just dosn't stick to the UV data.

It's really just like taking a skybox and applying it directly at the "windows" in your map (the points through which you can see the 'sky')

[Edit
I just saw your reply about the skybox - yes, that would explain how the effect would look, but unfortunately not do the trick since objects right behind a wall which is supposed to show a sky would still appear.

The trick realy just is - rather than showing the object, paste it's texture directly to the screen - the visual effect would be the same as using an image for the backdrop, for simple maps, but when they get complicated (ray casting games allowed physics that cannot exist in real 3D - rooms inside rooms etc)
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 14:32
Still sounds like texture backdrop would do the trick to me...

Either that or a normal skysphere. xD

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Jan 2011 14:47
Quote: "but unfortunately not do the trick since objects right behind a wall which is supposed to show a sky would still appear"

Maybe if you can explain what you mean by a "wall which is supposed to show a sky" it would make more sense?

Are you applying the backdrop image to walls? Surely that's the hardest way to do this simple effect.

I would just use a skybox/sphere and then you'll see sky wherever there aren't any objects?

If this is a 2D game couldn't you still paste your 2D images/sprites over a background image or even a 3D sky?

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 4th Jan 2011 15:01
Are you talking about windows and roofs that are see through and how when you look at the the sky appears right up against them? Or am I thinking of a different game..

Go ahead. Walk into Mordor.

Ball State University - Biology Major
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Jan 2011 15:07
I'm still completely baffled.

What's wrong with a standard skybox or sphere centred on or near the camera?
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Jan 2011 15:26
Quote: "I'm still completely baffled."

Me too.

I think the problem is that he's applying the background image to objects. Personally I would just get rid of those objects and use a background object (sphere/box).

I don't think Doom was doing it the way [i think] you are trying to do it.

Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 15:27
Yep Jaeg, that's what I am aiming for, however it's not doable by a skybox - since that'd appear behind everything in the given map.
Baxlash actually put it very right - a wall (or a floor, or a ceiling) that's supposed to show a sky.

This is not doable by the conventional skybox, since anything behind that wall would appear over the sky (which would mess up the appearance of old illogical maps)

I'd very much like to tidy up wy code for you to try and see what I mean, but it relies fully on the gamefiles that are tiet up on 15year old copyrights hold by a broke company

What I have working right now is a skybox, which is drawn by the shader, and therefore appears where the wall logically appears, however it doesn't look right since the box is still rotated and fixed in the gamespace - if it just followed the camera, I could work with it.

But again - a shader that disregards the projections - is that realy difficult? I actually thought it would happen by accident for anybody messing with them?
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Jan 2011 15:44
So you could maybe do this using two cameras, one showing only the skybox rendering to an image, the other rendering your scene after you have applied the image to certain objects... right?

C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 4th Jan 2011 15:45 Edited at: 4th Jan 2011 16:18
This actually sounds like something that was going on in Quake1.

Through my many hours of noclipping through the levels and admiring the architecture and level-designs I noticed that most of the skies in Quake weren't real skyboxes, they were just animated polygons over any window/hole.

So probably what you want is to just design your levels to have animated textures over the windows and that'll do it. - You don't need a shader in my opinion, that would just be overcomplicated. xD

I've tried to screenshot this below:

It's not terribly easy to see without being in the level itself.

Here's screenshots of Doom's sky in the Doomsday engine:
@
It seems to use a skycylinder to me.

revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 4th Jan 2011 16:22 Edited at: 4th Jan 2011 16:26
Using google, I searched for "doom parallax sky" and found a link to a page which was supposed to contain tutorials for this sort of thing, but unfortunately the link is now dead. (http://www.wolfenstein3d.co.uk/links.htm, it is the link to "CHAOS Software")

When I first started learning about game development I used a program called "Qoole" to make Quake2 levels. To setup the sky you had to actually create geometry to encompass the level (cover the windows), and define that it was a sky "portal". To me, this seems to pretty well describe what you are talking about (though the term "parallax" confuses me as well).

Anyways I made this demo which uses a standard cubemap-sky shader to try to mimic Q2's effect. I hope it is of some use to someone...


Edit: That'll teach me to use to use the refresh button, GG's was the last post I saw before posting
Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 4th Jan 2011 20:06
Vow, I have never had this much constructive feedback on anything in this forum - thanks a lot to everybody!
As COwbox is describing it is a tad weird effect, and by the logics of skyboxes, it's downright wrong to apply a sky like that.

That's perfect Mr. Chaos, it works for me right out of the box! Very nice, since this shader allows me to simply just apply the effect to the relevant surfaces, and needn't worry about skyboxes or or effects - simply just adding the effect when loading the map and nothing more.
Your shader is still adding the texture to a cube, which kind of distorts the effect I'm after, the graphics is oriented upside down and scalled extremely, but that gives me something to work with - thank you VERY much, all of you!
Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 5th Jan 2011 01:16
Why do you even need a shader? Just make a plain, lock it to the camera, position it at something near your camera range, and the scroll the texture by the change in camera y rotation.
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 5th Jan 2011 08:22
Quote: "Your shader is still adding the texture to a cube, which kind of distorts the effect I'm after, the graphics is oriented upside down and scalled extremely"
That tells me that your sky texture isn't a cubemap, but is a standard 2D image.

In that case, you might be able to use a free tool called "CubeMapGen" to create a usable texture from your current image.
Manson_NS
22
Years of Service
User Offline
Joined: 4th May 2004
Location: Denmark
Posted: 6th Jan 2011 12:53
Thanks for your followup, it lead me to try another approach with a minor modification to the shader which worked a lot better - the only thing I cannot get my head arround is scrolling the texture on the cube, but I'll simply just have to do without that.

Dr Tank, your idea is good, but just not exactly what I am after, the simplicity of using a shader is just much simpler, since it'll take into account the individual textures of the individual skies that might be placed in the map.

Login to post a reply

Server time is: 2026-07-17 17:12:49
Your offset time is: 2026-07-17 17:12:49