• 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.

mr_malee

Members
  • Content count

    59
  • Joined

  • Last visited

Community Reputation

185 Neutral

About mr_malee

  • Rank
    Member
  1. I got it working. Thanks again for the help int GetLevelForXP(int xp) { float baseXP = 100; float a = baseXP / 2f; float b = Mathf.Sqrt(a * a + 4 * a * xp) / a; float c = b / 2f; int level = Mathf.CeilToInt(c); //because of rounding issues the level returned might be higher. So check and reduce if necessary //the XP at the level returned should always be <= to the input level while (GetXPForLevel(level) > xp) { level--; } return level; }
  2. Really appreciate the help, I must be stupid, but how did you get 15 out of that equation? I get 750 float a = 50; float b = Mathf.Sqrt(50 * 50 + 4 * 50 * 10500); //1450 float c = (a + b) / 2; //750
  3. Hi, so I've got a function that gives me a XP for a given level. I'm looking at finding the inverse: (Level from XP) e.g: int GetXPForLevel(int level) { float baseXP = 100; float xp = (Mathf.Pow(level, 2) + level) / 2 * baseXP - (level * baseXP); return Mathf.FloorToInt(xp); } int GetLevelForXP(int xp) { //need the inverse of the above function return 0; } My Math skills are not great :(, not sure where to even begin
  4. Hi, I'm trying to project a 3D camera's view onto a plane. I currently have this working by:   1. Find normalized viewport position (-1 to 1) 2. Project this coordinate into 3d using the inverse of the cameras View and Projection matrices 3. Find the direction of this coordinate relative to the camera view 4. Find intersection of this direction onto plane.   I'm doing this inside a shader but wondering if I could simplify it by constructing some sort of matrix that finds the plane intersection for a normalized viewpoint. Not sure if that's even possible. Here's a picture that might better explain:     What I currently have: float4 unproject(float x, float y, float z) { // unproject the point // _ProjMatrix is the inverse of a cameras view and projection matrices // _ProjMatrix = inverse(cam.projectionMatrix * cam.viewMatrix) float4 pos = mul(_ProjMatrix, float4(x, y, z, 1)); return pos * (1.0 / pos.w); } v2f vert (appdata v) { v2f o; //convert the mesh vertex into local viewport space float4 vp = v.vertex; float x = vp.x / _Size; float y = vp.z / _Size; //unproject into the near and far clipping planes of the camera float4 p1 = unproject(x, y, -1); float4 p2 = unproject(x, y, 1); //find the direction of this viewport point float4 dir = normalize(p2 - p1); //project this viewport direction onto the world plane float distanceOfVertex = mul(_WorldMatrix, p1.xyz).y; float lengthOfLightDirectionInY = mul(_WorldMatrix, dir.xyz).y; dir = dir * (distanceOfVertex / -lengthOfLightDirectionInY); //output vertex o.vertex = mul(UNITY_MATRIX_VP, p1 + dir); } As you can see there's lots of multiplication here. First I have to find the near and far projections, find the normal between them, find the projection of that normal on the plane. Wondering if this could be simplified if I could just take that viewport position and multiply by the camera projection and view + some plane intersection matrix.
  5. Ok thanks. I have no idea what a polynomial is, but I'm going to do some reading.   so let's say   t = 3, start position = 0,0, end position = 10,5 gravity: -9.81 drag: 0.5
  6. Hi, I'm having a very difficult time figuring out how to find the velocity needed to reach a point for a projectile (shot from a cannon) to reach a point with air resistance.   time step is constant: 0.02 air resistance is constant: 1 / (1 + 0.02 * drag), where drag is a constant: 2 gravity is constant: -9.81 initial velocity is: 7, 20 mass is constant: 1   integration is like so:   velocity += gravity * 0.02 velocity *= airResistance position += velocity * 0.02   I'm not much of a math guy, any help would be greatly appreciated :)
  7. Thanks :) yeah this shader is for a specific sized texture
  8. You are a life saver. I finally got it working. I didn't realize that making a reference to bounds[0] was copying it to a new variable!   If I use bounds[0] in the InterlockedMin function, it saves my data :D   final working code: #pragma kernel CSMain struct Bound { uint minX; uint minY; uint maxX; uint maxY; }; Texture2D<float4> tex; RWStructuredBuffer<Bound> bounds : register(u0); [numthreads(8, 8, 1)] void CSMain (uint2 pos : SV_DispatchThreadID) { float4 color = tex[pos]; if (color.r == 0 && color.g == 0 && color.b == 0) { InterlockedMin(bounds[0].minX, pos.x); InterlockedMax(bounds[0].maxX, pos.x); InterlockedMin(bounds[0].minY, pos.y); InterlockedMax(bounds[0].maxY, pos.y); } } Thanks again
  9. Ok thanks. So what's happening is multiple threads are accessing the bounds[0] and modifying that value in random order?   You mentioned atomic computations. I've tried implementing the InterlockedMin on a groupshared object without success: groupshared Bound boundary[1]; [numthreads(8, 8, 1)] void CSMain (uint2 pos : SV_DispatchThreadID) { Bound b = boundary[0]; InterlockedMin(b.minX, (float)pos.x); } But I just get this error:   "interlocked targets must be groupshared or UAV"   How do you define a group shared object?
  10. This works, but is really really really slow. 5fps [numthreads(1, 1, 1)] void CSMain (uint2 id : SV_DispatchThreadID) { uint w, h; tex.GetDimensions(w, h); uint2 pos; Bound b = bounds[0]; for (pos.x = 0; pos.x < w; pos.x++) { for (pos.y = 0; pos.y < h; pos.y++) { float4 color = tex[pos]; if (color.r == 0 && color.g == 0 && color.b == 0) { b.minX = min(b.minX, pos.x); b.minY = min(b.minY, pos.y); b.maxX = max(b.maxX, pos.x); b.maxY = max(b.maxY, pos.y); } } } bounds[0] = b; } How can I translate that into a threaded version without loops?
  11. Hi, I'm trying to create a Compute Shader that looks at a texture and finds the bounds of all black pixels in that texture.   Like in this image:     I'm new to the whole concept of compute shaders, and struggling with this. Especially with threads and thread groups.   My initial attempt was to create a RWStructuredBuffer that contains 1 element, this element is a custom struct containing 4 floats: (minX, maxX, minY, maxY). The image is 512x512. I thought I could just get the thread position, color of the pixel at this position and compare with that in the buffer using min/max functions. This does not work. And I don't have any idea why. Here's my simple shader: #pragma kernel CSMain //custom struct to hold the bounds info struct Bound { float minX; float minY; float maxX; float maxY; }; Texture2D<float4> tex; RWStructuredBuffer<Bound> bounds : register(u0); //thread groups, not sure how many I need? [numthreads(1, 1, 1)] void CSMain (uint2 id : SV_DispatchThreadID) { //find the color at this position, image is 512x512 float4 color = tex[id]; //test if the color is black, if so, process if (color.r == 0 && color.g == 0 && color.b == 0) { //get the Bound object, there should only be 1 //compare the positions stored in this object with the current pixel position (id) Bound b = bounds[0]; b.minX = min(b.minX, id.x); b.minY = min(b.minY, id.y); b.maxX = max(b.maxX, id.x); b.maxY = max(b.maxY, id.y); //assign the Bound object back to the buffer so we can compare it later on, and also grab this data outside of the shader. bounds[0] = b; } } What happens is the result I get is very jittery, the bounds are jumping around and numbers are never the same, which is strange because the image is static.   From all the examples I've seen, the size of RWStructuredBuffer has some relationship with the thread count. However, I don't want this / know how I could use a buffer with that size. I need to be able to get data out of the shader telling my the min/max coordinates. If I have a buffer that's larger than 1 in size, how can I get these coordinates out?
  12. Match 3 game. I'd like certain types of "tiles" or "gems" to be selected more frequently.
  13. Thanks, turns out I'm looking for a "weighted random" function.   http://stackoverflow.com/questions/1761626/weighted-random-numbers
  14. Hi, I'd like to pick a value from an array which is sorted using a priority value, 0-100.   However, I'm looking for a way that returns a value in the array with a higher priority more frequently. Say my array has 5 values:   [100, 50, 10, 3, 1]   I would like the value "100" to be returned more often than "50". The value of "1" should rarely be chosen.   Two ways I think I can solve it, but not exactly ideal or efficient:   1. Put more of the higher priority values in the array: [100, 100, 100, 100, 100, 50, 50, 50, 50, 10, 10, 10, 3, 3, 1] 2. Multiply a random number (t) by a curve: http://easings.net/#easeInQuint and use that as the index (x).   Just wondering if there's a better way?   Thanks
  15. ah Thanks. Here's what I ended up with if (index == 0) { return 1; } int v = (index - 1) / 4; int n = (index - 1) % 4; int m = (int)Mathf.Pow(60, v); if (n == 0) { return 5 * m; } else if (n == 1) { return 10 * m; } else if (n == 2) { return 30 * m; } else if (n == 3) { return 60 * m; }