• 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.
Sign in to follow this  
Followers 0
football94

Unity
Ray Pixel collision

4 posts in this topic

Hi guys

 

Ive been working on a project involving  ray  collision  with a multitextured terrain(2D heightmap)  the ray method(below) not only returns the triangle intersected but the uv(barycentric) coordinates as well but during research for my project I came across  a post from the unity website(link below) that had to do with  ray pixel intersection and wondered if I should implement that instead, so the question that Im asking is which of the two is better. should I stick with the ray uv coordinate method or go with an XNA version of the ray pixel collision.

 

                                              Thankyou

 

 

 

 

 

 

 

unity ray pixel post

 

http://forum.unity3d.com/threads/131062-Terrain-and-footsteps

 

 

 

 

 

 

 

 the intersect method Ive been working with

public   bool RayTriangleIntersect(Vector3 ray_origin, Vector3 ray_direction,
                    Vector3 vert0, Vector3 vert1, Vector3 vert2,
                    out float? t, out float u, out float v)
        {
            t = 0; u = 0;  v = 0;
 

            Vector3 edge1 = vert1 - vert0;
            Vector3 edge2 = vert2 - vert0;

            Vector3 tvec, pvec, qvec;
            float det, inv_det;

            pvec = Vector3.Cross(ray_direction, edge2);

            det = Vector3.Dot(edge1, pvec);

            if (det > -0.00001f)
                return false;

            inv_det = 1.0f / det;

            tvec = ray_origin - vert0;

            u = Vector3.Dot(tvec, pvec) * inv_det;
            if (u < -0.001f || u > 1.001f)
                return false;

            qvec = Vector3.Cross(tvec, edge1);

            v = Vector3.Dot(ray_direction, qvec) * inv_det;
            if (v < -0.001f || u + v > 1.001f)
                return false;

            t = Vector3.Dot(edge2, qvec) * inv_det;

            if (t <= 0)
                return false;

         





            return true;
        }

also a youtube link to a project called rigs of rods to give a visual of the effect Im working on,

which is to have  a vehicle shoot out certain particles(dirt debris,grass debris,etc,..) based on

the texture its riding over.

 

 

http://www.youtube.com/watch?v=ajFe53pjaDs

 

 

 

 

0

Share this post


Link to post
Share on other sites

yet another option:

 

the pickray example in the directx sdk's. 

 

its probably the one that XNA's is based off of.

 

is it necessary to cast a ray?  there's no other way to know what texture is at location x,z  (the vehicle's location)? i take it the ground mesh is just a big textured mesh, with no underlying map, and you only have the artwork geometry to work with?

0

Share this post


Link to post
Share on other sites


i take it the ground mesh is just a big textured mesh, with no underlying map, and you only have the artwork geometry to work with?

 

 

Thanks for responding Norman,what would be the best type of terrain for this effect, right now Im using the shader based drawn terrain from riemers( http://www.riemers.net/eng/Tutorials/XNA/Csharp/series4.php)but would another approach do the job, like for example texture mapping(https://en.wikipedia.org/wiki/Texture_mapping),and what type of map do you think was used in this other youtube link below.

 

 

ultimate ninja storm

 

 

http://www.youtube.com/watch?v=azBWIT2d36Y

 

 

 

Thanks again

0

Share this post


Link to post
Share on other sites

right now Im using the shader based drawn terrain from riemers( http://www.riemers.net/eng/Tutorials/XNA/Csharp/series4.php)

 

a quick look at that link reveals that they are procedurally creating a large ground mesh, using a bitmap as the heightmap. and they are using the height at a given location to determine the blending weights of 4 textures they use, blending at most two together at once.

 

you would use a function similar to the one that maps height to blending weights, to map height to the closest single texture (the texture with the highest weight). that texture would determine the particle type to be emitted (mud, dust, gravel, etc). in border cases where the weights were equal, you'd choose some convention such as always going with the texture used for the "higher" altitude.

 

a function that maps from location to height to texture to particle type would get you just what you want: a function that maps from location to particle type based on underlying texture.

 

your heightmap function already does the location to height mapping.

 

you already know what texture you want to map to what kind of particle.

 

all you have to do is mod a copy of "height to blend weights" to create your "height to texture" function.

 

 

 

 


what would be the best type of terrain for this effect,

 

i don't quite follow....

 

do you mean the best type of terrain data structure?

 

in your case, the data structure is a bitmap heightmap, from which a ground mesh is procedurally generated, and from which texture blend weights are procedurally generated (on the fly apparently).

 

the downside of texture blend weights procedurally generated from a bitmap height map (on the fly) is that you have no "map" where you can just look up the texture at x,z and immediately create the appropriate type of particle emitter.. you must calculate the texture at x,z (on the fly) every time.   the workaround (if needed) is to implement an underlying map that you generate when you generate the mesh. in the underlying map, you calculate (one time only) and store the texture (and thus particle type emitted) at each location. 

 

an underlying map might take the form of a 2d array of bytes, with values of 0 through 3 indicating which texture is dominant (heaviest blend weight) and therefore which particle type to emit. the look-up function would do something like take x,z and convert them to ints, then used those int values as the array[x][z] indices to return a texture/particle type ID number 0 through 3. note that such a look-up table/map could get large. a 100x100 mesh would use an underlying map of 100x100 = 10,000 bytes. 

a 1000x1000 mesh would be 1 million bytes. and a 10,000x10,000 mesh would be 100 million bytes for the underlying map.

 

i personally use a "pattern map" to determine what ground texture goes where. a pattern map is just a small underlying map as described above. the difference is that a pattern map is only two times maximum visual range in size, instead of the size of the entire ground mesh, and gets repeatedly tiled across the ground mesh. the size is chosen to be as small as possible (to save ram), while being big enough that no repeating patterns due to tiling are ever visible from the camera's location while looking in all directions. my ground quads are 10x10, and my ground texture pattern map is 800x800. so the ground texture tile ID pattern map covers 80x80 quads, and only requires an 80x80= 6400 byte array. i use a single ground texture tile ID pattern map for all terrain types. i use 4 other pattern maps to place things like rocks, trees, berry bushes, fruit trees, and rock outcroppings. values in the ground texture pattern map are a simple ground texture tile set ID number 0 through 3. there are seamless ground texture tile sets (currently 4 tiles per set) for each terrain type. terrain type from the world map tells me the ground texture tile set used. the pattern map tells me which ground texture in the tile set is used at a given x,z location.

 

a pattern map lets you use seamless ground texture tile sets to reduce moire' patterns which you can get with just a single seamless ground texture tile (as seen in oblivion with distant ground textures). 

 

texture blending / splatting is another way to reduce or eliminate moire' patterns.

 

 

 


would another approach do the job, like for example texture mapping(https://en.wikipedia.org/wiki/Texture_mapping),

 

weighted texture blending (what you're doing) is already an advanced form of texture mapping. plain old texture mapping would just draw a single texture, not do a weighted blending of two textures.

 

 

 


what type of map do you think was used in this other youtube link below.

 

unfortunately, i'm on a 3g cell modem out in the boonies with marginal signal (1xrtt protocol usually - think dialup + intermittent signal loss), so streaming video isn't really happening for me.   : (

 

it drives me crazy, as i've become addicted to Korean historical dramas like "Faith" and "Iron Empress" on hulu.com.    <g>

Edited by Norman Barrows
0

Share this post


Link to post
Share on other sites

THANKS A BUNCH NORMAN !!!

 

I was just about to give up on the heightmap idea and before reading your response  I  wrote a post about using a textured quad for a terrain instead(below), sorry about that, didnt want to come across as ungrateful for all of the help youve given me,but I will be putting the info you gave me to good use.

 

 

           http://www.gamedev.net/topic/646055-multitextured-quad-terrain/

 

 

                                                   Thanks again laugh.png

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By ilovegames
      Are you ready to become the best truck driver?
      If the answer is yes then this game is for you!
      Various loads of cargo need to be delivered safely. Be careful or things might get broken.
      Your driving skills and accuracy will be tested in practice.
      Get in your truck and go!
      TruckDriverSteepRoadSetup.exe
    • By ilovegames
      OffRoad4x4: Max Speed

      If you passionately adore speed and cars, and most of all dream about tearing around in a large and powerful jeep, this game was made for you. First locate the finish line on the map to complete the level. Map or no map, you have to navigate the terrain like a pro. But you aren’t limited to performing tasks in the game as you are free to explore the area just enjoying the machine and the beautiful scenery.

       
       
      OffRoad4x4MaxSpeedSetup.exe
    • By TeoMakao
      Hello there!
      I am Theo and I am looking for an evil minion/partner in crime to help me with making games. Currently I am working on my first "official" game, which is point&click 2D adventure in Unity with Fungus extension, and I will need some help with that. More about the project and future goals in private.
      I need somebody who:
      - First and foremost is interested in making games, but since you are on this forum... yeah.
      - Is a 2D artist(amateur will do, but must be willing to improve)
      - Has at least some grasp around Unity(or is willing to learn)
      - Has at least some grasp around Fungus extension for Unity(or is willing to learn)
      - Is interested in talking about various concepts of imaginary worlds/characters(I need somebody to help me developing my universe and talking to myself proves inefficient)
      And optionally:
      - Is interested in fantasy worlds
      - Is interested in mythology
      - Is interested in sci-fi worlds
      - Is interested in talking about interesting ideas, even if they are completly abstract
      I am offering up to 50% of any profit made, depending on how engaged you'll be.
      This is the first time I am looking for someone to work with me by forums, so if I chose wrong place to announce I am sorry.
      If you are interested in working with me - feel free to PM.
      I do not expect you to sacrifice all the time for the project. For now it's pretty lightweighted.
    • By RobbyT15
      I'm a front end web developer trying to get into game development and I was hoping that someone has a project they would like some assistance on.  I've mostly done tutorials in Unity and made a couple games, roll-a-ball, space shooter, but would like to get more experience.  If anyone is willing to give me a chance, please reply to this message or shoot me an email at robbyt15@bmail.com.
    • By dhanrajsinh24
      I've recently made Fidget Spinner Unity Template which is available in most online stores. Buy and learn 2D game development with it or make your own reskin of the game.
      https://www.gamegorillaz.com/index.php/catalog/product/view/id/2779/s/fidget-spinner-unity-template/
      https://www.codester.com/items/4439/fidget-spinner-unity-template
  • Popular Now