Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About digital_phantom

  • Rank
  1. digital_phantom

    Shader causing wrong texture placement

    Hey, thanks for that information MJP. I'll put it to use.
  2. digital_phantom

    Shader causing wrong texture placement

    Alright, well I fixed my problem, it was inside the program code. What I was doing was setting the texture to the shader after the BeginPass() was called which was causing that texture to be used on the next call.
  3. My knowledge with the HLSL effect files is very little, I've been trying to get lights to work, so I found an example effect file and I've been messing with it. My demo I am working on a 3D tile engine for an RPG, when not using the light effect everything renders correctly, when using the effect through textures are misplaced to other tiles. Here is the shader fragment: //user variables float3 inLightPosition; float3 EyePosition; float4x4 inMatWorldViewProjection ; float4x4 inMatModelWorld ; float4 Ambient:Ambient; float4 Specular:Specular; float4 Diffuse:Diffuse; float SpecularPower:Power; texture inBaseTexture : BaseTex; //but we use the sampler in pixel shader (we can set parameter in it) sampler2D baseMap = sampler_state { //important, we must set texture in sampler Texture = (inBaseTexture); ADDRESSU = WRAP; ADDRESSV = WRAP; MINFILTER = LINEAR; MAGFILTER = LINEAR; MIPFILTER = LINEAR; }; //vertex shader //we execute all linear operation in vertex shader struct VS_INPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 Normal : NORMAL0; }; struct VS_OUTPUT { float4 Position : POSITION0; float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection : TEXCOORD2; float3 Normal : TEXCOORD3; }; VS_OUTPUT vs_main( VS_INPUT Input ) { VS_OUTPUT Output; Output.Position = mul( Input.Position, inMatWorldViewProjection ); // transform Position Output.Texcoord = Input.Texcoord; // use the input texture coords float3 ObjectPosition = mul( Input.Position , inMatModelWorld ); // get the object position Output.ViewDirection = EyePosition - ObjectPosition; // V Return the view direction Output.LightDirection = inLightPosition - ObjectPosition; // L return the difference in the light position from the object position. Output.Normal = mul(Input.Normal, inMatModelWorld ); // N return( Output ); } //Pixel shader //we use vertex shader results to calculate light in pixel shader (better result) struct PS_INPUT { float2 Texcoord : TEXCOORD0; float3 ViewDirection : TEXCOORD1; float3 LightDirection: TEXCOORD2; float3 Normal : TEXCOORD3; }; float4 ps_main( PS_INPUT Input ) : COLOR0 { float3 LightDirection = normalize( Input.LightDirection ); float3 Normal = normalize( Input.Normal ); float NDotL = dot( Normal, LightDirection ); float3 Reflection = normalize( ( ( 2.0f * Normal ) * ( NDotL ) ) - LightDirection ); float3 ViewDirection = normalize( Input.ViewDirection ); float RDotV = max( 0.0f, dot( Reflection, ViewDirection ) ); float4 BaseColor = tex2D( baseMap, Input.Texcoord ); float4 TotalAmbient = Ambient * BaseColor; float4 TotalDiffuse = Diffuse * NDotL * BaseColor; float4 TotalSpecular = Specular * pow( RDotV, SpecularPower ); return( saturate( TotalAmbient + TotalDiffuse + TotalSpecular ) ); } technique Technique0 { //each pass is a couple of vertex and pixel shader //we must specify the shader version (for this we need at least 2.0) pass Pass_0 { VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } } Here is the preview with the shader disabled: http://i292.photobucket.com/albums/mm40/digital_phantom/demo/without_shader.jpg Here is the preview with the shader enabled: http://i292.photobucket.com/albums/mm40/digital_phantom/demo/with_shader.jpg I need to know why and figure out why with the shader it is causing the misplacement of the tile texture.
  4. digital_phantom

    Help and question with RPG auto-stats for mechanics

    Quote:First, two general issues about RPGs (and I apologize for bringing them up!): I'd recommend not basing anything directly on d20. d20 is in many ways bizarre, irrational, and loaded with a lot of "tradition" aka weird design decisions. Also It was made for being played by-hand with dice -- you're using a computer so you don't need to do things the way d20 does it. My mechanics are now mostly based on some battle mechanics I found on gamefaqs on various Final Fantasy games, but the same problems I mentioned with players verses the enemies still exist with being leveled out. Quote:That said, "Levels" too are an abstraction created to make playing RPGs by-hand involve less calculation. (Though I realize that you have to quantify things using numbers at some point to ever calculate anything.) Because you're using a computer, you don't need to use strict levels for characters, you could probably be a bit more loose in tracking different attributes in different ways rather than pegging it all to level. But if you insist! The reason for using levels is by means to cap how strong your character becomes, and it helps me generate the stats for each level instead of trying to figure out how much the stats should increase at level up. Quote:Regarding stats and skills, I personally liked the system in Ultima Online -- you could only have 255 (or so) attribute points divided between 3 attributes (Strength, Dexterity, Intelligence), and once you got really trained up you'd just be shuffling a fixed amount between them as you used one particular attribute more at the time. Same for skills, once you hit 700 it'd just redistribute points from the rest of your skills into the skills you were currently using. This made the difference between the weakest and strongest players much smaller, a factor of someone with 50hp and 50 sword skills vs. someone with 100hp and 100 sword skill (who could very well kick their ass) rather than having some worm with 4 hitpoints trying to fight a god with 65000 hitpoints, which isn't even remotely fun for either. Ultima Online was interesting, but yet the way it worked is not the direction I want to take this battle mechanics system to. Quote:I guess what I'm saying is that you should be aware of the baggage that comes with employing the traditional abstractions used in RPGs. With all of that said, let me try to give comments you actually asked for. I suppose your problem can be solved by simply being being creative with, yes, game mechanics, but also algebra to make combat results less ... boolean. Like, hmm, compare the square root of attack vs. defense rather than the values directly, so instead of 1 attack skill = 1 attack skill in combat, you get 1 attack skill = 1 in combat to start, then 2 = 1.4, then 3 = 1.7, 4 = 2, 5 = 2.2, 6 = 2.4 ; Note that the rate of progression is slowing down, so the difference between a couple levels isn't so great. Or whatever, it's fun to plug equations into a graphing calculator to see what happens to the rate of progression. I don't get what you mean by compare the square root of the attack vs. defense, because the reason for comparing the direct value is to determine what the damage left to dealt is. Quote:And it'd probably be a good idea to make the relationship between damage and attack/defense less direct, like use a to-hit chance with a max and min possible value. In Fallout (which I admit was based on d20, damn!), you always had a minimum chance of 5% and a max of 95% to-hit, ever, so even a hopeless shot could make it through sometimes, and success was never guaranteed. I'm actually got a whole system going on checking the chance to hit which is divided into if a character missed or got their attack blocked. Quote:And I liked the way Fallout handled armor -- each armor type had a base damage "absorption" and then a percentage damage resistance. So: damage = (attackDamageRoll - armorAbsorption) * (1.00 - resistance); Leather armor had a good absorption and poor resistance while metal armor had poor absorption and good resistance (like 70% vs. lasers, I believe). Note that the armors do not have "levels" as such, they're just different types of armor, which I think is a good way to break out of the whole level-up grinding iterator genre of game -- eg. "Congrats! Everything is the same, just with higher numbers!" (though Fallout did break this rule later by adding "levels" of armors, tsk tsk). That is interesting but the thing is that the game would have to make to generate some kind of stats based off of those "types of armor" being hard-coded or not. My whole approach to this is to get hard-coded numbers out of the way and have the game handle this. Researching this and playing with the math involved in this process is a bit tricky because you have so many factors of things; players, enemies, player equipment, magic stats, etc... Just to get this all balanced is a pain.
  5. In my role-playing game's mechanics, I got the battle mechanics (like when a user attacks or uses magic) based off of the d20 system and other systems. The system works well in my tech demo using pre-decided player and enemy statistics. Since I don't have formulas for how much the player's stats should increased on level-up I decided to auto-calculate the stats for I don't have to hard code anything. What I mean by this is I built a bezier curve to calculate Y values for each X position using map point locations. Basically, it fills a stat graph for each player level (0-99) the player's primary stats are (1-99) but other stats are (1-255). So at level 1, the value is 1, and at level 99, the value is 255. And then I have different auto-creation functions for the stats that place the bezier points in different locations to indicate a slow-level up graph or a faster-level up graph, which looks like a cubic line for slow-level up. So I use these auto-functions right now to build these stats: * Player/Enemy Stats (Strength, Magic, Vitality, and Speed). * Equipment Stats (Attack, Defense, Evasion, Magic Defense, and Magic Evasion). * Magic Stats (Power) So that is what is going on here. Now note that the enemies are based on the same system that the players are with the exception that enemy's HP are generated way higher. Which that is where a little problem is at. The basic attack [damage = (user_derived_atk - target_derived_def)] Works some of the times depending on what the generated stats are. In order for anything to work the player has to be a higher level then the enemy... But then the enemy won't do good enough damage. Does anyone have any suggestions on this? By the way, the user and target derived attacks are just the equipment stats added up. Because some of the enemies are monsters which won't have equipment, I am thinking about adding 'Private Equipment' to the enemy database, meaning when the enemy's equipment isn't set then the private equipment stats is used instead. I know I've typed a lot so far, so bare with me. The last part, is what I use to calculate the stats. For the players/enemies, classes are used (players have classes like adventure, theif, mage, knight, etc...) and monsters have the classes (low, medium, high) Each class stores the calculated stats, the stats are generated by a "stat pie" I created that allows you to choose what the character is more of "ex: strength verses magic" The equipment is generated by using a "equipment level" and "equipment ratings". Each equipment stat has a rating, None, Low, Medium, or High. None means the equipment doesn't have that stat, low is the equipment's is very little with a capped max, and medium is a slow-level up graph, and high is faster-level up graph. Does anyone have any insight/ideas or questions to any of this? Like what does someone else recommend using instead of the bezier curve? Because I am doing all this pretty much blind since I have no previous knowledge on a battle mechanics system. Thanks for any help, it will be appreciated, and sorry again for the long message.
  6. digital_phantom

    Worms-Style 2D Water

    Thanks everyone for your quick replies, At this moment, I am not too concerned with creating the water layer translucent, for right now I think the main purpose is trying to create the surface of the water. Harry Hunt, as you mentioned about bezier splines would be useful, but you would have to figure out extra information like points for the curve, maximum height for the waves, getting the colors under the curve to display. I am thinking about using pre-rendered images for each part of the wave, of which is animated. I need to go look at a video for it. The screen shots' link I posted was from the new PSP game, which is why it's so small, the older games for the PC didn't look at great for the water effects.
  7. digital_phantom

    Worms-Style 2D Water

    I have a graphics question, I am trying to figure out how to render semi-realistic water in my side-scrolling game, I would like to match as close to possible the Worms series water. Screen Shots for one of the Worms games here: http://www.gamespot.com/psp/strategy/wormsopenwarfare2/index.html And, an actual screen shot here: http://image.com.com/gamespot/images/2007/129/939169_20070510_screen008.jpg If anyone knows how to do this or how to put me into the right direction, I would appreciate it.
  8. digital_phantom

    Colour Blending

    you can blend two colors together by a percentage, and I am guessing you are archiving for like a 50% blend. So the method I like to use is this: percent = 0.5; //what ever you want to use between 0.0 and 1.0 new_red = ((color1_red * percent) + (color2_red * (1.0f - percent))); new_green = ((color1_green * percent) + (color2_green * (1.0f - percent))); new_blue = ((color1_blue * percent) + (color2_blue * (1.0f - percent))); So maybe this can help you.
  9. I have a question for handling the falling part of collisions in my 3D game I am coding. When using falling collisions in a 3D environment, ray tracing is expensive if used a lot, so I am wondering how is the best way to handle a character (or any object) falling in 3D space, like a character walking around or jumping down from a ledge, because even for a character walking, it's got to detect the ground (and if any slopes), so what would be the best way to handle this, or how has other people handled this before? Any help would be appreciated, thanks in advance.
  10. digital_phantom

    Help with custom language variables

    Vorpy, So what I decided to do so far is this: I have been working on the framework for a memory table. Everything should work, but it's not tested until everything is changed over. But this is the contents of each table item in the memory table: * isUsed (If the memory area has been "destroyed", then this will be set to false and re-used by any future processes) * value (a string value that can be anything.) * arrayCount (if this is an array, this will contain a positive number over 0) * arrayItem[] (each array item will contain addresses to other memory areas) Now with this new structure, my new variable management system framework is as this for each variable item in the table: * isUsed (same as the isUsed field in the memory table entry, for safe deleting of variables without having to re-size the array (only if needed). * name (the variable's name, used for finding this entry if a name was given instead of an index value) * memoryAddress (the address to the memory table where the variable's value resides at) * location (if blank, this is a global variable, else if has a unique ID, this belongs to the area specified, like a function or some name space) I've already programmed the linker, and it seems to work as needed, I just need to apply it to the actual virtual machine. Thanks so far for yours and Ahnfelt's help.
  11. digital_phantom

    Help with custom language variables

    Ahnfelt, Quote:Original post by Ahnfelt Be sure to differentiate between Values, which are the actual data and Variables, which merely points to values. Yes, I know what the difference between Variables and Values are, so don't worry about that. Quote:I assume that you're going for a dynamically typed language (where every variable can contain any type of value). In that case yes, you should store type information in the value. You probably want "being an array" to be a property of values, not of variables. Yes, there is no data types in my language, everything is stored as strings (characters), but when numeric comparison comes into play, the virtual machine does everything necessary to check to see if both comparisons are numeric. Quote:However, I suggest that you choose a more dynamic structure than arrays - you can't really resize arrays, at least not efficiently. A popular scripting language called Lua uses hashmaps (aka tables) to store all collections of values, and it seems to work pretty well. Yes I know about Lua, well I've made some applications for it before. But if I am not mistaken, but a table is the same thing as an array... After all you have to use arrays to store lots of data, Item[0], Item[1], Item[2], etc... And isn't hashmaps just tables that contain MD5-hashes or equivalent ? Quote:If you're worried about efficiency, you should make your virtual machine instructions do as much as possible each. That way you reduce the amount of overhead (time spend fetching and decoding instructions), simply because you have less instructions. Most other optimizations can be applied when you have a working product. I'm not worried about the instruction part, I've got that done, but some of the instructions need some work done. Like the variable management, which is part of the instructions. Quote:I don't quite understand what being able to create new variables at runtime buys you. Care to elaborate? I'm sorry but that confused me, care to explain what you mean more further in depth? My scripting language technically has two languages in one... (1) So you type in the syntax into an editor, the compiler compiles the code into the native language used by the virtual machine. So that's the first language. (2) I use what I call "dynamic expressions", basically there is an instruction which parses a specified "dynamic expression" and runs it. Almost every virtual machine instruction can be defined in a "dynamic expression", I got the motivation for this from Winamp's "Advanced Title Formatting". This is where all my math equations come into play as well. Where new variables come into play is from this, some of my test applications, like my advanced calculator, allows the user to add variables in runtime, at any time, and work with them.
  12. digital_phantom

    Help with custom language variables

    Thanks so far Vorpy and Ahnfelt, I am going to look more into garbage collection on google. What I am doing right now is I am writing another small application for my scripting language which is what I will call for now a "Linker".... It has two steps, (1) first function is opening up a compiled script, finding all variables, and storing their names into a table, the (2) second function is reading that stored table and replacing all the variable names with the indexes. I am going to implement the whole memory collection for variable values, for they can be linked together, but how will this work for variables that are arrays? That each array item will link to a different area of memory, or will the variable to link a part of memory which that part of memory will have a flag saying if it's an array or not ? Next, on talking about variables... I think that after my linker is created and partially, or fully tested, I think the virtual machine runtime environment, needs to also have access to the linker data, and it will at first, pre-create the whole variable list based on the linker data... and then add any additional variables for any dynamic runtime variables... What do you guys think on this idea? Or what idea would be best suited, or none at all and something else instead? I am trying to look for methods that avoids any loops at all during the virtual machine script loop.
  13. digital_phantom

    Help with custom language variables

    Well referring to what your talking about, wouldn't that mean I would have two lists now (or more), a memory one for variable values, and another one having the names, memory location, etc... And I don't want to sound stupid or anything but what is a garbage collection?
  14. digital_phantom

    Help with custom language variables

    Vorpy, The reason why I have all global and local variables stored under the same variables listing is because of my 'Is Linked' flag. Just like in C/C++, in my language you can link a variable to another variable... For an example, let's say you have two variables, named varA and varB... And varA contains the number 18, but varB does not contain anything yet... So if you link varB to varA, when you go change varB, it would change varA too (really, varA is the only one being set here since varB is just linked to it) The linking feature is also how I make function's arguments "by reference" instead of just "by value". And that means that when a function is parsed, it's arguments are parsed as variables and later added to the variable list when that function is called. So I was thinking more about the variables list, if I am to add everything by index, right now I have the variable list always re-allocated every-time a new variable needs added... but this runs into a little problem. So when a variable is getting set/get using the "compiler index" values, it is most likely going to have a larger value then the allocated size of the table... like so we're going to set the variable #80 into the variable table of like size 30.... well that isn't going to work quite well... so... I was thinking about that, I see two choices... either (A) When setting a variable to a smaller table, automatically allocate the table to that variable's larger index ... or ... (B) Have a fixed memory allocation for the variables. By my programming habits, I don't like anything that is fixed, I want everything to be dynamic, more adjustable... So what do you think on this issue? Should it be a fixed or dynamic list ?
  15. digital_phantom

    Help with custom language variables

    Vorpy, Pretty much the "global variable list" is an always adjusting array list, each item in the array is a structure containing the variable's: * Name * Value * Scope (Global, Local) * Is Linked (Which Variable Name Is Linked To) And, * Local ID (If local scope is used, this is the 'Unique Function Name' that this variable belongs to, only used when searching for a variable through.) So you brought up a good point, like with Python, because my language is both Static, and Dynamic. There are variable management commands, and there are special "outside the environment" variable management commands as well that can be changed by the user at any moment as long as the parent application allows it. I don't know if all of this will spice it up a bit or not.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!