Тёмный

Programming Pseudo 3D Planes aka MODE7 (C++) 

javidx9
Подписаться 315 тыс.
Просмотров 103 тыс.
50% 1

In this video I look at some very simple code that emulates a 3D environment, popularised by the Super Nintendo, known as MODE7. This approach looks at how we can project a frustum into a texture to give a compelling pseudo 3d experience.
Source: github.com/OneLoneCoder/Javid...
Discord: / discord
Blog: www.onelonecoder.com
Twitter: @javidx9
Twitch: javidx9

Наука

Опубликовано:

 

14 апр 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 203   
@LeoOno
@LeoOno 6 лет назад
awesome as always ! you are really very talented for explaining your knowledge in a very clear, objective, interesting and very easy way to understand :)
@javidx9
@javidx9 6 лет назад
Hey thanks Leo. I must apologise, I thought you'd stopped posting videos as I wasn't getting any notifications, and somehow the bell had been switched off - I'm catching up now and will likely steal some of your ideas :D.
@LeoOno
@LeoOno 6 лет назад
ow i would be honored, but my stuff are already things that i get from someone else, so no problem xD ...
@VanillaMidgetSSBM
@VanillaMidgetSSBM 6 лет назад
Javid don't you know, Stealing is just a programmers form of collaboration!
@developersmith1920
@developersmith1920 3 года назад
@@javidx9 Me too creating a Video Game with Mode7 ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9YDV2DEM3gc.html
@RhoTrepaan
@RhoTrepaan 6 лет назад
You, sir, are a king in explaining programming techniques.
@CykPykMyk
@CykPykMyk 6 лет назад
Dear javidx9, your channel is gold mine. Best regards. :)
@javidx9
@javidx9 6 лет назад
Thanks Xavery :D
@joshelguapo5563
@joshelguapo5563 2 года назад
You're a saint! I've been looking for soemthing exactly like this for a while!
@hypernarutouzumaki
@hypernarutouzumaki 5 лет назад
I just discovered your channel and i am so glad i did! Thank you so much for uploading all these videos!
@javidx9
@javidx9 5 лет назад
Hi Kartik, thanks, no problem!
@AcceleratingUniverse
@AcceleratingUniverse 5 лет назад
i have been watching computer science and programming related videos on youtube since there was youtube; your channel is the first i've seen to imply a genuine understanding of the concepts as well as the mathematical underpinnings of the concepts you demonstrate.
@javidx9
@javidx9 5 лет назад
Thats really nice of you to say AcceleratingUniverse, I appreciate it a lot, thanks!
@fuzzycat3651
@fuzzycat3651 5 лет назад
That curvature was a problem I was having in one of my projects. I fixed it, but it had to do with the near plane/far plane issue like it does here. This topic is really interesting!
@fuzzycat3651
@fuzzycat3651 5 лет назад
That horizontal black bar in the center should only appear when you have an odd number of pixels for the screen height, right? Because if the height is even, then that infinity value falls right between the two pixels in the center.
@javidx9
@javidx9 5 лет назад
Hi FuzzyCat, yup, spot on. Not many monitors with odd rows of pixels though :D This is often a problem with computer graphics, as things tend to favour powers of two, but there is no accessible middle pixel in those circumstances.
@illdie314
@illdie314 2 года назад
I used this to help with building a Mode 7 renderer in GameMaker around a year ago, it was very helpful! But I want to mention that there are some inaccuracies towards the end of the video that I didn't notice until I tried stretching the system further. Once you switched to division at 19:15, there is no longer a far plane - the "far plane" variables actually represent the near plane now (that's what produces the impression of vertical camera movement), and the "near plane" warps the scaling between the frustum and the viewport, which produces the curvature. Not realizing this ended up leading to some headaches for me so I wanted to point it out in case it is helpful to someone else!
@jelleverest
@jelleverest 6 лет назад
As always a great tutorial! Thank you very much for making these!
@javidx9
@javidx9 6 лет назад
Thanks Jelle!
@3DSage
@3DSage 6 лет назад
This was really fascinating to watch. You do a great job explaining it so I can understand. Great video!
@javidx9
@javidx9 6 лет назад
Thanks Sage, another GBA candidate? :D
@3DSage
@3DSage 6 лет назад
haha yes i was thinking about it! :) Maybe adding this to the raycaster. Or make a gba racing game would be fun. I wonder how hard it would be to remove floats and division.
@DarkoMesarosSubotica
@DarkoMesarosSubotica 6 лет назад
You Sir, deserve much more attention! Amazing content!
@javidx9
@javidx9 6 лет назад
Thanks Darko!
@user-pu4eg5oq4h
@user-pu4eg5oq4h 8 месяцев назад
mode7の温かみのあるグラフィックが大好きです
@dasten123
@dasten123 6 лет назад
AMAZING!!! This is pure gold!! Thank you so much for this tutorial! :DD
@javidx9
@javidx9 6 лет назад
Thanks dasten, no problem!
@mattt2684
@mattt2684 6 лет назад
Why do your videos come out at the perfect times? 👌👍🙂
@javidx9
@javidx9 6 лет назад
Hi Matt, that'll be the subtle mind control working via the last few videos...
@jmalmsten
@jmalmsten 6 лет назад
A few things to add for more 2.5D realism: - Add a background that doesn't perspective warp and doesn't scale to make it infinitely distant. - Add a fuzzy line of sky color over the horizon line that can simulate atmospheric effects - You can also add an effect on characters/vehicles etc. that their contrast go down as their distance from the camera go up. Add to that a tint of sky color and they can fade into the horizon in a nice way. - You can also have layers of transparent clouds at the top. Maybe have different scaling to imply different distances with subtle paralaxing. Just a few things that popped into my head as I was watching. :)
@javidx9
@javidx9 6 лет назад
All good ideas, though the console is limiting when it comes to scaling and colour resolution, but if you are not in the console, good stuff!
@TheKhanQ
@TheKhanQ 6 лет назад
Super cool stuff. I was just watching darbs speed run of F-Zero on the SNES and he was mentioning MODE7. Thank you very much. greetings
@javidx9
@javidx9 6 лет назад
I didnt know darbs had started running F-Zero now, hmmm, I'll check it out, but I didn't thing there was much room for strats in that game - obviously I'm wrong if darbian is doing it lol
@TheKhanQ
@TheKhanQ 6 лет назад
Well, F-Zero is a hard game. You don't need glitches to make it interesting for a speed-runner. Darbian was doing F-Zero in a 12 hour challange which was just speed running a new game 12 hours one weekend. greetings
@TheIsolatedGamerz
@TheIsolatedGamerz 6 лет назад
Dude I love your work. Thank you
@javidx9
@javidx9 6 лет назад
Thanks TIG!
@hallakim184
@hallakim184 6 лет назад
This is exactly what I was looking for. Great!
@javidx9
@javidx9 6 лет назад
Psychic Coding :-S
@joshua7426
@joshua7426 5 лет назад
There was a group that did this with the gameboy color pokemon game and it turned out really well... I wondered how it was done(granted it's a full game so alot of work) but this pretty much explained it all.... thanks
@javidx9
@javidx9 5 лет назад
No problem buddy. This technique would be more complicated to do on a game boy so thats quite impressive.
@natevb9901
@natevb9901 4 года назад
Fun video to watch. Been a long since I've thought in terms of Mode7. Not to hinder the efforts of your member who is doing image-to-sprite transforms, there's a neat visual studio addin by incre of the main guys on the c# team. He created a sprite addin that will take an image you've loaded into VS, (or more if selected), right-click, and create sprites. It also works with the built-in image editor (or possibly enhances it... Been a while since I've needed to do graphical work in a project until recently). But it seems to work in a language-agnostic manner, as it should.
@Justnothankyou132
@Justnothankyou132 3 года назад
Amazing video, thanks for sharing
@johnmendez4998
@johnmendez4998 5 лет назад
I always press like on your videos before I even watch them! 😁
@markruddyjr56
@markruddyjr56 6 лет назад
Very awesome as always.
@javidx9
@javidx9 6 лет назад
Cheers Mark.
@ahsosorry
@ahsosorry 2 года назад
thanks man! This helped with a raycaster engine i was working on :)
@leberkassemmel
@leberkassemmel 6 лет назад
So that’s how they did hills in Mode7! Crazy stuff.
@javidx9
@javidx9 6 лет назад
Kind of, its all an optical illusion really. If you add more scenery like trees for example, you can make the illusion even more compelling.
@F0r3v3rT0m0rr0w
@F0r3v3rT0m0rr0w 6 лет назад
This ... is so freaking cool! ...
@francescopiazza4882
@francescopiazza4882 4 года назад
Very good stuff!
@em00k
@em00k 4 года назад
Excellent video.
@colinwatts9232
@colinwatts9232 5 лет назад
FrustRum! God, you're so frustating x Love your work man
@NeilRoy
@NeilRoy 6 лет назад
Great stuff. I was recently contemplating coding an old style 3D engine, only for normal graphics in C. Doing all the 3D stuff myself, completely software just for fun. Perhaps using plain Windows code. You could easily expand on this further using concepts you already introduced, drawing sprites at certain locations (trees, poles would work well with racing games). Lots of potential here, could redo your RPG so it is in 3D instead.
@javidx9
@javidx9 6 лет назад
Cheers Neil, yeah I think theres lots of potential. I've just been fiddling about trying to add height to it too. I reckon there're some interesting videos to be made with this. I have some plans for a racing game too.
@levitationlee3450
@levitationlee3450 4 года назад
Hi mr javid, i really appreciate your videos, they have been helping me a lot in learning the cool techniques behind some of my favourite childhood videogames. May u make a serie on the pre rendered background? the one that was used in 90's games like resident evil, final fantasy 7,.. With love from Vietnam. Thanks again !
@clonkex
@clonkex 3 года назад
Btw series is both singular and plural, so it's 1 series, 2 series, 3 series, etc.
@chriswinslow
@chriswinslow 6 лет назад
Who on earth disliked this video? It must have been by mistake lol. But thank you for another great video. Very informative and interesting, I do remember the Mode 7 days of the SNES, I was so impressed when when I saw graphics being scaled and rotated them were the days 😌
@javidx9
@javidx9 6 лет назад
There's always that one guy that doesnt like retro pseudo 3d graphics emulated in a windows command prompt...
@chriswinslow
@chriswinslow 6 лет назад
Always one 🙄
@JimGiant
@JimGiant 6 лет назад
I started work on something similar but combined with your "Perlin" noise generator to make a 3d landscape. Unfortunately I got side tracked to a more serious project so never got it finished.
@javidx9
@javidx9 6 лет назад
It happens Jim, it happens, I've a folder full of "work in progress"
@tails_the_god
@tails_the_god 3 года назад
This guy is a programming wizard
@s-sugoi835
@s-sugoi835 6 лет назад
thats beautiful
@Magikookeven
@Magikookeven 5 лет назад
Amazing video man!
@theignorantphilosopher4855
@theignorantphilosopher4855 5 лет назад
I have literally been looking for a proper explanation of the perspective problem as far as I can remember, more or less. I think don't quite understand it, but I'm sure another look, or two will do the trick.
@tzisorey
@tzisorey 5 лет назад
"I then need three more pieces of information. What is the nearest location to the camera, which is the furthest location from the camera, and what is your favourite colour!"
@itsGeorgeAgain
@itsGeorgeAgain 6 лет назад
I keep seeing the sky as a ceiling that is the same distance from my head as the ground is. I guess that's why mario kart didn't use that kind of sky technique but a 2D background. The curvature really reminds me of Terranigma, when you are underground.
@javidx9
@javidx9 6 лет назад
Yeah, I dont like how the sky moves up and down either, I think for a flight sim you would need different sample coordinates for the sky and ground
@jmalmsten
@jmalmsten 6 лет назад
I guess that it would look nicer to just have the sky as a simple background that simply pans around matching the rotation of the camera so it looks like unfinite distance. Maybe have a cloud layer or two as separate mode 7 textures though to keep things more interesting. But have them fade out towards the horizon to make it nicer.
@tomaskot9278
@tomaskot9278 5 лет назад
Sky should be considered very far away and thus it can be rendered completely stationary, you just rotate it with the player but dont move it.
@vinayaksharma8387
@vinayaksharma8387 5 лет назад
I want to do this!! How are you so smart?! You must be really remarkable in Math!!
@thefoolishgmodcube2644
@thefoolishgmodcube2644 6 лет назад
Are we going to see more plane related videos like this in the future? That would be dope.
@javidx9
@javidx9 6 лет назад
Yes I think we will, its a great starting point for racing games, flight sims, shooting games...
@MrVainSCL
@MrVainSCL 5 лет назад
Very nice tutorials / videos! But i still have a question... What does your rendering engine uses? Does it is 100% software rendering (GDI, DIB) - or are you using APIs like OpenGL, DX to render things on screen)? Keep on your nice work!
@javidx9
@javidx9 5 лет назад
Thanks! The Pixelgameengine uses a single opengl1.1 call to display the screen buffer on the screen.
@scriptingtutorials4060
@scriptingtutorials4060 6 лет назад
Hey, Can you do a whole series on a 3D game engine from scratch, but every time we do something "huge(a big HELPFUL change)" we take a break and make a game with it to see what we can do. and then you keep repeating this cycle to get a good game engine series. no one has any tutorials like you, your awesome!
@scriptingtutorials4060
@scriptingtutorials4060 6 лет назад
Just an idea but i haven't seen a good tutorial on this before and i look a lot.
@flavioarruda4452
@flavioarruda4452 4 года назад
Awesome!!! Congratulations man! I would like to see this racing in Stencyl engine... Is it possible? Do you know Stencyl?
@BrekMartin
@BrekMartin 5 лет назад
I missed this one at the time. I wonder if something like this is behind the GPS map automotive view. You could plot points, and connect with lines on the new projection.
@javidx9
@javidx9 5 лет назад
Hi Brek! I think you could easily replicate the projection with a projection matrix and draw things into your scene. In fact use the matrix to also create the sampling points for the FOB quad.
@MacShrike
@MacShrike 5 лет назад
Dear Javid, 1st. Best of wishes for 2019 =) I did something similar, I think I mentioned that before. In this gameconsole... library? in c++ if I understand correctly, you actually draw/plot all the pixels? I'm coding for GPU's and can only use (fast enough) polygons, quads and scaling. I found that although I could make it look 3d-ish, When confronted with enemy 3d location and flying bullets/rockets it was hard to create gratifying control and execution. Then again, my math skills are really rusty and basically just bad. But I'm learning from you and you make it a pleasant journey, thank you! Highest regards, Mac
@javidx9
@javidx9 5 лет назад
Hey Mac, Happy new year to you too! Yes I do everything using the CPU. Introducing the GPU would make some of the videos quite boring given all the setup code required.
@iProgramInCpp
@iProgramInCpp 4 года назад
@@javidx9 Says the 1 year younger Javid. Now you have decals in the PGE 2.0 :)
@JaviBite
@JaviBite 4 года назад
Hi! i have a question, how whould you do to put movile sprites on the map, how would you map them? thank you!
@sophiacristina
@sophiacristina 5 лет назад
Did you wrote all your engine by yourself (Lone coder)? You must be very patient and passionate in coding, that is great, keep on!
@javidx9
@javidx9 5 лет назад
Yes, all the code I present on the channel is a solo project (unless I explicitly state otherwise). The trick is to just keep things as a hobby, if it stops being fun then dont carry on with it.
@thefoolishgmodcube2644
@thefoolishgmodcube2644 6 лет назад
Nice
@aikou2886
@aikou2886 5 лет назад
I have just discovered your channel and I really like your content, however, I think I need to ask this: Do you happen to have C++ tutorials for complete beginners? A few of the topics you cover are really interesting but they are really advanced for me as well.
@javidx9
@javidx9 5 лет назад
Hi and thanks Aikou! I have a couple of videos about programming in general for beginners, but ultimately no, I dont have any aimed towards complete beginners. I try to make videos which dont even rely on you using C++, even though I do, the concepts are easily portable to other languages.
@aikou2886
@aikou2886 5 лет назад
@@javidx9 Oh that's fine, I'm acquainted with some basic concepts of both Java and C++ but I asked the complete beginner part because that's pretty much how I see myself when I watch some of your content lol (yes, the 3D engine videos blew my mind). I'm teaching myself how to code so I don't really know much other than the two languages I mentioned but I'll try to pay more attention to your "code-it-yourself" series. Thank you so much for replying to my comment.
@spencerhall7157
@spencerhall7157 4 года назад
I am confused about how fSampleDepth fits onto the frustum. If fSampleDepth is normalized between 0 and 1, and you calculate (fFarX1 - fNearX1) / fSampleDepth, you'll get an x value that's outside of the range from fNearX1 to fFarX1. The same goes for the other three calculations to get fStartX, fStartY, fEndX, and fEndY. But if all of the x, y coordinates calculated from dividing by fSampleDepth lie beyond the far plane of the frustum, that contradicts the premise that the far plane is the maximum distance the camera can see. To make matters more confusing, at 17:56, the y marks are drawn on the frustum y-axis. But you can't sample from the frustum at those y points given the way that fSampleDepth is used, because dividing the differences between fFarX1 and fNearX1, fFarY2 and fNearY2, etc. by a number less than 1 will give a value that doesn't even fall within the frustum. Am I missing something here?
@WolfGr33d
@WolfGr33d 3 года назад
Hi, kind of new to the channel. So have you already made a video explaining as to how you made 'olcConsoleGameEngine'? I really want to make a Mode7 game of my own, but I doubt I'll be able to follow along with what you're doing without a game engine to access.
@Fezezen
@Fezezen 4 года назад
I've tried at drawing sprites to the screen in the pseudo 3d space, but I just can't find an algorithm that works. And I mean like the sprites of the other racers, how they get smaller the further they are. I have no clue how to get their screen coords from the top down 2d coords.
@goupilsystem4717
@goupilsystem4717 5 лет назад
Fantastic pedagogic skills, thank you so much. I've been only developing on XNA and Unity, so my question may sound naive, but I only see mathematics here. Does it mean that the Mode7/scaling abilities of the Snes was only implementation of mathematic specific functions? How was this impossible for a developer on Megadrive not to approach the same result through pure code?
@javidx9
@javidx9 5 лет назад
Thanks Goupil! The Snes had hardware specifically capable of performing an Affine Transform, which is the effect emulated in this video. To be fair, I too could have implemented an affine transform directly but kept it simple with linear(ish) interpolations. On our modern hardware at these resolutions its no big deal, but back in the 90s, doing a per pixel affine transform would have been quite a challenge without dedicated processing units. The megadrive lacked such additional hardware, but had its own features that could produce effects the snes couldnt.
@goupilsystem4717
@goupilsystem4717 5 лет назад
Wow that was quick, thank you. I've been thinking for a while about 3d prototypes with Mode7 rendering on Unity, for nostalgic esthetic purpose. Since there is no such concept as canvas on Unity but only textured quads, so far the only solution I could consider would be to add a purely graphic "pixel-perfect layer" above the regular 3d display, which would be seen through a camera with no perspective. In this extra layer, some 2d looking-squads would be displaced "pixel by pixel" (an arbitrary unit) following the edges of the models in the back-layer (sorry it's a bit hard to explain for a non-native english speaker). I didn't find much work on this subject, so if some other persons had been working on it, I'd be very interested to hear some alternative solutions. Keep up the good work!
@t0biascze644
@t0biascze644 2 года назад
it is possible on Mega Drive through pure code :) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-X975THoQ6DE.html
@ticiusarakan
@ticiusarakan 2 года назад
очень интересно и как всегда доходчиво. я не программист а 3д художник, но посмотрев ваши видео про рейкастинг мне пришла в голову интересная идея. а можно ли сделать такой же мод 7, но не для текстуры а для поля векторов? таким образом можно было бы избежать ресурсоёмкого рейкастинга и бсп зонирования. и если можно, сделайте пожалуйста видео про это)
@stefanveselinovic4777
@stefanveselinovic4777 6 лет назад
PogChamp
@javidx9
@javidx9 6 лет назад
kappa
@karatepolska
@karatepolska 3 года назад
I am playing around with my raycasting engine on a older hardware.. I wonder if that techinque could replace my current floor and ceiling drawing. But also I can mouse look around and my floors can contain different textures per grid, I wonder if mode7 can handle it..
@inceptional
@inceptional 3 года назад
So, it it possible to have a Mode 7 background loop on SNES so that when you get to the end it doesn't appear to actually end and instead just go on forever, like in an endless ultimately repeating map terrain of hills and rivers and so on for example?
@grevel1376
@grevel1376 4 года назад
How can I optimize it? I have a canvas made of 700x500 pixels in java awt, and Im running on about 13fps.
@naejimba
@naejimba 9 месяцев назад
So how do you make the portion of the screen that shows the land higher and less sky? If you look at the original F-Zero I believe it is 83% of the screen is taken up by land. This is important as it lets you see farther ahead. =) Also, at around 20:25 you talk about altering the "near plane." This looks like some pretty convincing going up and down hills... would it be possible to utilize this to imply it or is there some reason why this wouldn't work? Because that seems like a good way to get even more of a pseudo 3D effect.
@matheusmcdouradinho4790
@matheusmcdouradinho4790 3 года назад
Do you can make a tutorial from how to add collision in Mode 7 games?
@nonoroberto8219
@nonoroberto8219 5 лет назад
Wonderful job, but i actually don't get exactly what is the mathematical justification about the 19:07 when you replace *(1-fSampleDepth) by /fSampleDepth. Actually, as a first shot i would say that's because the perspective formula is based about dividing by Z. Like to have the perspective projection of (x,y,z) you do (x/z,y/z,1). But in your case you're doing a kind of texture mapping and your idea seems to be that more a scanline is near the middle, more it is mapped far on the floor, can you explain why do dividing by fSampleDepth does the job ?
@javidx9
@javidx9 5 лет назад
Hi roberto, in principle you are correct, perspective is not linear. When my calculations were linear, they generated curved looking projections. Dividing by fSampleDepth straightens it out because I need a 1/Z somewhere in the transformation.
@nonoroberto8219
@nonoroberto8219 5 лет назад
@@javidx9 OK I see. Cause actually you can find the same equation when doing ray casting on a plane. If you got a vector v= (x, y, z) and a plane which equation is z=-1 assuming that the player is a point p=(xp, yp, 0) the intersection with the ray casted from the player will be finded by resolving the system of p+v*k and z=-1. So by resolving pz+vz*k=-1 which gives k=-1/vz - pz which gives k=-1/vz cause pz=0. So p+v*(1/vz) gives the intersection point. So we can get x and y coordinate from the plane with it. And it is exactly the formula you used. But actually mine is multiplied by - 1. It should invert x and y. Do your rotation is inverted? By the way the formula I gave you is based on raycasting. A way to produce a kind of perspective vision based on optics geometry and physics. And it seems to work.
@djaccount5458
@djaccount5458 8 месяцев назад
How calculate sprite position from bird view (x,y) to projected view 3d??
@paul8028
@paul8028 6 лет назад
How can you render sprites (cars in this case) that move through the track and rotate?
@javidx9
@javidx9 6 лет назад
Hi Pablo, you can render a sprite the same way I have done in many videos, making it rotate is tough. If looking top down, you can use a rotational transformation matrix to rotate the sprite, looking from behind as would be the case here, you would just need several sprites.
@PauloConstantino167
@PauloConstantino167 6 лет назад
Very cool my friend! I am programming a true 3d engine from scratch and I've uploaded a video of its first version. You might wanna have a look at it just for fun.
@xupculture_studios2114
@xupculture_studios2114 6 лет назад
am new to programming, you make it look really easy. i decided to try out the tetris cos i love that game.will it compile on c++ 2010. i see you are using modern IDE.
@javidx9
@javidx9 6 лет назад
It "should" compile with 2010, however a lot of my more recent videos will probably not. The tetris code i present here is simple enough that any unsupported features could be worked around quite simply.
@xupculture_studios2114
@xupculture_studios2114 6 лет назад
thanks, one question though the capture listing is it serving as lambda am still learning that syntax and how it works, i hear it works only on 2011 and upward releases
@xupculture_studios2114
@xupculture_studios2114 6 лет назад
i share your persona, am really a lone wolf and i don't do too well in groups ,i read alot and am way too selective.
@javidx9
@javidx9 6 лет назад
Yes, lambda functions need a recent version of C++, you can just replace them with a regular function though, it may just need a few more arguments.
@VitalZero
@VitalZero 3 года назад
Hi!, I tried this on processing (java), in theory, should be the same (because the algorithm is what matters), but is not. I had to multiply the sample X and Y to grid width and grid height / 2, respectively. Besides, had to check whether X or Y were below 0 and remove the sign (mult by -1), otherwise an ugly gray area was drawn and some parts of the window were not cleared. Why is that? Is it due to your pixel scaling (1 pixel = 4 pixels)?
@javidx9
@javidx9 3 года назад
I dont think the pixel scaling would be the culprit, could be the organisation of the textures is different? dunno...
@szymoniak75
@szymoniak75 6 лет назад
new video!!!!!!!!!!!!!!!!!!!
@ianmarshall3310
@ianmarshall3310 5 лет назад
Is there a way to lower the angle of the camera for a third person view?
@javidx9
@javidx9 5 лет назад
Hi Ian, yes there is. If you angle the camera downwards, you are reducing the near and far plane distances, so that's easy enough. The problem is this wont look right because we expect the horizon to raise as we look down, so you will need to do this also. In this video I split the ground/sky 50/50, you may need to try other ratios until it feels correct.
@ianmarshall3310
@ianmarshall3310 5 лет назад
@@javidx9 That worked great thanks!
@Ryan-xq3kl
@Ryan-xq3kl 3 года назад
I feel like this could be well applied with fractal art
@johnnycrash1624
@johnnycrash1624 5 лет назад
I have a question regarding the formula (fFarX - fNearX) / fSampleDepth + fNearX. When fSampleDepth = 0, in the middle of the screen, the result is infinity, so you can see as far as possible. But for fSampleDepth = 1, you simply get fFarX, so at the bottom of the screen is the far plane. You're really rendering everything from the far plane to infinity, rather than everything between the two planes. Wasn't the goal to render everything inside the view frustrum, not everything behind it? And it's visible that your near plane isn't actually the near plane, as changing it doesn't change what you can see, it only adds that weird curvature. I'd expect the result to be perspectively correct, without any curvature, regardless of where the near plane is.
@rol1939
@rol1939 5 лет назад
For a better formula see my blog at: tegtips.blogspot.com/2019/04/correcting-pseudo-3d-planes-aka-mode7.html
@Justnothankyou132
@Justnothankyou132 3 года назад
At line 84 19:38, how do you not get a divide-by-zero error? Doesn't (y) start at 0, giving a sampleDepth of zero, then causing the first section of fStartX to divide by zero? Edit: C++ works differently than other languages :P
@Kavukamari
@Kavukamari 5 лет назад
I just implemented this in pico8 and my topmost line is showing really bizzarre artifacts, probably because dividing by zero gives 32768. I could just set the top line to something else, but any idea how to sensibly deal with it without just hiding it?
@javidx9
@javidx9 5 лет назад
Hi Kavukamari, sometimes, you just need a little hack! Chances are you're right, you are getting some overflow/underflow mess for that particular row. Without knowing your precise implementation I can only speculate, but if a hack works, then go for it!
@mistervoldemort7540
@mistervoldemort7540 6 лет назад
Thanks for the nice video, but what is the fundamental difference between a png and a sprite file?
@javidx9
@javidx9 6 лет назад
Sprite files store ASCII characters that make up the "pixels" used in the console game engine, dont forget that ultimately this is still just a windows command prompt, so the concept of "pixel" does not really apply. A PNG file is a traditional format image file which stores pixels in RGB format (with some compression). My Code-It-Yourself Frogger video introduced sprites and how they work.
@mistervoldemort7540
@mistervoldemort7540 6 лет назад
Thanks so much for the explanation! I'll check out that video
@theears995
@theears995 6 лет назад
Using this technique, I bet you could make a sort of flight simulator! It’s not true 3D, obviously, but it at least gives the illusion of 3D. (Considering you could “move up or down” in this psudeo-3D world, a flight simulator wouldn’t be very hard, I’d imagine).
@javidx9
@javidx9 6 лет назад
Yup, I could get at least 25 videos out of this! Space shooter, underwater shooter, WW2 simulator...
@theears995
@theears995 6 лет назад
javidx9 Programming gives us almost unlimited possibilities, and that’s what I love about it - there’s virtually unlimited things people can do with code :) I view programming as a sort of art form in that regard 😛
@CreepyBio
@CreepyBio 5 лет назад
Stop talking
@stumbling
@stumbling 5 лет назад
24:12 You've created Spoon Racer 2018 :P
@jensBendig
@jensBendig 4 года назад
Mode7...now I learn something "new"! What about using this together with the Raycaster? Shouldn't that bring walls plus sky and ground?
@javidx9
@javidx9 4 года назад
It could certainly be used for planes in a ray caster yes!
@chrissxMedia
@chrissxMedia 6 лет назад
omg played super mario kart a hour ago lol
@olasoderlind5685
@olasoderlind5685 4 года назад
its like tranforme in PhotoShop
@MsKocagoz
@MsKocagoz 6 лет назад
what kind of king are you?
@johneymute
@johneymute 3 года назад
I have a question is mode 7 rotation and moving backgrounds in real 3D space?? Or is it all faked by stretching,shrinking,skewing and shearing an image?? Also is rotation just faked by moving scanline horizontally and vertically atonce??? Anso since mode 7 is only 1 single background, then how could it be that i see multiple moving backgrounds in street racer and mario kart?? Thanks alot in case you will ansure these wuestions.
@javidx9
@javidx9 3 года назад
The "effect" of mode 7 is achieved purely as a transform distorting a 2D image. Arguably, 3D doesn't actually exist since it must be in 2D form to display on a screen, but that's a whole other video. The background can be whatever you want it to be, 8 see no reason for restrictions, and rotation is often more complex than just scrolling horizontally.
@johneymute
@johneymute 3 года назад
@@javidx9 so theres even no 3D space at all??? And how about the backgrounds, for what i do know is that the snes cannot do 4 backgrounds and mode 7 atonce no, so how were those multi scrolling backgrounds done in street racer and mario kart???
@xbelanch
@xbelanch 5 лет назад
First of all, thanks for that useful video tutorial. Trying to porting the code I found that fSampleDepth = 0 when y = 0 so you're dividing by 0 and the result equals to inf. Sure I'm wrong but I can't find any workaround to solve it :-/
@fruitpunchoreos7449
@fruitpunchoreos7449 2 года назад
start the loop with y = 1
@SM-ht7qf
@SM-ht7qf 5 лет назад
How would you do this in Python and Pygame?
@javidx9
@javidx9 5 лет назад
Hi SM, I don't know Python very well so I can't help you, sorry about that
@purpleice2343
@purpleice2343 5 лет назад
The math is exactly the same, what you'd do is either modify texture and then render it using pygame or instead use shaders to sample textures on a quad that would take up entire screen (since this problem is actually horribly parallel).
@sirspeedy9583
@sirspeedy9583 6 лет назад
more!!!!!
@javidx9
@javidx9 6 лет назад
I'm workin' on it! I'm workin' on it! :D
@fabricio4794
@fabricio4794 Год назад
i will try this on chatgpt to run this on Blender code,is it possible?
@inlandish
@inlandish 5 лет назад
how to increase the quality?
@ricarleite
@ricarleite 5 лет назад
Mode 7 doesn't quite work like this, it uses HDMA to skew the image.
@snurffff
@snurffff 5 лет назад
Its fake mode7
@draconitalag3756
@draconitalag3756 5 лет назад
Which game engine is this? Game Maker Studio?
@javidx9
@javidx9 5 лет назад
Hi Draconita, this is a single file custom game engine which I use for all my videos called olcConsoleGameEngine. Its simple to use and has the odd characteristic that everything you see is rendered inside a windows command prompt. The source is all available in the description. Ive recently released a newer version which is more conventional in terms of graphical style but retains the simplicity, thats called olcPixelGameEngine, and I have a video exclusively about this too.
@iProgramInCpp
@iProgramInCpp 4 года назад
I made one by recreating what the actual SNES did a year ago.
@goldenguy_dev
@goldenguy_dev 5 лет назад
please make a tutorial of how to calculate positions for sprites to render them on the map :( or reply if there is a good documentation
@javidx9
@javidx9 5 лет назад
Hi GoldenGuy, ill be following this video up with something similar to what you're asking in due course, calculating the position is no different from translating a pixel in the map into screen space, as the map pixels are in world space too. The tricky part is scaling the sprite in accordance with the perspective. This can be derived from the scaling mechanism in use too, but may need some experimentation.
@somebodyjohnson6220
@somebodyjohnson6220 4 года назад
@@javidx9 Mr Javidx I am also struggling to calculate the screen position, could you please give a couple pointers? I understand the frustum corners but am unable to place the object on the screen correctly.
@mohamedakaddar5735
@mohamedakaddar5735 11 месяцев назад
I can’t be able to understand what are you explaining. I ve 4 years in programming ! What do you think about this problem which i have ?
@tomk435
@tomk435 6 лет назад
Awesome video but did anyone notice how he said Mario kart... it kills me. Although it’s still amazing how he’s able to do this in command prompt
@javidx9
@javidx9 6 лет назад
Thanks! lol, how do I say Mario Kart? :D
@tomk435
@tomk435 6 лет назад
M-aaa-rio kart... idk it might be just how different people pronounce it, but it seems that in America everyone says it differently
@RandomGuyyy
@RandomGuyyy 6 лет назад
Just curious, how do they say it in America?
@tomk435
@tomk435 6 лет назад
Mar as in mars the planet e-o so mar-e-o
@CSDragon
@CSDragon 3 года назад
Very useful info, tho that's gotta be the weirdest way I've seen someone write an X. How come you don't just use two intersecting straight lines like normal?
@javidx9
@javidx9 3 года назад
That looks like multiply.
@dominikskeries
@dominikskeries 4 года назад
beginnen question i am on mac can i still follow your videos ?
@javidx9
@javidx9 4 года назад
Yes you can! Theres a port for pixel game engine available in the contributers folder on the repo. I try to make my videos platform/language agnostic so the algorithms are still going to work.
@ancientfools
@ancientfools 5 лет назад
I am on Linux. Can you suggest me another alternative for visual studio. 😀😀😀
@javidx9
@javidx9 5 лет назад
Now that's a heavy question and no matter what answer I give, it will be wrong :D My experience in IDEs, there is sadly little that is comparable to Visual Studio in terms of its integrated debugging facilities. There are many code editors (I believe VS Code is very popular) but few that really permit debugging as fluidly as Visual studio. However, as I'm not a frequent linux user, I could be very wrong in this regard.
@Overlordgaming91
@Overlordgaming91 5 лет назад
you can do it the hard way with any text editor of your choice and a terminal, plenty of programmers do this. i personally recommend Visual Studio Code, it Open Source. and provides the best of IDE like features, while being very customize able. a RU-vid Search for VS Code C++ should give you all kinds of information tip and tricks for getting started. it does require some setup, but that is because it can be tailored to YOUR workflow and how you like to do things. codeblocks is another very popular IDE, Along with QT Creator. most of these can usually be obtained from your Linux distro's Package Manager. sorry if im late and non of this information is needed. Good luck in your Linux Programing Journey :D.
@olasoderlind5685
@olasoderlind5685 4 года назад
not move the skymap x,y whit the player only angle. and make like x move slolwy like a wind clowds are far away
@javidx9
@javidx9 4 года назад
Yeah thats a great idea Ola!
@samserious5483
@samserious5483 Год назад
Super Mario Cart 1992:))
@VanillaMidgetSSBM
@VanillaMidgetSSBM 6 лет назад
When you are testing with the Player position, I noticed the Framerate was at 25-ish FPS...I think we are pushing the Command Prompt too far.
@javidx9
@javidx9 6 лет назад
You could be right, this was in debug mode so its actually about 120fps. However its the variation of the maps that causes the performance drop. The algorithm is a fixed level of complexity so the performance is not related to the properties of the frustum, instead as the pixels become more distinct in appearance the windows algorithm that renders the characters takes a nose dive.
@achtsekundenfurz7876
@achtsekundenfurz7876 3 года назад
> instead as the pixels become more distinct in appearance the windows algorithm that renders the characters takes a nose dive. Those are probably cache misses; if you don't hit the same pixel twice, each pixel has to be loaded from RAM. (Since today's RAM is usually cached in small blocks, about 32 bytes IIRC, that doesn't hit hard unless the pixels are REALLY far apart or from different rows of the texture.) If you profile the program and see a drop in your subroutine rather the API call, that's what causes the drop, even though the number of operations per frame doesn't change. I found another performance issue: Instead of computing fStartX + (fEndX-fStartX)*fSampleWidth, you should consider precomputing fStepX = (fEndX-fStartX)/fScreenWidth and then use a for(x) loop that only adds: fTempX = fStartX; // ditto for fTempY for (x blahblahblah) { fTempX += fStepX; // ditto for fTempY short col = sprGround->SampleColour(fTempX, fTempY); // ditto for sym Draw(blahblahblah); } That won't alleviate the caching issues, but mipmaps will ;) Oh yeah, they look better, too.
@BirinderSingh
@BirinderSingh 3 года назад
I get that he's the lone coder, but he needs to collab with the guy from the coding train.
@bioman1hazard607
@bioman1hazard607 6 лет назад
Ever thought about programming for either the Sega genesis or PlayStation Meaning assembly or c
@javidx9
@javidx9 6 лет назад
Hi Artemis, I did a little bit of NES programming once. The problem with console programming (lol as in gaming console) is the code you write is highly specific for that platform, so you need to invest a lot of time learning how the platform works. There are a few game boy programmers on my discord server, they've managed to find C++ dev kits for the platform too.
Далее
Programming Balls #2 Circles V Edges Collisions C++
32:28
Code-It-Yourself! Role Playing Game Part #1
50:36
Просмотров 207 тыс.
УНИТАЗ В ЛЕСУ?? #shorts
00:24
Просмотров 734 тыс.
Zlatan embarrasses Speed 😂 #ishowspeed
00:32
Просмотров 9 млн
Coding Quickie: Isometric Tiles
22:13
Просмотров 115 тыс.
Programming Mazes
27:11
Просмотров 190 тыс.
How I Made a 3D Platformer in 2D Game Engine
21:23
Просмотров 443 тыс.
2D Sprite Affine Transformations
27:59
Просмотров 33 тыс.
Code-It-Yourself! Simple Tile Based Platform Game #1
39:41
The 20 Most Stunning Mode 7 Uses in SNES Games
8:23
Просмотров 78 тыс.
I Made Sebastian Lague's Procedural Planet In Godot 4
18:07
OZON РАЗБИЛИ 3 КОМПЬЮТЕРА
0:57
Просмотров 1,5 млн