• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

trock3155

Members
  • Content count

    17
  • Joined

  • Last visited

Community Reputation

155 Neutral

About trock3155

  • Rank
    Member
  1. Ok, I definitely need help, as my mathbrain is simply non-functional here. Now that the root node is properly following my physics entities "body", I am struggling to get the transforms for the rest of the skeleton. I am getting crazy stretching, presumably because I'm not working in the right "space" when calculating those transforms. This is what I'm doing, starting with how I calculate the offsets of physics entity-to-bone: [source lang="csharp"] offsets.Add("Armature", Matrix.Invert(bindPose[0]) * Entities["body"].WorldTransform); //Calculate root offset first for (int i = 4; i < input.Model.Bones.Count; i++) { int poseIndex = i - 3; string bone = input.Model.Bones[i].Name; if ((bone == "neck")) offsets.Add(bone, Matrix.Invert(bindPose[poseIndex]) * Entities["head"].WorldTransform )... // get each "physics-tied" bone's relative offset[/source] Now I calculate the boneTransforms: [source lang="csharp"]Matrix[] boneTransforms = new Matrix[bindPose.Count]; Matrix finalOffset = offsets[0] * body.WorldTransform; boneTransforms[0] = finalOffset * Matrix.Invert(actorWorld); //establish root for (int i = 1; i < bindPose.Count; i++) //get offsets for other bones { int boneIndex = i + 3; string bone = input.Model.Bones[boneIndex].Name; if (bone == "neck") { offset = Matrix.Invert(offsets[bone]) * Entities["head"].WorldTransform; boneTransforms[i] = offsets[bone] * Matrix.Invert(actorWorld); } else //offsets for non-physics bones { boneTransforms[i] = bindPose[i]; } }[/source] And finally, converting the bone transforms into world space: [source lang="csharp"]Matrix[] worldTransforms = new Matrix[modelData.BindPose.Count]; Matrix[] skinTransforms = new Matrix[modelData.BindPose.Count]; worldTransforms[0] = boneTransforms[0]; skinTransforms[0] = inverseBindPose[0] * worldTransforms[0]; // Child bones. for (int bone = 1; bone < worldTransforms.Length; bone++) { int parentBone = skeletonHierarchy[bone]; worldTransforms[bone] = boneTransforms[bone] * worldTransforms[parentBone]; skinTransforms[bone] = inverseBindPose[bone] * worldTransforms[bone]; } return skinTransforms; //this gets passed into my shader (identical setup to what the XNA skinning example uses)[/source] Again, this all works just fine for my root node, but the various bodyparts (in this case the head) ends up stretched and about 15 ft from where it should be. Can anybody help me figure out where I am going wrong in calculating the skintransforms?!
  2. After thinking through what I said above, I tried a simple thing and it worked to solve the problem mentioned above. Here is what I did: 1. Stopped using the offset world position for my the ragdoll and draw transforms. This made it so my model always at least drew where it was supposed to in bind pose while ragdolls were enabled. Again, the offset was an artifact of using a physics entity that had it position set to the middle, and then having to reverse that when drawing. 2. Used an offset for the entire skeleton (in the bone-entity mapping phase). Prior, I had been only getting offsets for each bone, starting with the hip (aka bones[1]). Since the hip is centered in the middle of the body, it's transforms would be offset weird from the model's center, which is actually between it's feet. I believe this was also worsened by the fact that the physics entity's orientation UP is different than the models. Now, I move onto binding each bodypart... I suspect I will have issues doing this as well; if so you'll be certain to see me back here
  3. This topic is also here: [url="http://www.gamedev.net/topic/633955-ragdoll-physics-rendering-issues/"]http://www.gamedev.net/topic/633955-ragdoll-physics-rendering-issues/[/url] but I realized after posting, it might make more sense in this forum? Feel free to remove the dupe. Hi folks, I have reached my wits end in trying to get my model to align with its ragdoll, and I was hoping you could help me a with a couple questions. I am using BEPU physics for my simulation, where my Player primarily moves around via a CharacterController object until he dies, and then the ragdoll is activated. I am currently trying to simply get the player model to stay locked with the the "body" entity as an initial working case before attaching each limb. The problem I have is pictured below: [img]http://i573.photobucket.com/albums/ss178/trock3155/ragdollseparation.jpg[/img] As the ragdoll moves, the model does not stay locked with the body entity, and the more it rotates, the more the model separates. I presume this has to do with one (or both) of these 2 things: 1. The world transform of the model represents the center of the CharacterController capsule (the pink thing pictured). I use an offset during drawing that adjusts the draw position, but this may be causing wierdness when rotations are added from the body entity. Should I essentially just pre-offset my CharController's position, and then pass that Transform to the ragdoll class and draw functions? 2. I am attempting to calculate the offset of the model to the ragdoll, which I then factor in when passing back the bone transforms, so that apples are compared to apples when the body does start to rotate/translate. I may be doing this wrong? This is my psuedocode for calculating that offset: Matrix offset = Matrix.Invert(bindPose[bindPoseIndex]) * Entities["body"].WorldTransform and my code for reapplying it when the bone transforms are being calculated: Matrix.Invert(offset) * body.WorldTransform * actor.WorldTransform (actor is the char controller) I am pretty sure that once I can figure this out, the rest of the ragdoll will be gravy, but I have been racking my brain for about 30 total hours on this issue to no avail, and I need some help thinking outside the box. Thanks!
  4. Hi folks, I have reached my wits end in trying to get my model to align with its ragdoll, and I was hoping you could help me a with a couple questions. I am using BEPU physics for my simulation, where my Player primarily moves around via a CharacterController object until he dies, and then the ragdoll is activated. I am currently trying to simply get the player model to stay locked with the the "body" entity as an initial working case before attaching each limb. The problem I have is pictured below: [img]http://i573.photobucket.com/albums/ss178/trock3155/ragdollseparation.jpg[/img] As the ragdoll moves, the model does not stay locked with the body entity, and the more it rotates, the more the model separates. I presume this has to do with one (or both) of these 2 things: 1. The world transform of the model represents the center of the CharacterController capsule (the pink thing pictured). I use an offset during drawing that adjusts the draw position, but this may be causing wierdness when rotations are added from the body entity. Should I essentially just pre-offset my CharController's position, and then pass that Transform to the ragdoll class and draw functions? 2. I am attempting to calculate the offset of the model to the ragdoll, which I then factor in when passing back the bone transforms, so that apples are compared to apples when the body does start to rotate/translate. I may be doing this wrong? This is my psuedocode for calculating that offset: Matrix offset = Matrix.Invert(bindPose[bindPoseIndex]) * Entities["body"].WorldTransform and my code for reapplying it when the bone transforms are being calculated: Matrix.Invert(offset) * body.WorldTransform * actor.WorldTransform (actor is the char controller) I am pretty sure that once I can figure this out, the rest of the ragdoll will be gravy, but I have been racking my brain for about 30 total hours on this issue to no avail, and I need some help thinking outside the box. Thanks!
  5. Alright, so it looks like my shaders are not properly downscaling the render target target that contains the luminance data. Everything seems correct until I get to the final single pixel target. At that point, I am (seemingly) only getting a 1 pixel sample from my previous/larger RenderTarget (not totally sure which pixel it is pulling though). It's odd, because they all scale down just fine, and I can see in my luminance chain render targets that they are showing light where my screen is lit (albeit in mega-low resolution). I have to figure out why my final downscale shader is not properly sampling each pixel it needs to before it outputs the current frame's luminance. Below is my scaling shader code. Note that this function [i]should be [/i]taking in 5 samples total as a sort of manual linear filter (see below) [CODE] float4 vColor = 0; for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { float2 vOffset; vOffset = float2(g_vOffsets[x], g_vOffsets[y]) / g_vSourceDimensions; float4 vSample = tex2D(PointSampler0, in_vTexCoord + vOffset); if (bEncodeLogLuv) vSample = float4(LogLuvDecode(vSample), 1.0f); vColor += vSample; } } vColor /= 16.0f; if (bEncodeLogLuv) vColor = LogLuvEncode(vColor.rgb); if (bDecodeLuminance) vColor = float4(exp(vColor.r), 1.0f, 1.0f, 1.0f); return vColor; [/CODE]
  6. Alright, so I found the error in my luminance code that was causing it to bug and out and make everything super dark (it always thought the previous frame was max intensity white, as suspected). I can now use my normal light intensities to get similar results with and without HDR, which is awesome. However, the ultra-black (or burnt out) areas of the frame are even more pronounced and more common, and the entire scene is actually worse off than it was before. I have messed with my specularity, but that alone does not seem to be causing it. I am thinking maybe it is my normals, but I'm not sure? In any case, take a look at what I'm seeing now, and let me know if you have any thoughts: [url="http://img15.imageshack.us/img15/4932/v2hjcedzkttfslgfpwmwbb.mp4"]http://img15.imagesh...fslgfpwmwbb.mp4[/url] Thanks!
  7. You are definitely right about the strong intensities causing the bloom artifacts; if I turn the bloom threshold down things work just fine at lower intensities. I think the problem that I'm trying to overcome is that i must make my light intensities 5-10 times higher than I did prior to implementing HDR to get the same visibility levels. Literally, in order for me to get the same scene brightness from a directional light that I got with LDR set at ".7" intensity, I must set the same lights with my HDR potprocess to 4 or 5. Is this normal? How is this best countered given my tonemapping algorithms above? This will be especially problematic if I have profiles that allow you to turn off HDR rendering, where things will be unbelievably bright. My luminance test also seems to be outputting a full white color no matter how dark the screen is (when I map the have my renderer output the average luminance sampled in the tonemap function). Is that normal (perhaps due to the larger color range of the actual HDR sample than I can output from the renderer? Even if that was the case, I would think and unlit, black scene would produce something more gentle than what looks like full white.
  8. I'll start out by saying I worked from MJPs oldish example of HDR: [url="http://www.xnainfo.com/content.php?content=28"]http://www.xnainfo.com/content.php?content=28[/url] Note that without the HDR postprocess everyone looks just fine. In my code, I am using HdrBlendable surface formats for my Color and Lightmaps, which are then combined into a final RenderTarget, also with HdrBlendable as its surface type, before being passed off to the HDR postprocessor My results can be seen in the below video (where a single directional light is being used at an intensity of 5). You can see the bloom effect is very "spotty", changing drastically when the camera angle changes. You can also see near the roof of each house a super-dark area, that almost looks like noise. Note that the super-dark areas appear even if I pull bloom out of the equation altogether. [url="http://img341.imageshack.us/img341/5366/rxtfsmkqvrfuypnechfltu.mp4"]http://img341.imageshack.us/img341/5366/rxtfsmkqvrfuypnechfltu.mp4[/url] I think my problem is most likely due to changing a majority of the samplers from MJPs project to use Point sampling, since XNA doesnt allow linear filtering of HdrBlendable RenderTargets, however I tried implementing some manual linear filtering in my shaders, and not only did they slow things down terribly, they didn't seem to solve the problem. Anyone have an idea of what is causing these visual glitches? I can provide any code necessary, but here is the ToneMapping PS: \[CODE] float3 ToneMap(float3 vColor) { // Get the calculated average luminance float fLumAvg = tex2D(PointSampler1, float2(0.5f, 0.5f)).r; //return float3(fLumAvg, fLumAvg, fLumAvg); // Calculate the luminance of the current pixel float fLumPixel = dot(vColor, LUM_CONVERT); // Apply the modified operator (Eq. 4) float fLumScaled = (fLumPixel * g_fMiddleGrey) / fLumAvg; float fLumCompressed = (fLumScaled * (1 + (fLumScaled / (g_fMaxLuminance * g_fMaxLuminance)))) / (1 + fLumScaled); return fLumCompressed * vColor; } float4 ToneMapPS ( in float2 in_vTexCoord : TEXCOORD0, uniform bool bEncodeLogLuv ) : COLOR0 { // Sample the original HDR image float4 vSample = tex2D(PointSampler0, in_vTexCoord); float3 vHDRColor; if (bEncodeLogLuv) vHDRColor = LogLuvDecode(vSample); else vHDRColor = vSample.rgb; // Do the tone-mapping float3 vToneMapped = ToneMap(vHDRColor); // Add in the bloom component float3 vColor = vToneMapped + tex2D(LinearSampler2, in_vTexCoord).rgb * g_fBloomMultiplier; return float4(vColor, 1.0f); } [/CODE]
  9. Just confirming that this solved my problem
  10. [quote name='Dancin_Fool' timestamp='1342646935' post='4960661'] Agreed with previous poster, my immediate thoughts are also that you aren't handling half texel offsets properly. [/quote] I am [i]trying[/i] to handle the offset, but definitely believe when you say that this is where the problem lies [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]. As I understand it, this is only necessary when rendering fullscreen Quads within a deferred renderer. Is this a false assumption? If this is incorrect, during which render calls [i]should [/i]I be handling offset ie. initial GBuffer render, light passes, drawing the final quad to the screen etc.[i]?[/i] I will do a full audit tonight, but this is what I am doing when rendering quads: [b]C#:[/b] Vector2 halfPixel = new Vector2(.5f/GBufferSize.X, .5f/GBufferSize.Y); //this is passed into the effect file [b]HLSL (Vertex Shader):[/b] [CODE] struct VertexShaderOutput { float4 Position : POSITION0; float2 TexCoord : TEXCOORD0; }; VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; output.Position = float4(input.Position, 1); //align texture coordinates output.TexCoord = input.TexCoord - halfPixel; return output; } [/CODE]
  11. Somehow in writing masses of XNA code, I think I missed that EffectPass.Apply() (which in XNA4 encompasses Effect.CommitChanges()) must always be called AFTER the Effect Parameters are set. In my case, my Player object was being drawn before the other NPCs, and thus it's Effect settings were applying to the NPCs that followed after. I will try this tonight, but I expect it should work. Thanks a ton!
  12. HI, I am trying to get rid of an issue I have with "glowing" edges that has plagued my deferred renderer for a while. I have spent some time looking thru my lighting code and G Buffer Rendering Code, but can not find anything that stands out. This is what I am seeing: [img]http://img163.imageshack.us/img163/2/glowingedges.png[/img] Anyone have any idea where I should start looking? It definitely negatively affects the final image quality. I do use normal map and specular map sampling in my Gbuffer Shader, if that makes a difference. I can post code as well, just don't want to explode this thread with unnecessary code for my various .fx / c# code. Note: This is using a single directional light that does not cast shadows, but does read normals/spec.
  13. Hi, I am having an issue that probably has something to do with my understanding of inheritance, and I've been wrestling with it for hours, but can't find that simple "thing" that is causing the problem. The issue is simple, really: A method is operating differently when called explicitly than when it is called from a base array, even though I can see the proper overridden method is getting called in both situations. I have the following class structure - WorldObject->GameObject->SkeletalObject->Player and NPC (2 classes) I track all of my drawables in a List of GameObjects. I draw to my gbuffer by iterating through each of the objects (including NPCs and Players) and calling their Draw() method. This works great! Both players and NPCs are using the SkeletalObject Draw() method and all skeletal animations draw to the screen properly. The problem is in a secondary draw method, StandardDraw(), that I use to draw models with custom effects (in this case shadows). It is NOT working on Player objects when called from the GameObject list, but IS working when called explicitly, while it works properly from the list for NPCs. The issue I see is my Player sporadically (rarely) at the incorrect world position in Tpose. Now, the crazy thing is, I can SEE that the correct StandardDraw method (from SkeletalObject) is being called both from the GameObject array and explicitly, and when steeping through it the variables look the same. Please help me figure out what is going on Custom Effect Draw Method - Inside SkeletalObject base class. This is NOT working for my Player objects when called from a base class (GameObject) array, but does work for my NPC objects within that same array. [source lang="csharp"]public override void StandardDraw(ref GraphicsDevice graphics, ref Effect effect) { Matrix[] boneTransforms = null; if (skinnedPlayer != null) boneTransforms = skinnedPlayer.GetSkinTransforms(); Matrix rootTransform = Matrix.Identity; if (skinnedRootPlayer != null) rootTransform = skinnedRootPlayer.GetCurrentTransform(); effect.CurrentTechnique = effect.Techniques["Skinned"]; foreach (ModelMesh mesh in Model.Meshes) { if (mesh.Name != "CollisionMesh") { //Draw Each ModelMeshPart foreach (ModelMeshPart part in mesh.MeshParts) { if (boneTransforms != null) SetBoneTransforms(boneTransforms, effect); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); //Set Vertex Buffer graphics.SetVertexBuffer(part.VertexBuffer, part.VertexOffset); //Set Index Buffer graphics.Indices = part.IndexBuffer; effect.Parameters["World"].SetValue(Matrix.CreateTranslation(-offset) * rootTransform * worldMatrix); graphics.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, part.NumVertices, part.StartIndex, part.PrimitiveCount); } } } } }[/source] Draw method - Inside SkeletalObject base class. This works properly when called from a GameObject array for both NPC and Player) [source lang="csharp"]public override void Draw(Matrix viewerView, Matrix viewerProjection, float farClip) { Matrix[] boneTransforms = null; if (skinnedPlayer != null) boneTransforms = skinnedPlayer.GetSkinTransforms(); Matrix rootTransform = Matrix.Identity; if (skinnedRootPlayer != null) rootTransform = skinnedRootPlayer.GetCurrentTransform(); foreach (ModelMesh mesh in Model.Meshes) { if (mesh.Name != "CollisionMesh") { for (int i = 0; i < mesh.Effects.Count; i++)// (Effect effect in mesh.Effects) { //Console.WriteLine(mesh.Effects[i].Name); mesh.Effects[i].CurrentTechnique = mesh.Effects[i].Techniques["Skinned"]; mesh.Effects[i].Parameters["farClip"].SetValue(farClip); mesh.Effects[i].Parameters["View"].SetValue(viewerView); mesh.Effects[i].Parameters["Projection"].SetValue(viewerProjection); if (boneTransforms != null) SetBoneTransforms(boneTransforms, mesh.Effects[i]); mesh.Effects[i].Parameters["World"].SetValue(Matrix.CreateTranslation(-offset) * rootTransform * worldMatrix); //effect.World = Matrix.CreateTranslation(-offset) * rootTransform * worldMatrix ; //effect.SpecularColor = Vector3.Zero; } mesh.Draw(); } } }[/source] Calling method [source lang="csharp"] public void StandardDraw(GameTime gameTime, ref Effect effect) { terrain.StandardDraw(ref graphics, ref effect); foreach (GameObject gameObject in gameObjects) { if (gameObject is Player) gameObject.isDrawable = true; if (gameObject.isDrawable) gameObject.StandardDraw(ref graphics, ref effect); } Player1.StandardDraw(ref graphics, ref effect); }[/source]
  14. So I updated the code to use linear interpolation and am using the green channel as Luma (to be safe in case I am setting Luma incorrectly), but I'm not certain things are working correctly. Below is an image of what it looks like, as well as my new shader code. Note that I am using above average quality settings and still seeing obvious aliasing: [img]http://i573.photobucket.com/albums/ss178/trock3155/Aliasing3.png[/img] [CODE] uniform extern float SCREEN_WIDTH; uniform extern float SCREEN_HEIGHT; uniform extern texture gScreenTexture; sampler screenSampler = sampler_state { Texture = <gScreenTexture>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = Clamp; AddressV = Clamp; }; #define FXAA_PC 1 #define FXAA_QUALITY__PRESET 23 #define FXAA_GREEN_AS_LUMA 1 #if SHADER_MODEL >= 0x400 #if SHADER_MODEL >= 0x500 #define FXAA_HLSL_5 1 #else #define FXAA_HLSL_4 1 #endif #elif SHADER_MODEL <= 0x300 #define FXAA_HLSL_3 1 #endif #include "Fxaa3_11.h" //Texture2D Texture; SamplerState TextureSampler; cbuffer cb0 { float4 _rcpFrame; float4 _rcpFrameOpt; }; //Vertex Input Structure struct VSI { float3 Position : POSITION0; float2 UV : TEXCOORD0; }; struct FxaaVS_Output { float4 Pos : SV_POSITION; float2 Tex : TEXCOORD0; }; FxaaVS_Output FxaaVS(uint id : SV_VertexID) { FxaaVS_Output Output; Output.Tex = float2((id << 1) & 2, id & 2); Output.Pos = float4(Output.Tex * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f); return Output; } sampler Texture : register(s0); struct PS_OUTPUT { float4 c : COLOR; }; float4 PS(FxaaVS_Output input) : COLOR0 { float pixelWidth = (1 / SCREEN_WIDTH); float pixelHeight = (1 / SCREEN_HEIGHT); float2 pixelCenter = float2(input.Tex.x, input.Tex.y); float4 fxaaConsolePosPos = float4(input.Tex.x - .5f, input.Tex.y - .5f, input.Tex.x + .5f, input.Tex.y + .5f); //FxaaTex = //return float4(0,1,0,1); return FxaaPixelShader( pixelCenter, input.Pos, screenSampler, screenSampler, screenSampler, float2(1.0f/SCREEN_WIDTH, 1.0f/SCREEN_HEIGHT), float4(2.0 / SCREEN_WIDTH, 2.0 / SCREEN_HEIGHT, .5 / SCREEN_WIDTH, .5 / SCREEN_HEIGHT), float4(0,0,0,0), float4(0,0,0,0), 1.0f, .063f, .0833f, 8.0f, .125f, .05f, float4(0,0,0,0)); } //Technique technique Default { pass p0 { PixelShader = compile ps_3_0 PS(); //VertexShader = compile vs_3_0 VS(); } } [/CODE]
  15. I know all of that is probably pretty hard to read, but I can't even go back and edit my posts, so I apologize. I guess something in my initial topic broke the forums. I'll let the admins know.