Jump to content
  • Advertisement

Doggolainen

Member
  • Content Count

    41
  • Joined

  • Last visited

Community Reputation

115 Neutral

About Doggolainen

  • Rank
    Member

Personal Information

  • Interests
    Business
    Production
    Programming
  1. Hi, I wish to generate light map textures for objects in my scene containing ambient occlusion and global illumination. Currently I can do this in 3D Max, but it is taking too long on my single computer for this to be feasible. Does anyone know any rendering farms that supports this (light baking)? I checked "Rebusfarm" and they did not support this feature. Any help appreciated, Doggolainen
  2. Doggolainen

    Sampler not working outside pixelshader

    Thank you so much! It works now. I was so busy binding the actual samplers that I forgot to bind the textures!!! Thanks again <3
  3. Hello, I am, like many others before me, making a displacement map tesselator. I want render some terrain using a quad, a texture containing heightdata and the geometryshader/tesselator. So far, Ive managed the utilize the texture on the pixelshader (I return different colors depending on the height). I have also managed to tesselate my surface, i.e. subdivided my quad into lots of triangles . What doesnt work however is the sampling step on the domain shader. I want to offset the vertices using the heightmap. I tried calling the same function "textureMap.Sample(textureSampler, texcoord)" as on the pixelshader but got compiling errors. Instead I am now using the "SampleLevel" function to use the 0 mipmap version of the input texture. But yeah non of this seem to be working. I wont get anything except [0, 0, 0, 0] from my sampler. Below is some code: The working pixelshader, the broken domain shader where I want to sample, and the instanciations of the samplerstates on the CPU side. Been stuck on this for a while! Any help would be much appreciated! Texture2D textureMap: register(t0); SamplerState textureSampler : register(s0); //Pixel shader float4 PS(PS_IN input) : SV_TARGET { float4 textureColor = textureMap.Sample(textureSampler, input.texcoord); return textureColor; } GS_IN DS(HS_CONSTANT_DATA input, float3 uvwCoord : SV_DomainLocation, const OutputPatch<DS_IN, 3> patch) { GS_IN output; float2 texcoord = uvwCoord.x * patch[0].texcoord.xy + uvwCoord.y * patch[1].texcoord.xy + uvwCoord.z * patch[2].texcoord.xy; float4 textureColor = textureMap.SampleLevel(textureSampler, texcoord.xy, 0); //fill and return output.... } //Sampler SharpDX.Direct3D11.SamplerStateDescription samplerDescription; samplerDescription = SharpDX.Direct3D11.SamplerStateDescription.Default(); samplerDescription.Filter = SharpDX.Direct3D11.Filter.MinMagMipLinear; samplerDescription.AddressU = SharpDX.Direct3D11.TextureAddressMode.Wrap; samplerDescription.AddressV = SharpDX.Direct3D11.TextureAddressMode.Wrap; this.samplerStateTextures = new SharpDX.Direct3D11.SamplerState(d3dDevice, samplerDescription); d3dDeviceContext.PixelShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.VertexShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.HullShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.DomainShader.SetSampler(0, samplerStateTextures); d3dDeviceContext.GeometryShader.SetSampler(0, samplerStateTextures);
  4. Doggolainen

    Arena - Debut Trailer

    Here is the first trailer for a game we've been doing.
  5. Im working on a 2D fighting/platformer game. As it is now it works fine, I handle movement by adding vectors to a Velocity vector. [source lang="csharp"]Velocity += v;[/source] Then at the end of each frame, where elapsedTime is the time elapsed since previous frame. [source lang="csharp"]Velocity += gravity; //Apply gravity Position += Velocity * elapsedTime; //Move the object Velocity *= 0.8f; //Friction[/source] Now to the problem: My above functionallity only works accurate if the game is running at 60 fps since the friction multiplication is not time varying, but a constant. Ive tried where I divide the elapsedTime by the target fps. [source lang="csharp"]Velocity *= 0.8f/0.016f * elapsedTime;[/source] I think I have to use Math.Pow() for this to work, but I cant get my head around it.
  6. Im making a ray or a "laser" for my game using GL_LINES. I want the laser to have a strong clear light in the middle and to get more and more transparent at the edges. For this I want to do a point - line distance calculation in the fragment shader. To my vertex shader I send, vertices for the laser, a directional vector for each vertex and also the modelview matrix. I wish to make something similar to this (see quote/link below), but I cant get the calculations for gEndpoints[2] and gPosition (gl_FragCoord?) correct. I wish to translate my vertex coordinates into the same coordinate space as the gl_FragCoord. I've tried numerous variations by googling the problem and some bruteforce matrix multiplications but I just cant get it right. Any help would be greatly appreciated. Glow With Point-Line Distance Here’s my fragment shader for Tron-like glow. For this to link properly, the geometry shader needs to output some screen-space coordinates for the nodes in the line strip (gEndpoints[2] and gPosition). The fragment shader simply computes a point-line distance, using the result for the pixel’s intensity. It’s actually computing distance as “point-to-segment” rather than “point-to-infinite-line”. If you prefer the latter, you might be able to make an optimization by moving the distance computation up into the geometry shader. [size=1][size=1] uniform vec4 Color; varying vec2 gEndpoints[2]; varying vec2 gPosition; uniform float Radius; uniform mat4 Projection; // Return distance from point 'p' to line segment 'a b': float line_distance(vec2 p, vec2 a, vec2 b) { float dist = distance(a,b); vec2 v = normalize(b-a); float t = dot(v,p-a); vec2 spinePoint; if (t > dist) spinePoint = b; else if (t > 0.0) spinePoint = a + t*v; else spinePoint = a; return distance(p,spinePoint); } void main() { float d = line_distance(gPosition, gEndpoints[0], gEndpoints[1]); gl_FragColor = vec4(vec3(1.0 - 12.0 * d), 1.0); } [/quote] http://prideout.net/blog/?p=61 - link to the page
  7. Doggolainen

    Circle to 2D-array

    I want to remove the overlap between a 2D-array containing a circle and another 2D-array containing alpha values of a pictures. (Think an explosion in liero or worms) But my problem is creating the circle 2D-array from a given radius. I've been looking into the midpoint circle algorithm a little bit, but I cant find any good hits on filled circles. int[,] CreateCircle(float radius) { //return a int matrix where 1 is a pixel part of the circle and 0 is outside the circle }
  8. Doggolainen

    Generic dynamic call in C#

    I want my components to be loosely coupled. I havent figured out a way yet to use Delegates/Events to get the result that I'm aiming for. http://devlicio.us/b...aggregator.aspx My system is/will be very similar to the things described in the article above. [/quote] Events are about as loosely coupled as you can get. The problem is that we don't understand what your end goal is. So what is your end goal? [/quote] Well the article pretty much sums up what I'm trying to implement. I'm making an Entity system for my game, where components can send messages independently without knowing who is listening on the other side (sounds like events, yes). But I dont want any of the components to hold the event itself, I want that the Entity class (which is a container for the components) to be in controll and contain all of the events. But to avoid reusage of code where the compoentents have to subscribe/unsubscribe on an event their selves, I just want to let a component implement an interface with the message/messages their interessted of and let the engine call them accordingly whenever the message is fired. Again, look at the article, thats what triggered me into doing this.
  9. Doggolainen

    Generic dynamic call in C#

    I wouldn't use inheritance here, but whatever. [/quote] I meant implementation IMessage is an interface. There's not enough code here to really figure out what you're doing. But as soon as you start checking types, it's a code smell. Personally I'd look into simply having a dictionary of delegates (remember, delegates are multicast) and simply adding/removing entries from that. [/quote] Well I use the type checking in very primitve functions that wont affect the end user.
  10. Doggolainen

    Generic dynamic call in C#

    I want my components to be loosely coupled. I havent figured out a way yet to use Delegates/Events to get the result that I'm aiming for. http://devlicio.us/b...aggregator.aspx My system is/will be very similar to the things described in the article above.
  11. I'm implementing a message system for my entity/component system. What I do is basicly let components implement a IMessageHandle<T> where T is IMessage. Then I inherit from IMessage for diffrent types of messages. For instance DrawMessage extends IMessage. The following code works and is in the Entity class. It calls all the added components that implements the IMessageHandle for the given IMessage. public void FireMessage<T>(IMessage message) where T : IMessage { List<Component> receivers = messageTable[typeof(IMessageHandle<T>)]; foreach (Component c in receivers) CallMethod(c, "Handle", message); } I use a hashtable/dictionary and C# magic for optimizing the call. public void AddComponent(Component component) { components.Add(component.GetType(), component); Type[] types = component.GetType().GetInterfaces(); foreach (Type t in types) { //if (!t.IsAssignableFrom(typeof(IMessageHandle<IMessage>))) // continue; if (!messageTable.ContainsKey(t)) messageTable[t] = new List<Component>(); messageTable[t].Add(component); } What I want to do instead is something like this: public void FireMessage(IMessage message) { Type t = message.GetType(); List<Component> receivers = messageTable[typeof(IMessageHandle<t>)]; foreach (Component c in receivers) CallMethod(c, "Handle", message); } But my C# reflection skills are to weak for me to figure it out. Anyone got any advice on how to implement this, cause it would really make my code feel more clean and easier to use! //Doggolainen
  12. Doggolainen

    Vector rotation and mirroring

    I'm making this 2D game where I want several textures move accordingly to another texture. So right now I got this body where the head has to rotate around an axis accordingly to the body when the body rotates. The following code does the trick: Vector2 spatialPosition; //The global position Vector2 origin; // Origin relative the position Vector2 position; //Local position of the texture to draw i.e. the heads position relative the body. Vector2 bodyPosition; //The local position of the body Vector2 bodyOrigin; //origin of the body relative the bodyPosition public void Draw(SpriteBatch spriteBatch, bool mirror, Camera camera, Vector2 spatialPosition,Vector2 bodyPosition, Vector2 bodyOrigin, float bodyRotation) { Vector2 positionOffset = RotateAroundPoint(position, bodyOrigin, bodyRotation); if (!mirror) { spriteBatch.Draw(texture, positionOffset + spatialPosition - camera.Position, null, Color.White, rotation + bodyRotation, origin, 1, SpriteEffects.None, 0); } } As mentioned earlier - the code seen above works correctly. I do however want to mirror the image depending wheter the character is facing right or left, this code on the other hand does not work. It only works if the body is not rotated. The hardcoded "100" is the width of the body texture. else { spriteBatch.Draw(texture, new Vector2(100 - positionOffset.X - texture.Width + origin.X * 2, positionOffset.Y) + spatialPosition - camera.Position, null, Color.White, -rotation - bodyRotation, origin, 1, SpriteEffects.FlipHorizontally, 0); } So anyone good at algebra out there, please help me solve this nut.
  13. Well, since all my high-level logic is handled in Lua rather than C++, it's not really an issue. I just populate a table and pass that as the arguments for the message. [/quote] Ive made some progress in my "engine" which I nowadays call a game. I've decided to make a few games and then take parts out of them to make an engine (thanks to this forum Ive realized it was a better approach for me). Anyhow, I've got my self a world divided into tiles. Think of it as and old-school top-view game, where an entity only can move between tiles. I've got query functions in my gameworld such as "GetEntititiesAt(Coordinate position)" which would return all the entities stored in a tile at that position. But how am I suppose to handle return parameters using my message systems? I'm thinking of implementing some kind of broadcast system. So that if a component needs to know of its surroundings, I let them subsrcibe on the "GetSurroundings" message. And then let the gameworld/someComponent fire that message each frame to let every subrscriber know of their surrounding. Either that or some kind of callback function, so that when an entity asks for its surroundings, they could pass a reference to a list or something which will be filled. This is the first problem of this type Ive ran into so far, and I expect to see more of it, so I want to have a method of dealing with it asap. My question in short terms: Do you have messages that also returns stuff? If yes: How do you handle if several objects would subscribe on the same message? If no: How do you do it? //Doggolainen Edit: @JJTippets: A quote from your blog that pretty much hits spot on what this topic is about. http://www.gamedev.net/blog/33/entry-2249433-how-goblinson-crusoe-works-the-tldr-version/ [color=#1C2837][size=2]There is also a function,[color=#1C2837][size=2] [color=#1C2837][size=2]handleRequest()[color=#1C2837][size=2], which acts similarly to[color=#1C2837][size=2]handleMessage()[color=#1C2837][size=2], but which will return a list of results. This is used for queries, and I am unsure on whether or not it is actually needed, as I haven't really used it much.[color=#1C2837][size=2] [/quote]
  14. Ive got this message system up and running in between the components in my game-engine. Ive just started to implement Lua and I've run into a problem. When I try to pass arguments from the lua file to a function in C# that takes arbitrary parameters, using the "params" keyword, I get the following exception: "Invalid arguments to method call" I tell the Lua which function to call. lua.RegisterFunction("FireMessage", this, this.GetType().GetMethod("FireMessage")); This is what the function looks like. public void FireMessage(String messageName, params object[] parameters) { if (messages.ContainsKey(messageName)) { foreach (KeyValuePair<Component, String> e in messages[messageName]) CallMethod(e.Key, e.Value, parameters); } } This is what I do in my .lua file. luanet.load_assembly("LuaWorld"); Vector2D = luanet.import_type("LuaWorld.Vector2D"); dir = Vector2D(50.0, 50.0); FireMessage("Move", dir); How can I solve this problem and still, if possible, use params object[] as parameter type?
  15. I've been into the idea of message passing between entities in my game framework. But I always get stuck on on how to implement the argument passing correctly for the messages. I always end up with ugly typecasts on the other end (the entity that receives the message). In your case, I assume you pass some kind of float value along with the "ModifyLife" message. Could you please tell me how you would implement the receiving part of that message?
  • 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!