Announcement

Collapse
No announcement yet.

WorldSpawn official WIP thread

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #61
    I've been working on my math expression parser. Consider this:

    You have to get all the operators without grabbing unary operators ex: 1 * -2. In this example I need the * but not the -. Now there are a lot of stupid ways to do this and they all involve attempting to pick and choose via a loop. My eval() is regexp driven so, with some genius I don't have to write loops for this stuff.

    first let's consider a regex that knows what a unary operator is or more specifically knows what ISNT a unary.
    /(?<![-+/*]|[0-9.]E)(?<=[0-9a-z]|\))[-+/*]/g

    I posted some regex on some other thread on here and that example was simple stuff. This is a bit more complicated.


    Let's skip to the end and come back. The below is what we are actually trying to find. Any of these characters in the brackets.
    [-+/*]

    This means "if I look behind the found character and it IS what is in this group". For this group I am looking for numbers, letters or a close parenthesis
    (?<= )

    This means "if I look behind the found character and it's NOT what is in this group". In this group I am looking for operators and handling E possibilities
    (?<! )

    So if we read my regex from end to beginning it says
    find [*/+-] that IS preceded by [0-9a-z] or ) and is NOT preceded by [*/+-]

    The E thing is in there too but I don't feel like explaining it. What I explained is good enough.

    Now, we have a regex that when used with string.split() will create an array of everything to the sides of the operator
    ex (1 * -2) becomes [1,-2]

    But how do we get the operators back? We still need them to eventually start doing the math. THis is the genius part

    Code:
    	//create an array of evrything except actual operators
    	res_stack = (child.expr).split(re.infix);
    	
    	//reformat the res_stack values into a regex
    	stack_str = res_stack.join("|").replace(/\(/g, "\\(");
    	stack_str = stack_str.replace(/\)/g, "\\)");
    	stack_str = stack_str.replace(/\|E/g, "|(?<=[-+/*])E");
    	
    	//create an array of only actual operators
    	op_stack  = (child.expr).split(new RegExp(stack_str, "g"));
    I simply rejoin the array with | (or) symbols and reformat it a little bit with more regex. What I end up with is the exact opposite regex of the one I used to remove the operators.

    blink, blink, done...no loops.

    I ran a test and so far my evaluator runs about 2200 times a second. It's almost entirely regex.
    Last edited by MadGypsy; 10-17-2016, 10:33 PM.
    http://www.nextgenquake.com

    Comment


    • #62
      Heh, I reread this
      find [*/+-] that IS preceded by [0-9a-z] or ) and is NOT preceded by [*/+-]

      and when put in those terms, one of those is unnecessary. I got rid of the IS and remembered to add the case-insensitive flag (for the E)
      /(?<![-+/*]|[0-9.]E)[-+/*]/gi
      http://www.nextgenquake.com

      Comment


      • #63
        Game On!


        My processes per second dropped a 1/3rd but I only need about 60fps... I'm doing about 800fps. I'm way good on what I need this for. Of course it also depends how long the expression is. I have looked at a fair amount of "particle math" (regarding my API) and the expressions are about half as long as my example one.


        Here is an actual expression used for my fireball rocket. As you can see the expression is about 1/3 the size of the above expression and the time is a third as well.


        I need to make some exceptions for min/max math functions but, the fork is hovering over this steak cause it's about done. I've parsed a lot of things in this world, never did I think I would end up parsing math expressions. It was pretty tough. Not a million hornets tough but, there definitely was some stinging. But hey, now I know math.

        note: If it's not obvious...the time that the script took to run is printed in the console (big light grey display) at the bottom of my ui. Anything I trace() ends up there.
        Last edited by MadGypsy; 10-18-2016, 03:53 AM.
        http://www.nextgenquake.com

        Comment


        • #64
          I'm flying on this shit. Check it out... fully customizable and functional particle/light script. There are definitely some things about this that need to be made a little better but...that fireball looks just like all my other fireballs, the only difference being that instead of it being hardcoded it was created on the fly off of my JSON. My Expression class is in play here too (this is the whole reason I wrote it);


          things I need to do

          1) I am cheating on those node arrays and currently have my script specifically looking for what I have there (so I can hurry up and test). I just need to make it more dynamic.
          2) Currently my particle engine only allows you to use a plane. I just need to add in cube/sphere/model

          ...that might be it. Maybe there is a 3 or 4 but I seriously can't think of one right now so, it must not be that big.

          edit: I know a 3. I should make it to where when the JSON text script is finalized it can be exported as a byteObject. This way, when it gets loaded it is just ready and I shave off the internal JSON parsing. Also the file would be a lot smaller as a byteObject....yep gonna do that.

          currently my vision for today is this:

          1) finish the particle engine (ie #1 & #2 above).
          2) Make an uber simple map with a custom entity in the center of the room (func_particles or summin)
          3) write a particle script for something stationary
          4) create kb commands to reload the json particle script

          What this will end up being is basically a particle editor of sorts, where I can make changes to the script, quick reload (just the particles), and see my results. Currently you have to reload the entire engine to see changes. I want to make it much easier. I might even smack a textfield right on top of the engine with a toggle so I don't even have to open an external editor or switch between apps.
          Last edited by MadGypsy; 10-18-2016, 12:09 PM.
          http://www.nextgenquake.com

          Comment


          • #65


            The JSON now fully controls everything about the particles and accompanying light, if any. There are a few Particle types that I haven't included yet but, that's pretty much a bunch of copy/paste/adjust of any other particle type that I have included.

            I took the time to default all of this stuff. That's why there are empty objects ({}) in my json. In those cases the defaults are what I need so, I just need to make that feature exist (ie {}) my script will default whatever is missing.
            http://www.nextgenquake.com

            Comment


            • #66


              I made another particle weapon so I could get changing weapons out the way. This effect is a derivative of the fireball but, a couple of it's values make it entirely different than the fireball. I know it's not awesome. I needed a second weapon. I call this one "laser" (note: the fireball is actually called "rocket"). I wanted to make a laser and this is sort of what I pictured in my mind. Having the trailing squares is right but the hot white in the front is not what I want. This effect moves differently than the fireball. It's appears to grow away from you and then leave you and then catch up to itself (some). What's really happening is it is leaving itself behind and those parts take a little time to fade out. The laser also completely dies about the same time its trail is disappearing so, it looks a little like it's sucking it's remains up as it dies.
              Last edited by MadGypsy; 10-18-2016, 06:12 PM.
              http://www.nextgenquake.com

              Comment


              • #67
                I played with the world light a bunch and added one point light that is used to buck ambiance even more. These lights don't cast shadows. It's a little orange but I think my results are much better.



                oh wait, here we go
                Last edited by MadGypsy; 10-18-2016, 10:33 PM.
                http://www.nextgenquake.com

                Comment


                • #68
                  The world lighting looks fantastic! Will this be a field mappers can adjust (intensity and RGB)?
                  'Replacement Player Models' Project

                  Comment


                  • #69
                    @dutch

                    yes and no.

                    The yes part is that you can definitely set this per map. The no part is the way you described it, although it is sort of right. There are definitely colors involved.

                    Code:
                    {
                    	"skybox":"moonhigh",
                    	"fog":[1000, 2000, "0x55555F"],
                    	"weapons":["energyball","laser","rocket"],
                    	"worldlight":
                    	{
                    		"castsShadows":false,
                    		"color":"0xFFEFDF",	
                    		"ambientColor":"0xFFDDCC",	
                    		"diffuse":1,	
                    		"ambient":1,	
                    		"specular":0.15	
                    	},
                    	"ambiance":{
                    		"ambientColor":"0xFFDDCC",
                    		"ambient":0.6,
                    		"diffuse":1
                    	}
                    }
                    you may notice that both my worldlight and ambiance have ambient fields set. This is because the first ambient&diffuse at 1 just give you the dark look that my map would have with no light. It's the specular in worldlight that is bucking the brightness up a bit but, this is a fickle setting because, too much and it just starts greying all the textures out. The ambient in the ambiance obkect is what really turns the lights on. My other pictures were at 1. I dropped it down to 0.6 and compared it to FTE. My results are damn near identical.

                    even though this has nothing to do with your question, it is linked to the same file. The weapons array tells the engine which bullet particle effects to load. Currently, you get every gun as soon as the engine starts. When I get to pick-ups I'll worry about an inventory system and probably end up doing the current "weapon pool" a different way.

                    @The world lighting looks fantastic!

                    Thank you! The good thing is, due to how I have it externalized, it doesn't matter if I get it fantastic...
                    Last edited by MadGypsy; 10-19-2016, 02:09 AM.
                    http://www.nextgenquake.com

                    Comment


                    • #70
                      I realized due to my most recent posts here that people may think that my RTLs are casting all those shadows. That is NOT true. Those shadows are straight out of a lit file. All my light does is brighten and (possibly) re-contrast the world. There is not a single shadow cast by world lights. As a matter of fact not one single texture has been told to cast shadows so, I could add a zillion lights and there would still not be any shadows because of them. This is really JUST light and I'm a hair annoyed that it is necessary cause I would like to use those lights for other things. There is one spot where my engine is seriously crippled and that is light. I can literally and actually render HALF A MILLION particles with nary a burp in FPS. I have completely loaded maps that have about 75,000 polys and FPS stayed pretty damn solid. Start adding light....[X] My world lights don't seem to effect performance due to it only being 2 lights add about 2 more lights and it's still decent. Anything past that and performance is completely gone. I can change that a little by implementing a pvs and I've concocted ways to use the hell out of those 2 extra lights but all in all the flash version of my engine is NEVER going to cut it with RTLs. Light in my engine should be viewed more as a way to add drama to something that simply cannot do without it. For instance, maybe you are on a spaceship or something and there is this huge glowing reactor core or something...you could totally get away with adding ONE light in that spot but, you better not need another one in that map.

                      @1/2 million particles

                      Apparently some genius created a particle system for flash and Away3D adopted it. There are numerous posts raving about how good the particle system is (even before it was in Away3D). I have no idea what kind of voodoo is going on in the background but, the particle system at my disposal is bad-ass. You get one burp when you initiate the particle effect and then it runs smooth as ice. When I say this I mean, ex the first bullet you fire may burp but not a single one after that will. I am actually looking into how to make it burp before you need it. Getting rid of the burp entirely would be nice but, I don't think that's possible.
                      Last edited by MadGypsy; 10-19-2016, 10:15 PM.
                      http://www.nextgenquake.com

                      Comment


                      • #71
                        Well RTlights ARE a performance hog, and as far as I understand with my very limited knowledge, Flash was never made for this kind of fancy stuff.

                        @burp Could you make it happen during map load so that it doesn't impact gameplay?
                        ♪ I'm skiiiiiiinnin' in the pain, just skiiiiiiinnin' in the pain ♪
                        ♪ What a glorious feelin' I'm haaaaaaappy again ♪

                        Comment


                        • #72
                          @burp - I'm attempting to do exactly that

                          @flash wasn't meant for this
                          Well then neither was html5 cause flash outperforms html5. Javascript is never going to be faster than AS3...not as long as it's JIT compiled anyway. I know what you are saying though. However, Flash player since 10 is actually exactly designed for this stuff, hence the entire Stage3D package that was added. The only reason Flash is targeting such a low OpenGL is in order to be compatible with as many devices as possible. There is nothing stopping Adobe from going the other way and dropping the whole kitchen sink in flash. I think people are so accustomed to flash as a browser plug-in that they don't realize it's not really a "web" technology. It's a virtual machine and it out performs NEKO... in my experience, anyway. My neko engine port ran at 80% of what the exact same script produced in Flash. Actually the ONLY port that I could get to outperform flash was c++ and not by some astronomical amount.

                          I think adobe messed up by focusing so hard on flash as a browser plug-in. They should have started with AIR, gained credibility as a viable VM and then expanded into browsers. All this "flash is dead" talk is because people think flash only works in a browser and they think websites don't use it anymore. This has actually never been true. Way back in flash 5 (like 15 years ago) you could make stand-alone applications and even target the system a bit with fscommands.

                          @think websites don't use it anymore
                          At least 10 or more times a day my browser asks me if I want to allow flash to run. I was on the fox news website today and a bunch of stuff on their page was flash. I viewed the source for their page and it was HTML5. Funny that, HTML5 was supposedly going to obsolete flash so why would they have an html5 page but use flash anyway? Even though the flash player for youTube is no longer supported, it is exactly what is used when you embed a video. I'm positive, cause some of those "10 times a day" are me allowing flash to run youTube videos embedded on this site.
                          Last edited by MadGypsy; 10-20-2016, 12:38 AM.
                          http://www.nextgenquake.com

                          Comment


                          • #73
                            What strikes me is the extremely low number of RTlights needed in order to clog Flash. In Darkplaces, I get significant* performance drops only when RTlights amount to hundreds.

                            *: by "significant", I mean below 30fps on a not-up-to-date rig. I have a Core2Duo E6750 with 2Gb DDR2 and a GeForce GTX 650.
                            Last edited by Mugwump; 10-20-2016, 12:44 AM.
                            ♪ I'm skiiiiiiinnin' in the pain, just skiiiiiiinnin' in the pain ♪
                            ♪ What a glorious feelin' I'm haaaaaaappy again ♪

                            Comment


                            • #74
                              Yeah that is a problem. Flash is never gonna beat a native application in performance. I'm not trying to say flash is as good as everything else, cause it definitely isn't.
                              http://www.nextgenquake.com

                              Comment


                              • #75
                                I have a plan though. By combining excellent particle effects with colored and animated lightmaps I should be able to still create some very rich environments that perform well. Of course some things will suffer - like models wont receive shadows from the world, but hey, this is just my first engine. No sooner will I finish this one then I intend to go back to Haxe with no APIs (not even OpenFl) and build a real engine. This is the "figure it out" engine. My next engine will attempt to compete with FTE and DP. And it should go a hell of a lot faster due to me having far less, if any questions.

                                Don't misunderstand me though. This may be the "figure it out" engine but I intend to make this as good as it can possibly be. Everyday, I treat this like it is the real deal and I generally program things in 3 or 4 different ways before I consider it done. In a way I have built like 10 engines or some shit cause I refuse to ever believe that I finally got it right.
                                Last edited by MadGypsy; 10-20-2016, 12:55 AM.
                                http://www.nextgenquake.com

                                Comment

                                Working...
                                X