BSP Renderers

  • Creator
    Topic
  • #5763

    OneMadGypsy
    Participant

    I built some BSP renderers in a couple of languages. The flash one runs amazingly, the javascript one, not so much. Both are junk right now though. I built the Javascript one first and then I decided to do it all in Haxe and ended up with another Javascript one (because you can transpile HaXe to javascript). Both of my Javascript versions suck … cause Javascript is a garbage language, with garbage performance. The identical port runs awesome in flash, c++ and neko.

    I’m not trying to make a Quake engine, or even remake my original WorldSpawn engine. I have other ideas. Neither of these ports were pulled from my WorldSpawn engine, either. There never was a working HaXe WorldSpawn and there certainly wasn’t a Javascript one. I wrote the first Javascript one from scratch pulling from the BSP specs. I then based the HaXe version on the Javascript one but, then changed a lot of stuff.

    I can’t batch render the entire map in javascript. It’s just not going to work with any reliable performance or reasonable load times. I’m going to have to use the PVS but, I can probably at least fatten the PVS.

    http://www.nextgenquake.com/groups/onemadgroup/forum/
Viewing 15 replies - 1 through 15 (of 56 total)
  • Author
    Replies
  • #6129

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    I can halfway help you. The below download has 6 files but only 4 are truly important

    BSP29.as – the loops to parse bsp29 lumps
    PSB2.as – extends BSP29 and overrides only the lumps that changed
    BSP2.as – extends PSB2 and overrides only the lumps that have changed
    BSPFILE.as – map property constants ~ I would actually ignore this file cause 2psb and bsp2 change these constants. I may have also made up crazy constants for some vars or maybe even nulled them. This file is not reliable.
    BSP.as – around line 316 is buildFace() which has the exact formula you need to concoct vertex and uv data
    Palette.as – the quake palette written out as an array

    That gives you a “diff” of all 3 file formats and all the math to get the vertices and uvs. Also, the functions are complete in BSP to parse facedata to groups by texture. You will exactly need that if you want to convert to .obj. However, one issue with BSP2 is extended limits that blow out your average vertex buffer. You need to group facedata by textures but you need to make sure if your buffer get’s too big (65536 I think … I’m very close) you create a new buffer. Since you won’t truly be dealing with any buffers, I obviously mean you would start a new submesh in the obj file. If you wish you can port my scripts to some other language and create your own bspx2obj parser.

    Once you get all the bsp data parsed out to arrays converting it to an .obj should be pretty trivial … mostly a bunch of stuff like this

    var obj_string:String = "o "+numberOfObjects;
    for (i = 0; i < vertices.length/3; ++i)
    {	obj_string += "v " + vertices + " " + vertices[++i] + " " + vertices[++i];
    }
    var t:int = -1;
    for (i = 0; i < vertices.length/3; ++i)
    {	obj_string += "vt " + uvs[++t] + " " + uvs[++t];
    }
    t = -1;
    for (i = 0; i < faces.length; ++i)
    {	obj_string += "f " + indices[++t] + " " + indices[++t] + " " + indices[++t] + " " + indices[(t-=2)];
    	t+=3;
    }
    
    //pbbt that's practically your parser.
    //something is probably wrong but, that's definitely pretty close to the overall meat and potatoes
    

    Also, you may want to see if FTE can do this for you. I have seen various things written on func regarding FTE that lead me to believe this could be possible. I never saw anything about exactly X to obj conversion but I've seen other stuff that was similar.

    parser files
    .obj file specs

    #6128

    Monty Burns
    Moderator
    • topics: 5
    • replies: 47

    Darn it! I had a feeling that might be the case. Oddly enough I’m not going to use any Quake lighting or Vis information as it is destined for another engine anyway. I’m looking for something that will just convert the meshes so that I can alter them in Blender rather than have to build the entire maps from scratch. Don’t get me wrong Noesis does a great job it just hasn’t been updated to account for newer map formats which means I can’t get my hands on all that lovely dark Arcane Dimensions goodness.  Oh well that’s life I guess.

    Thanks for taking the time to respond. Now back to your extremely cool utility…. 🙂 🙂

    Kind regards

    Monty

    =====================
    Mr. Burns
    My little OOT project thing - Demo download
    top | reply

    #6127

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    I’ve never written a tool for bsp to obj conversion. It is unlikely you will find any programs that will convert maps which use 2psb or bsp2 format. I don’t suppose it would be that hard to write a converter but, you lose a lot of information (light and vis).

    #6126

    Monty Burns
    Moderator
    • topics: 5
    • replies: 47

    Hi MG,

    I don’t suppose that while you have been working your magic on these Quake maps that you developed or came across a utility that allows you to convert Quake maps or all sorts to more useable formats (eg fbx, obj, blend)?  If currently use something called Noesis (see https://richwhitehouse.com/index.php?content=inc_projects.php for more details) following a helpful recommendation from Baker but it doesn’t seem to handle newer maps (like the main Arcane Dimensions Hub) . If you or anyone else reading this spot anything that can do this I would be grateful if you would be kind enough to let me know. Many thanks

    Kind regards

    Monty

    =====================
    Mr. Burns
    My little OOT project thing - Demo download
    top | reply

    #5943

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    It’s going to be a minute before I am back on the visual end of this. I invented a language about 11 months ago but, I invented it in AS3. I need to port it over to HaXe and it’s not as simple as just doing a find/replace all on all the syntactical differences. It could be that easy but, I want to take advantage of abstracts, enums and typedefs. In a way it’s like I have to start completely over but, I have a concept to follow. This language is going to serve as the language for my engine. Numerous things need to be done to the engine, though because, the language I wrote was already supporting a lot of “API” types and already had the power to do a lot of things like:

    1) Completely restyle the system chrome and apply 2D AND 3D contexts in layers to it
    2) Build UI elements (like checkbox, radio buttons, textfields, sliders, etc…)
    3) Manage events (currently only Mouse and Keyboard)

    There are more things but, I’m not trying to write a feature list. I just wanted to give an idea of how far I had gotten on this. Also, a lot of those possibilities were available because they were being bounced off of classes in the client. Those classes do not exist in my current client. I’ve already rewritten some of it and I have a decent structure going but, I know that structure is going to change the longer the full scope stews in my brain. I intend to rebuild the base client, get the language working and then start adding everything from this thread back in but more from a possibility standpoint, as opposed to an “IS” standpoint. If I am going to go to all the trouble to build a language and a player I want it to serve as something that can be used for any idea, as opposed to being strapped solely to a quake concept engine.

    I will probably start a thread in my profile group forum to track the progress of this project once I get to a point where I have something solid to build on. Actually, I will probably just start putting all my projects and work in my profile group forum. It’s a completely public group. The only real difference is my work won’t be spread all over the main forum. There will come a day where everyone will have to do this and there won’t be a main forum … or barely one.

    #5900

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    Earlier I noticed this issue. I noticed a similar issue with archways that use an archway texture a while back. This really baffled me … “How could all of the textures in the world be correct, except buttons? How could OTHER identical buttons be correct but, not these for some reason?”

    I went over the entire BSP parser and even back to the specs to see if there was maybe some value I had forgotten to consider. There was nothing. Then I thought about something and I had an idea…

    I redraw non power of 2 images as soon as they are made. This happens before I calculate texmins, extents, etc.. (obviously). However, the calculations require image width and height. In my case those dimensions were the new power of 2 dimensions. I made a little addition to one of my typedefs to store original dimensions and fed that into the calculations.

    The only real point of this post is for any novice trying to make a BSP parser. Whereas you may think powering the images right off the bat is a great idea (it’s not a bad one) and you may think that the new image width|height would be the proper numbers to use for calculating the UVs. It is not. You need the old dimensions.

    #5895

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    I’ve been messing with “quakeshop” a lot with a lot of different maps and trying to find combinations of filters that are pretty universal. With very little work I can bring any quake map to life with rich colors. Below is an example.

    this is pretty close to how a stock quake engine would render this map

    this is how my engine would render the exact same spot with very few tweaks in the utility panel

    Quake textures tend to be dark and muddy. The idea I am implementing is to allow the ability to change the textures (possibly dramatically) without having to make new ones or write custom shaders. Simple post-filters can be used all the way back at the point where the bsp is being parsed for it’s textures (ie. long before the image even makes it to the GPU).

    #5885

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    @This is one of the most interesting Quake topics I have read in a looooong time.

    Thank you.

    @ some users would probably appreciate just a few basic button presets (e.g. ice, snow, Tron, desert, dusk, midnight, etc) to help them get the idea of how it works quickly

    Yeah, I agree 100%. Especially for the convolution filter since most things are algorithms that are more-or-less set in stone like: sharpen, gaussian blur, etc.

    @ In any event, that’s really great job, well done sir

    Thank you, again. There will be more things. I have tons of ideas that I have never seen in a Quake engine.


    I got tripped up for hours yesterday. My PNG loader from older projects doesn’t work anymore and I couldn’t for the life of me figure out why. After like 3 hours of hunting through code, auditing bytes, running numerous tests and still not coming to any conclusion, I created an entirely different method. It’s good and bad. It works async so that’s good but, it is not very fast. My old method was to simply parse a PNG exactly how you would expect to do so if you wrote a PNG parser. My new method utilizes the flash Loader class (errr… openfl Loader class – same diff). If an image is not zipped it gets sent down a new abstract of my generic file class that I made, which is specifically for images. That class simply uses Loader instead of URLLoader so I can let openfl do the png|jpg parsing. If the image is zipped it first gets inflated and then I rape the Loader class by tricking it into thinking it loaded the inflated bytes. It works perfect but, it is kind of slow.

    I have an idea on how to make it faster. Since concocting bitmap data is fastest when doing it from a Vector and my engine will be set up to package each map and all of it’s config/extra data in a zip, I am going to create a condition where images get converted to a csv of UInts with the extension .vec. That way when a package is loaded there won’t be any png|jpg parsing. I will be able to make images by simply passing the vec to BitmapData and it will be really fast. The fastest possible way, to be specific.

    I also created the condition to only allow the alpha channel on images that need them (vines, fences, etc). On Sock’s start map that ends up being a 10mb ram savings, which is 1/9th of what the overall cost was before.

    I have some ideas that I will be working on today. All of them create a situation where my engine could be used as a utility to recreate BSPs that could be used on any engine.

    #5883

    Monty Burns
    Moderator
    • topics: 5
    • replies: 47

    Thanks for doing this MG,

    This is one of the most interesting Quake topics I have read in a looooong time. I’m with you on the cofigurability aspect of this as Quake Players like to tweak their config to get it just how they like it, and I imagine mappers will probably be of a similar view but, and its just my very humble opionion,  I can’t help thinking that perhaps some users would probably appreciate just a few basic button presets (e.g. ice, snow, Tron, desert, dusk, midnight, etc) to help them get the idea of how it works quickly, even if they then tweak it further themselves. In any event, that’s really great job, well done sir 🙂

    Kind regards

    Burnsy 🙂

    =====================
    Mr. Burns
    My little OOT project thing - Demo download
    top | reply

    #5882

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347



    I got skyboxes hooked up and then I messed around for a while with trying to make the map look like it belonged in the chosen skybox. It could definitely use some work.

    Here’s a shot of the same map in a stock quake engine. I’m only posting this as a comparison to how much was changed to try to fit the map in the skybox.

    #5881

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    LOL, my alphamask wasn’t doing anything at all. I accidentally made another connection within the alphamask possibilities which finally turned on the alphaBlending for the transparent pixels. Like I said in my last video, the pixels around the vines are 0x00000000 … that is not palette[255]. So, all the alphamasking in the world wasn’t doing shit. What was happening is, after I spun the alphamask I was setting alphaBlending to true as well, and that finally told all those pixels to stop being black. I realized I was only telling water/clip/trigger/skip to have some form of alpha and never told images that only had partial transparency to do anything. (oops)

    Also, stripping the alpha channels from all images cut the ram down for that start map by 10mb BUT then vines came back to having the black pixels. That’s when I realized that vines are using the alpha channel, and did more digging to figure out what the hell is going on. I turned the alpha channel back on for textures but left them off for lightmaps. I could come up with conditions that only use the alpha channel for images that need them, and I might but, I’m not all that concerned with a few mb’s right now.

    #5880

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    No textures are achieving alpha due to the actual alpha channel. I am going to run a test. I am going to strip the entire palette down to 24bit colors and turn alpha off for all instances of BitmapData. This will get rid of quite a bit of useless bytes. It will definitely take a chunk out of the ram and might even make things a little faster.

    I’ll be back with some results (if they are worth talking about) in a few minutes.

    #5879

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    I fixed vines. I did exactly what I said I would in my last video. I used the vines texture to create an alphamask of itself and then simply applied the alphamask to the material. I have it set to where any texture that uses palette[255] triggers the alphamask so, the issue should just be fixed period.

    the code to create the alphmask is nothing. Really, it took all of about 2 minutes to solve this problem.

    public static function alphamask(bmd:BitmapData):BitmapData
    {
    	var vector:Vector<UInt> = bmd.getVector(bmd.rect);
    	for (n in 0...vector.length)
    	{
    		if (vector[n] == 0xFF9f5b53) vector[n] = 0xFF000000;
    		else vector[n] = 0xFFFFFFFF;
    	}
    	bmd.setVector(bmd.rect, vector);
    	return bmd;
    }

    However, this way isn’t the best way. I am comparing one exact color. I should be comparing to Palette[255] … as maybe that will not always be 0xFF9f5b53. Easy fix.

    #5878

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347
    #5877

    OneMadGypsy
    Participant
    • topics: 47
    • replies: 347

    I figured out the “Tron” settings

    both are clickable for fullsize view





Viewing 15 replies - 1 through 15 (of 56 total)

You must be logged in to reply to this topic.