Jump to content
  • Advertisement

Servant of the Lord

Member
  • Content Count

    7285
  • Joined

  • Last visited

Community Reputation

33735 Excellent

1 Follower

About Servant of the Lord

  • Rank
    C++ programmer

Personal Information

Social

  • Twitter
    JaminGrey

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Servant of the Lord

    [GLSL] Having trouble with a graphical glitch in my shader

    I fixed the problem by sampling each of the four corners of the cell, and interpolating between them. //Sample four different corners of each 24x24 area water cells. vec4 waterColorTL = GetWaterColor(fArea_WaterCellCoord + (vec2(-1.0, -1.0) * Area_WaterCellHalfSize), sineWave); vec4 waterColorTR = GetWaterColor(fArea_WaterCellCoord + (vec2( 1.0, -1.0) * Area_WaterCellHalfSize), sineWave); vec4 waterColorBL = GetWaterColor(fArea_WaterCellCoord + (vec2(-1.0, 1.0) * Area_WaterCellHalfSize), sineWave); vec4 waterColorBR = GetWaterColor(fArea_WaterCellCoord + (vec2( 1.0, 1.0) * Area_WaterCellHalfSize), sineWave); //Interpolate between the horizontal samples. vec4 waterColorTop = AlphaBlend(waterColorTL, waterColorTR, amountThroughCell2D.x); vec4 waterColorBottom = AlphaBlend(waterColorBL, waterColorBR, amountThroughCell2D.x); //Interpolate between the vertical samples. vec4 waterColor = AlphaBlend(waterColorTop, waterColorBottom, amountThroughCell2D.y); You can see a video of it working here: https://twitter.com/JaminGrey/status/1056672921048006657
  2. I'm making a 2D river, and shifting the texture coordinates of the water based on a low resolution "flow map". Each pixel in the flow map is 24x24 pixels on-screen. Everything is mostly working fine, but I'm getting a weird distortion where pixels are interpolating between the flow map. I'm animating the tex coords based on time, and passing in the time via a uniform, from 0.0 to 1.0. What's weird is that the distortion is non-existent at a time of 0.0, and gets worse and worse until 1.0. At time = 0.0, no distortions At time = ~0.5, some distortions At time = ~1.0, lots of distortion [YouTube video demonstrating the glitch] (Notice it snap back around the 5-second mark of the video - that's when uWaterCycle reaches 0.0 again) I tried to simplify the shader as much as possible to narrow in on what's going on, but something is eluding me. I understand the texture won't line up perfectly, since the texture only tiles at the seams, but here it'll be sampling arbitrarily. Regardless, I don't understand why the lines are all streaky and seemingly moving sideways? uniform float uWaterCycle; //Goes from 0.0 to 1.0, based on time. void main() { //======================================================================================= //...snip irrelevancies... //======================================================================================= //The "flow map", where each pixel represents the water flow of a 24x24 pixel area on-screen. vec4 areaWaterCell = texture2D(Area_WaterCellTexture, fArea_WaterCellCoord); //Water direction. vec2 waterDirection = areaWaterCell.rg; //Convert from (0 - 1), to (-1 to 1) waterDirection = (((waterDirection) * 2.0) - 1.0); //Multiply to increase water flow speed. vec2 waterDirectionX10 = (waterDirection * 10.0); //Get the primary water texture. vec4 waterDiffuseFrag = texture2D(Water_DiffuseTexture, fWater_DiffuseCoord + (waterDirectionX10 * -uWaterCycle)) * Water_Coloration; //======================================================================================= //...snip irrelevancies... //Set this color as the output. ColorBufferOutput = waterDiffuseFrag; //======================================================================================= }
  3. Servant of the Lord

    Accessing a subrect of a texture using a UV map [GLSL]

    I got my effect working. Thanks gents! ūüėÉ https://twitter.com/JaminGrey/status/1053107844474646528
  4. Servant of the Lord

    Accessing a subrect of a texture using a UV map [GLSL]

    I'm not using instancing. I'm using this specifically to do a special-effect for enemy deaths (and enemies can be different sizes). I think I am just trying to cram too much stuff into one general purpose shader. Because only one or two enemies are going to be dying on-screen at one time, I'll just use a separate shader and upload the subrect as a uniform. Thank you both!
  5. I have a texture I'm reading from like this: vec4 diffuseFrag = texture2D(DiffuseMap, fDiffuseCoord); Sometimes, for special effects, I'd actually like to do something this: vec4 uvFrag = texture2D(UVMap, fUVCoord); vec4 diffuseFrag = texture2D(DiffuseMap, uvFrag.rg); ...basically, I'm using a texture's Red and Green color channels to store the frag coordinates I want to read from DiffuseMap. My probably is, both the UV map and the Diffuse map are spritesheets with multiple images in them. This means, I'm actually wanting uvFrag.rg's (0-1) texcoord to be multiplied against the *subportion* of the texture that all four vertices of my fDiffuseCoord are referring to. Something like: vec4 uvFrag = texture2D(UVMap, fUVCoord).rg; vec4 upperLeftOfSubrect = ...; vec4 bottomRightOfSubrect = ...; vec4 subrectSize = (bottomRightOfSubrect - upperLeftOfSubrect); uvFrag = upperLeftOfSubrect + (uvFrag * range); vec4 diffuseFrag = texture2D(DiffuseMap, uvFrag.rg); Where my mind is going blank is, how can I get upperLeftOfSubrect / bottomRightOfSubrect, without bloating my vertex struct further with additional attributes? It mentally trips me up that I'll have to copy upperLeftOfSubrect / bottomRightOfSubrect into all four of my vertices... and triply annoys me because I'm already passing them in as fDiffuseCoord (just spread between different vertices). Is there a simple solution to this that I'm missing?
  6. Servant of the Lord

    Returning arrays of ""pointers""?

    Thank you, that indeed was the problem. And thanks for writing Angelscript and making it opensource, it's actually enjoyable integrating into my code - especially what with the native function calling!
  7. Servant of the Lord

    Returning arrays of ""pointers""?

    I'm having some trouble returning the array of pointers. Everything seems fine, and the array ends up the correct size (in my test cases, I'm only putting one element in it), but the pointer in the array on the script-side is null, despite me putting a valid pointer into it, on the C++ side. CScriptArray *GetTestCharArray() { static Character character; character.name = "CharName"; asIScriptContext *context = asGetActiveContext(); Assert(context, "Error! Can only call this function from within scripts"); asIScriptEngine *engine = context->GetEngine(); asITypeInfo *typeInfo = engine->GetTypeInfoByDecl("array<Character@>"); CScriptArray *arr = CScriptArray::Create(typeInfo, 1); arr->SetValue(0, &character); return arr; } //Elsewhere, where registering the function: RegisterScriptArray(engine, true); asCheck(engine->RegisterObjectType("Character", sizeof(Character), asOBJ_REF | asOBJ_NOCOUNT)); asCheck(engine->RegisterObjectProperty("Character", "string name", asOFFSET(Character, name))); asCheck(engine->RegisterGlobalFunction("array<Character@> @GetTestCharArray()", asFUNCTION(GetTestCharArray), asCALL_CDECL)); Here's the Angelscript side of things: void Fireball(Enemy &enemy) { array<Character@> @chars = GetTestCharArray(); //Correctly prints a length of '1'. print("Num players: " + formatUInt(chars.length())); //Prints "null" (but it shouldn't be null...) if(chars[0] is null) print("null"); else print("not null"); //Script crashes and reports a "Null pointer access" print("Character " + formatUInt(0) + ": " + chars[0].name); } Is there some obvious mistake I'm making? [Edit:] I simplified the code even further from what I originally posted, but the array elements are still null.
  8. Servant of the Lord

    Goblinson Crusoe Level Editor

    Will your spline groups actually be able to depress the terrain for the rivers? That sounds really neat!
  9. Servant of the Lord

    Returning arrays of ""pointers""?

    Thank you, that link helped alot. I must've missed the 'handle' stuff, distracted by 'references'.
  10. Servant of the Lord

    Returning arrays of ""pointers""?

    I'm new to Angelscript. I have some classes that I don't want scripts to create, but that I want to give scripts access to. I have several different class types like that ("Player","Enemy","Event", - scripts should never create any of these). Would the appropriate registration flags be asOBJ_REF and asOBJ_NOCOUNT, and then simply not registering the constructors/destructors? All of these are guaranteed to out-live the scripts. engine->RegisterObjectType("Event", sizeof(EventStructure_Server), asOBJ_REF | asOBJ_NOCOUNT) I want (C++-side) functions that returns arrays of these references/pointers. Things like, "event.GetPlayersInRange(pos, range)" I see there is a CScriptArray, but I don't understand if this is a *replacement* for an existing built-in array type, or if there is no default array type? In C++, how would I create an array of non-reference-counted references to return? Is this correct: (going off of the addon Array example) // Registered with AngelScript as 'array<Enemy> @CreateArrayOfString()' CScriptArray *GetEnemiesInRange(cPointF pos, float radius) { asIScriptContext *ctx = asGetActiveContext(); Assert(ctx, "Error! Can only call this function from within scripts"); asIScriptEngine* engine = ctx->GetEngine(); // vvv Should this just be "Enemy"? asITypeInfo *typeInfo = engine->GetTypeInfoByDecl("array<Enemy>"); std::vector<Enemy*> enemies = /*...whatever...*/; CScriptArray *arr = CScriptArray::Create(typeInfo, enemies.size()); for( asUINT i = 0; i < arr->GetSize(); i++ ) { arr->SetValue(i, enemies[i]); //Just give the CScriptArray pointers to the Enemy instances? } return arr; }
  11. Servant of the Lord

    Multiple scripts with the same function names?

    I suppose I could just have an AreaA_OnLoad.as script, when I load the script, just wrap it in void AreaA_OnLoad() { <file code> } , like the ExecuteString() utility does.
  12. Servant of the Lord

    Multiple scripts with the same function names?

    I just started using Angelscript, and am misunderstanding how exactly to set up everything. One of my confusions is, suppose I want a script for each area, with maybe an interface like this: void onLoad() { //...unique initialization logic for this area... } void onTick() { //...unique update code for this area... } How do I prevent the AreaA.as script's onLoad() function signature from conflicting with AreaB.as script's onLoad()? How do I call a specific one's function? Would I make each *area* have a separate *module*? That doesn't sound right. Each area would provide *different* logic in each Area's function, so it doesn't seem like it'd make sense to make Area a class, I think.
  13. To add to this, it takes the same amount of time (in general) to render a pre-rendered image as it takes to render any other image that's the same resolution and color depth. An image is an image (mostly - things like compression can also play a big effect on performance), whether it's a pre-rendered scene, a sprite, or a real photograph. Games like Myst (and it's sequel Riven) took advantage of this to make breathtakingly beautiful worlds (for the time) run on such (relative to the present) dramatically weak hardware. The downside is that it's not dynamic. The reasons why earlier pre-rendered artwork was inferior is for a number of reasons. Part of it is, as others mentioned, lower resolution and lower number of colors available. Other reasons include that pre-rendering images isn't easy either! Toy Story 1 had each frame rendered on a server farm of 300 processors, and even then, every frame took between 45 minutes and 30 hours to render, and Pixar basically had to invent most of the technology and algorithms from scratch, and had brilliant computer scientists like Catmul heading it up. Average videogame studios didn't have the technical expertise in that (at the time) cutting-edge field, nor the massive amount of specialized computer hardware necessary to pull it off within their limited budgets. Further, there's also the issue of the massive amount of 3D modelling that must be done to create models (to prerender) with very high polygon counts. The 3D modellers' computers need to be able to render the individual 3D models (without lighting) at least almost in real-time, otherwise modelling gets very frustrating fast, so this also puts a soft cap on the quality of the individual objects that will be pre-rendered. The better option for PS1-era games would be having artists create the 2D backgrounds, perhaps with some basic polygonal scene modelling, rather than trying to 3D model complex scenes. Legend of Dragoon and Chrono Cross looked very good (about the same quality as your RE3: Nemesis screenshot) when exploring the world, though in both those games the actual characters and all in-combat scenes used 3D models that were low-polygon and suffered in comparison to the non-combat backgrounds. Diablo 2 pre-rendered all their character models, that way they could have their character models be higher polygons than they'd otherwise be able to do. To pre-render their models, they had to essentially take (automated) screenshots of their models from every rotation, for every keyframe of animation, and do the same for each piece of equipment, which they would layer on top (called "paper-dolling"), because different equipment in Diablo 2 affected your avatar's appearance.
  14. Servant of the Lord

    Grappling in Open-World PvP

    Nothing prevents a team of very skilled programmers from implementing such a feature, if that's what you're asking. No such pre-built system exists that can just be plugged into a game, and the animation requirements and programming effort would be such that it'd be a very difficult task (and certainly beyond my meager capabilities, so the rest of my post is just me thinking). The "open world" part is irrelevant (the layout of the world doesn't affect the combat), but expanding it to online PvP (rather than just online PvE or even easier, single-player PvE) makes it harder, definitely. I'd imagine such a system would ultimately behave similarly to the Uncharted series of games: basically, a bunch of context-sensitive pre-scripted animations that can play out based on your position relative to the enemy and the enemy's current state (orientation, and combat state - e.g. throwing a punch at you), as well as the immediately-surrounding shape of the environment. If you haven't played the game (I've only played Uncharted 1 and 2 myself), none of that video is a cutscene - it's all gameplay. BUT you lose control for short blips of time during certain moves - i.e. once a more complicated move begins, and the player' and enemy's animations need to be synced together (for example, pulling the enemy off a roof, or grabbing onto them in any way), you lose temporary control until the synced animation plays to completion. Basic attacks like punches and kicks, and so on, don't have you lose control. But for the duration of e.g. grabbing an enemy's head and smacking him with your head, you lose momentary control. With longer moves this is more apparent and noticeable to the player (the reason why I said you "don't lose control" during basic kicks and punches is really because they are so fast you don't notice you lost control - most action games are like this while a quick animation plays out (for example, a sword-swing in 3D zelda games)). In Uncharted specifically, you only have two or three buttons that help decide what type of move to do, and the final move chosen is based on context, not explicit player choice. So it's very interactive, but sacrifices more interactivity than most games do specifically to enable the cinematic movie feel that you seem to also be interested in that requires the animations of more than one entity to sync up together.
  15. Servant of the Lord

    What to do in a pirate game?

    Not pirates, per-se, but have you watched the Russell Crowe movie Master and Commander? Good inspiration there. Shooting albatrosses while standing on a bucking ship deck. Becoming a naturalist and discovering different kinds of new animal species. Trying to scavenge supplies off of islands - need to discover what herbs are edible Oregon Trial-style. Trading at ports - piracy always involves merchantile-ness as well. Gotta unload that cargo somehow, and gotta procure more supplies. Upgrading your ship, getting caught in storms and having to repair your ship while at sea or via resources scavenged from uninhabited islands. Hunting a specific enemy vessel - whether it be a more powerful military vessel or an elusive merchant vessel. e.g. you could be aware that the Spanish Silver Fleet is in a specific ocean, but you'd have to scour the ocean to find it. Maybe you have the barest idea of their sea course, and can try to find them along it somewhere. Can also be flipped - once you have become famous enough of a pirate, powerful government vessels can start hunting *you*, and you better know the sea very well, and all the islands, because the more powerful of their ships outgun you substantially.
  • Advertisement
√ó

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!