General Discussion of the DoomSharp() project.
Printable View
General Discussion of the DoomSharp() project.
So can I see a picture of how you are going to make this picture out of paralelograms?
http://maven.smith.edu/~mcharley/bsp/figure1.jpg
- ØØ -
OK, basically with a texture that has half of it transparent, it effectively becomes a triangular texture. If you want to skew a bitmap in GDI+ you need to specify the first 3 points of a parallelogram (the 4th is implied).
So using 2 overlapping para's and ignoring half of each one we can stitch together a whole trapezium.
Granted the texture will be a bit warped, but if we use subtle textures this will be less noticable, but the outline of the shape will be perfect.
All I need to make this happen is the 4 corners of the para. OR 2 triangles. Triangles would be better because it lets us shade and shadow each part naturally.
Drawing the first parralelogram (remember the textore us triangular because of the transparent part)...
Then the bottom para... (this time the transparent part is on the other side of the texture)
both of those drawn will look like the picture that noteme posted.
We ned to use simple textures to make this look right though.
If we wanted to use just a single color within the quad, it would be a simple matter of filling a polygon, and we might do this for objects far away in the distance. that would increase drawing speed massively.
Hehe...ok..yeah...well, I guess it is triangles all the way here...or at least quads twisted to paralelograms represented as triangles...this is going to take a LOT of processor power. I better make my part of the code REALLY REALLY good..:D...and we better not make big rooms where you have easily 40-60 wall/floor/roof items...:)
Hmm...so how do you want the points now. Do you only need 4 points for the actual wall, and you devide it up to become two paralellograms or?
PS: I am going to lunch in a a ccouple of minutes...be back in an hour...
- ØØ -
An other thing...is it ok if we represent as room as a 2D array? Something like:
[Removed because of frustration]
and make it look funny....an other problem then will probably be to go from one texture to the other one...guess we have to do some manipulation in phptpshop. So we have a texture that goes from one texture to an other. So if 1 is one wall texture and 3 is an other texture, then we have to have a texture 2 that goes from texture 1 to texture 3 and a texture 4 that goes from texture 3 to texture 1, so we it looks nice if we do this:
12341 comared to just do this:
131
Any thoughts on this?
- ØØ -
not sure what you mean about changing textures, a wall only has one texture doesnt it?
I think we need to make some words here..:)
Wallpart: One sqare (at the moment 64*64pixels).
Wall: Many wallparts after each other so it can be for example a whole wall in a room.
If that wall have to types of textures. Lets say like this house:
http://photos.imageevent.com/kcdownt...ges/Adler1.jpg
Then it will look pretty stupid if it was a totaly straight line on the middle where it suddenly became red on the right side and brown on the left side. Of course we don't have to support more then one texture on a wall, but it is just an idea. Want to hear your oppinion..:)
- ØØ -
And BTW what do you think about the 2D array map idea? Doable? Or do you have an other idea. If you like it, I also guess we need a class to read in a map file too.
- ØØ -
Hmm.
Well, it works but its not exactly what you'd call fast...
The number on the titlebar is the drwaing time in seconds as per your timer class. Doesn't include loading any textures or instantiating the rendering engine. The diagonal line is an atrefact of the stretching and the border of the 2 transparent regions.
That's about 30 frames per second. My machine is a P4 1.8ghz with 256MB ram and 32meg NVidia graphics (not that the GPU is relevant here).
Here are the 2 textures that you can see. When drawn together they form a black UP arrow on a white square 64x64 pixels.
Note:
I think your idea about blending 2 adjacent textures would be nice in theory if we can spare the memory.
The 2d array sounds easy enough to me, although it means we can't have for example an octagonal room, but its fine for starters.
I wonder if i can make this go any faster with unsafe code.
First of all updating the text field of a form is expensive in it self..but it can't have that much to say. This was not really fast. Hmmm....
But since this will be a full screen app, I can't see any reason why you want to clear the back bufffer. Do you? You will after all write all over the buffer the next iteration anyway.
I am not sure how you are dawing in GDI+ anyway. But as long as you are not casting any big objects back and forth from functions, it should go any faster with pointers. As long as you use refernce that is.
BitBlt should be faster, but as you said. We probably don't wan't to go there.
The artifact (or atrifact as you like to call it) was nasty though. Didn't think about that. Both the line and th scewed end of the arrow is not what we won't I guess..:(
- ØØ -
About the map format...hmm..yeah, you are right. But should we implement curved walls in the first iteration anyway? Is it nessesary? SHould we make a road map now, so we know where we are going, and set iterations, so we get some parts done before we start on other parts?
- ØØ -
BTW if you use 0.03 sec on one picture, and we can expect to have 10-20 in the frame at every time, I guess we will end up with 3FPS or something just for the rendering..:D:D:D:D:
Nope :D, the drawing routine is dead fast, I just called it 20 times in a row and it hardly dented the time, although smaller parallelograms do go a bit faster.
Here's my timing code anyway: (yes it does look like MDX code doesn't it :D)
Quote:
private void button1_Click(object sender, System.EventArgs e)
{
double tt;
t.Mark();
//device.BeginScene();
device.Clear(pictureBox1.BackColor); //clear backbuffer
device.DrawTriangles(list);
//device.EndScene();
device.Present(); //copy backbuffer to screen
tt = t.GetElapsedTime();
this.Text = tt.ToString(@"#0.00000000");
}
Hehe..yeah it does....what was the time after 20 wallparts or what ever you did. And BTW...why are you still clearing the backbuffer? Do you really need to do that...to me it looks like waste of time.
- ØØ -
BTW, I just saw that CornedBee has all ready made a balanced BinaryTree and posted it in the CodeBank. I might be able to use that as the foundation to BSP. If I do, I will ask him later on if it is ok. Will save us a lot of time, and it is better then an unblanced tree too.
http://vbforums.com/showthread.php?t=276170
- ØØ -
You've got to clear the buffer because if you don't the old drawings will still be visible..
I just realised I forgot to bring my work home so I can't continue with this part of it until monday :( I can do something else in the meantime though. Probably sleep with a bit of luck.
But helloooooooooo...this is a fullscreen 3D app. Indoor. EVERY frame you will draw over the WHOLE buffer. Not one single pixel will be left un rendered each frame. So how can you say that the old picture will still be there...it will get rendered over...???? :confused:
I bet you didn't bring it with you home on purpose...boooo...I actualy sat half an hour extra at work today to bring my stuff with me home...I did a dist-upgrade on linux the last 20 minutes, and when I was going to go home I wasn't longer able to connect my MP3 player to my machine so I couldn't get my stuff out of that dumb machine..:( Had to upload it to my server in the end...:(
- ØØ -
Sorry I was forgetting about the skybox which would cover everything. Good point.
:confused: No no no...what are you talking about..:D...Look at this picture:
http://www.theirishewe.com/shop7.jpg
If that was what we just drew. And then next frame the user camera has moved 3 cm toward the right side. Then you have to draw the roof again, because it has moved, you have to draw the floor again because it has moved, you have to draw the walls and door again because it has moved, so there is really NOTHING that won't be overwritte because after the 3cm move, everything has changed position...do you see what I mean..:D
- ØØ -
Guys, question:
This is all being done with GDI+? Not directX or OpenGL, am I correct in assuming that?
chem
Yeah I get it.
We need to discuss lighting. I presume (hope) that we are just using ambient light and no localised light sources. Also how should a surface's angle to the camera affect its brightness?
EG. if a surface is facing us then the texture will be as normal, but as it turns away from the camera, does it get lighter or darker? (or does it approach an arbitrary shade of gray?).
I'll have to use ColorMatrices to draw these re-shaded triangles, but if the angle is large then we can just use a filled gray polygon instead, much faster.
It would be useful to make this quite a dark and atmospheric demo. All kinds of optimisations are availabe to us then.
Correctamundo! :D we are pushing the boundaries of the GDI+ to see how much it can do. It's going to be interesting whatever happens :DQuote:
Originally Posted by chemicalNova
Quote:
Originally Posted by wossname
I hope you can amaze me with some speed soon...;)
Well, hard to me to discuss your lightning since I have no idea how you use ColorMatrices and so on. But one thing is for sure. If you are planning on only using Ambient lightning, then it is easy. Ambient lightning is the ONLY lightning made in DX and OGL that doesn't actualy exist in the real world..:D...it is a light that lit every surface equaly much, the only difference in result is the materical color for the lit surface. So that means that the degree between camera and surface doesn't have anything to say.
Of course if you really want we can add other lightning effects as we go. But I wouldn't prioritize that if I where you..:) So what is happening with our road map? Something like this:
Iteration 1:
- Read in the walls from a file (what file format?)
- Sort them according to a starting position.
- Straight forward draw 20 walls. (no culling, no Space Partitioning, no ....)
Iteration 2:
- Make camera, so we can start to move.
- Get input, so camera can move.
- Draw more realistic walls (wØØsys Colormatrices and lightning questions and hoohooo).
Have I forgotten something importent? Please add it while I drink the rest of this beer..:)
- ØØ -
My god guys. I wouldn't mind having a look at it when you's are done (or whenever you feel like showing it to people). I've had a little bit of experience with C#, and getting back into .NET would no doubt prove alot easier looking at this :)
I've always wanted to do something like this in VB6/ASM. I just can't get my head around the 3D math :blush:
I would say BSP would be the way to go NoteMe. I posted a link to a very good article about BSP Trees (I think to Electroman, or maybe it was you :p) a short while back. Worth the read, if you haven't already :)
chem
It was probably me or Keda posting it..:)...maybe in our big Space Partitioning thread..:)...if it wasn't I would be glad if you showed it to me. Since I can't remember any other then that one.
This is going to take some time though. I am leaving on a vecation for 10 days in a week. And then an other vecation for 9 days or so the week after that. At least if I am lucky. But the work has started, so we just have to see where it ends up...:)
- ØØ -
Ah, it was for Halsafar. It was here - the post.
He gave me reps, I remember :p
The link is in the post :)
chem
The article doesn't go really deep into the field. At least not as deep as the links I all ready have. But thanks anyway. Not able to rate you today anyway..must have done it lately I guess...
- ØØ -
Ah, well, if you have some better ones, I wouldn't mind taking a look. I used to use a few different engines, and that sort of information intruged me :)
Yes, you rated me the other day, helping in the Games Section, but ta anyway :)
chem
I am not sitting on my machine now, so I can't post them today. But will do it tomorrow when I am at work.
Thanks again.
- ØØ -
I'll work on the automatic triangular texture code (takes a normal picture and cuts it in half diagonally, filling the other halves with transparent pixels).Quote:
Originally Posted by NoteMe
Quote:
Originally Posted by wossname
Quote:
Iteration 1:
- Read in the walls from a file (what file format?) any image format for the textures size limited to exactly 64x64 pixels at the moment.
Since you started to talk about picture format, I guess I have to add what I really ment. Map file format....;)
- Sort them according to a starting position.
- Straight forward draw 20 walls. (no culling, no Space Partitioning, no Occlusion..finaly..I remembered the word..:))
Iteration 2:
- Make camera, so we can start to move. Just an XYZ position and a couple of vectors? Havn't you learned anything from your MDX days..:)..We need, position vector, lookat vector, and up vecotor, and of course functions to work on these vectors.
- Get input, so camera can move. There is a joystick class in Sandpaper.dll knew it would come in useful ONE day. Not that I have a joystick though, so guess keyboard, (mouse?) has to be used too.
- Draw more realistic walls (wØØsys Colormatrices and lightning questions and hoohooo). This is going to be hard to do. We'll see. We should keep textures simple.Ai ai sir...you deside that one..:)
Nice and dandy isn't it?...:)
- ØØ -
Since the map files will be read into the 3d engine directly I think that is entirely up to you, use whatever format suits your code :), I am concerned only with graphics at the moment. I have started work on distance darkening (DD), and it works great, depending upon how fast I can generate color matrices we can get some good effects here. If its too slow to generate them on the fly then I'll have to have a buffer of colormatrices and select an appropriate one.
I think I can save some time by optimising the surfaces I'm are drawing to. Use a few SetStyles() to drop some default options. May increase rendering speed a bit.
I have tried fiddling with Bitmap.LockBits(WriteOnly) but it seems to prevent drawing rather than accelerate it. MSDN is no help on this subject.
I'll be back to coding it the main graphics engine again tomorow, I'll take my DD code to work and incorporate it into the engine.
I found this to be a very usefull article.Quote:
Originally Posted by wossname
Quote:
Originally Posted by grilkip
Hmm...if that is wraps around the GetPixel and SetPixel API, then they are bound to be REALLY slow. IF they are wraps around some of the DIB interfaces or something, then it might be interesting. wØØsy?
Quote:
Originally Posted by wossname
But if I do it the way I stated in one of my first posts here, then you won't get your round corners...and BTW I just remembered that I have no idea how to read or write to a file in C#..:D...I think I need to start there now..:)
- ØØ -
OK, got framerate up to 37fps at the moment. Might slow down alot once the game loop is running. Might be worth putting 3D math in a separate thread??, then boost the graphics thread to a higher priority level. Might get a few extra frames.
Currently tinkering with SetStyle() property of form object.
I'm buffering everything that is bufferable: textures, rectangles, matrices and ImageAttrib objects. Happily this code I have for DD doesn't seem to slow things down at all!!
Hmm....not sure not sure...an extra thread gives overhead as long as you don't have a multithreaded CPU, and we need to have the input commands and the math synced, if not, it will be really jerky. No need to render 100FPS if the input and the movement is only updated 10FPS. If you see what I mean...Quote:
Originally Posted by wossname
Set it to double buffering..:)Quote:
Originally Posted by wossname
Quote:
Originally Posted by wossname
Send it too me..I want to test it..:)
- ØØ -
Not yet, its nowhere near ready to let you loose on it, you'll only break it. :D
Woo000o0t, I had been testing using 32bppRGB format images and was getting crap times. Changed it to 24bppRGB and it went from 37fps to 57fps!!!
Then I changed it to 32bppPARGB (premultiplied Alpha + RGB) and i'm now getting 130fps for a single wall section!! 130 walls sections per second isn't bad at this stage and I'm trying to work out how to turn off Antialiasing for stretched images.
We'll be able to have colored ambient light too since this matrix thing carries no speed penalty. Neat eh?
Also found a 'fix' to the seams on the wall panels, I altered the triangles to overlap very slightly so there is now no gap. However, the warping of the patterns still occurs but there is a way around it. You know the diagonal seam? If that seam passes through a vertical line on the pattern then you can't tell that its warped... lets draw textures where only verticals are allowed to cross the diagonal seam.
Its a bit of a bodge but its nothing out of the ordinary for game coders eh? :D
Earlier on today I spent half an our shouting at my machine because it kept drawing all my images really dark, then I suddenly realised that my DD code was working already! I'm too good.
130FPS...now we are talking...:)...lets just wait two sec so I can get it down to 10FPS again..:)
BTW just as a hint. Rendering in real time is defined as 10FPS at 640*480pixels. So we are way in front of our schedual. But I hope I can manke my part of this too though..:) Still havn't even had the time to look at the read in an out stuff. Will do that right now..:)
- ØØ -
About the textures. I think that will be "ok"..not more or not less. Brick walls and doors and what else contains only horizontal and vertical lines after all. We just have to watch out for funky wall paper with spots/dots/and burbery on them..:)
- ØØ -
You reading in normal text files?
Thats dead easy. You'll get that sussed in no time.
I am pretty amaced about my book not mentioning how to do it at all..:)...still havn't had the time to check goole...will do it in a few minutes..:)
Just to clarify, horizontals will be a problem but only if they cross the seam.Quote:
Originally Posted by NoteMe
Ohhh...I guess there isn't many textures less then..:D..unless we use something like:
http://safariexamples.informit.com/0...%20texture.jpg
or
http://www.fabricattic.com/counterto...e%20orange.jpg
:(...I really wish we could use something like:
http://www.kestan.com/travel/dc/smit...%20texture.jpg
or
http://www.free-pictures-photos.com/...exture-012.jpg
But I guess we have to abbondon doors and bricks and so on...
- ØØ -
BTW since I am writing this map loader now...do you use any global namespace for this project, or just wrap stuff up in classes and goodby...?
- ØØ -
BTW, where do you usualy put the brackets in C#? After the line, or on a blank new line? I usualy add them to the same line. Guess it is an old VB habbit. LIke this:
Code:using System;
class DoomSharp{
public static void Main(){
Console.WriteLine("DoomSharp Will make you young...");
Console.WriteLine("DoomSharp Will make you pretty...");
Console.WriteLine("DoomSharp Will make you sexy...");
Console.WriteLine("DoomSharp Will make you smart...");
Console.WriteLine("DoomSharp Will make you happy.........");
}
}
OK...for now I will just define a WallPart as this. This is a quad, I guess you are the man that have to translate this into two triangles? Or should it be done in this class too? And add the "fix" for the stipled line between the two triangles?
[Removed because of frustration]
That quad is fine, for now. I have been rendering from an array of triangles but I can adapt your wallparts to that no problem. Can you find a way to also pass me a value saying how far away this wallpart is from the camera? Maybe a float value as a fraction of the total depth (if our far plane is 1000 metres away and the wall is 243 metres away give me 0.243). I suppose this could be an average of the distances to each corner of the wall. Then I can use my DD :D
I always put the opening brace { on the next line, mainly because thats how intelisense does it. I prefer it this way but I don't really mind.
I haven't used any namespaces yet as I am trying to keep everything loose so I can change it later.
This is my first screeny with perspective, a floor and a wall, the vanishing point is roughly centered on the screen. Vertical lines are no problem as you see here, both these textures have verticals running through them and show very little distortion.
The fix is done, but you can sometimes still see some tiny atrifacts (:D)Quote:
Originally Posted by NoteMe
How are we going to use that wallpart if all its members are private? :D
Woohooo..that looks awsome..:D.....great job..:)...I was actualy sitting thinking about two problems now.
1. How to tell you and me and the WallPart class what texture should be assosiated with it. I guess the name of the texture and the "id" tag for it will be read from the Map file. So I guess that is my problem, but then I have to have a way to assosiate it with the WallParts, and then store the textures somewhere, and then tell you what texture goes to what wallpart. Have you thought about this at all? How are you storing the textures now? Any structure at all, or just loading and drawing at the moment?
2. What units to use. I guess this is entirly up to me. But you can at least help me out by saying aproximatly how many meters one of those wall parts are. BTW what you drew now, is that ONE wall part and ONE floor part, or two of each?
- ØØ -
Quote:
Originally Posted by wossname
You will only use the render function..;)...I will sort the wall parts, occlude those that are not going to be rendered, then you will spew through the rest of the array, or list, or tree, and render them as fast as you can in the order they are listed..:)
- ØØ -
Ohhh...BTW...great idea....what about adding billboards in iteration 2 or 3..::)...