Is 1 pixel of a height map representative of 1 vertex on the mesh? I'm trying to get my head around heightmap terrain generation. If I have a plane say 64 x 64 verts will I need to create a 64px by 64px greyscale heightmap in order to displace the geometry of the plane correctly?


Demystifying "chunked level of detail" Just recently trying to make sense of implementing a chunked level of detail system in Unity. I'm going to be generating four mesh planes, each with a height map but I guess that isn't too important at the moment. I have a lot of questions after reading up about this technique, I hope this isn't too much to ask all in one go, but I would be extremely grateful for someone to help me make sense of this technique. 1 I can't understand at which point down the Chunked LOD pipeline that the mesh gets split into chunks. Is this during the initial mesh generation, or is there a separate algorithm which does this. 2 I understand that a Quadtree data structure is used to store the Chunked LOD data, I think i'm missing the point a bit, but Is the quadtree storing vertex and triangles data for each subdivision level? 3a How is the camera distance usually calculated. When reading up about quadtree's, Axis aligned bounding box's are mentioned a lot. In this case would each chunk have a collision bounding box to detect the camera or player is nearby? or is there a better way of doing this? (raycast maybe?) 3b Do the chunks calculate the camera distance themselves? 4 Does each chunk have the same quot resolution quot . for example at top level the mesh will be 32x32, will each subdivided node also be 32x32. Example below


What is the role of tessellation in terrain? I'm relatively new to graphically programming and I've been looking into ways to render larger heightened terrain. I keep seeing comments directing me to disregard things such as geometry clipmaps, in favor of tessellation. From what I've read however, tessellation adds inner and outer triangles between a set of vertices. So from what I understand, you would lose the 1 to 1 relationship between height points and vertices. Additionally, the new vertices would be interpolated and therefore somewhat similar looking between points of similar height. Is this the case or is there something I'm missing. Is tessellation exclusively the way to go or can it ( should it) be combined with other techniques?


Very large terrains in Unreal 4 I was watching some YouTube tutorials on making terrains in UE4 and in each one they mention that the larger the terrain the worse the performance gets. I was wondering what you would do if you wanted to create a map like in skyrim or WOW. Is the terrain made of one massive terrain or is it made up out of a series of terrains in a grid? And is there any optimisation that you can do or is it all handled by UE4?


Rendering smooth ground I'm attempting to render terrain made out of a triangle mesh. The problem is that whenever I have a northwest gt southeast ramp in the terrain, I get this diamond pattern The issue is that at the top and bottom of the ramp, the terrain is more flat than at the middle, so if the ramp is aligned with the triangles, each triangle will have two light vertices (at the top and bottom), and one dark vertex (at the middle). How can I fix this effect? Subdividing the mesh helps, but doesn't fix it completely. Vertex shader uniform mat4 projection attribute vec3 position attribute vec3 normal attribute vec4 color varying vec3 f position varying vec3 f normal varying vec4 f color void main(void) gl Position projection position f color color f normal normal f position position Fragment shader varying vec3 f position varying vec3 f normal varying vec4 f color uniform vec3 light position void main(void) float light 0.5 0.5 abs(dot(normalize(f normal), normalize(light position f position))) gl FragColor vec4(light, light, light, 1) f color


How to smooth low res sampling of noise for voxel terrain I am attempting to create a new terrain generator as part of a minecraft mod, which works very well if it samples at the full terrain resolution (16x256x16 voxels per terrain chunk). This is extremely laggy, so i attempted using a lower resolution sample, x4x64x4, with an extra one sample on each positive axis to interpolate with (5x65x5, representing 20x260x20 space). It all works fine until i try to smooth out the resulting 4x4x4 cubes of terrain. I have tried interpolating the noise value (0.0 to 2.0) of each block with the value next to it along each positive axis, each value weighted by how close the block is to it. The result has some smoothing, but some of it seems to be rotated 90 degrees, and some areas are unsmoothed. I know this is possible, minecraft does it internally (the code is illegibly obfuscated and messy, about half a page, 20 variables and 6 loops). Does anyone have any ideas about a reliable method for smoothing, only knowing the contents of the chunk and one sample to the north east top? my current noise array generator protected double getNoise(float x, float z) get a rough noisemap every 4 blocks, 1 more past the edge to round with double n new double 1625 x65x5x5 3D space in order y,x,z represents one chunk at 1 4 precision (1024 blocks plus 601 blocks padding along the positive axis sides for rounding. Minecraft uses 825 doubles internally, 5x33x5) for(int lx 0 lx lt 5 lx) for(int lz 0 lz lt 5 lz) some extra noise that controls terrain thickness along Y double m 32 (1f SimplexNoiseGenerator.getNoise( (x (lx 4)) 256, (z (lz 4)) 256) ) 32 for(int ly 0 ly lt 65 ly) n (ly 25) (lx 5) lz ( 1f SimplexNoiseGenerator.getNoise( (float)(x (lx 4)) 512f, ((float)ly 4) m, (float)(z (lz 4)) 512f ) ) (1.5f (Math.abs(32f ly) 32f) ) return n Someone posted this on stack overflow, it is exactly the same problem and seems to be unresolved. https stackoverflow.com questions 35852194 smooth lower resolution voxel noise


Query regarding a quad tree implementation for spherical terrain I am having some difficulty conceptualising how a quadtree would be used to implement a spherical terrain system. I currently have a spherical terrain system working, without any form of optimisation, I just have a vertex buffer full of every vertex in the terrain. Obviously, this can only be rendered at very low resolutions without lagging. I intend to use a Chunked Level of Detail system to speed things up, however, despite my research, I am still somewhat unsure as to how to proceed. From what I understand I need to generate several levels of detail (by essentially creating several distinct terrain files, each with a lower resolution than the last). I then load the quad tree with the data by setting each level of the quad tree to be a "level of detail", so level 1 would be the root node, encompassing everything, level 2 would contain very low resolution terrain data (in the form of a low resolution list of terrain vertices), and so on until level n, where the highest resolution data would be stored (in the form of a high resolution list of terrain vertices). This is the part I have the most trouble with, is this correct? Generating several terrain files at different resolutions, and loading each one to a separate level of the quad tree? Or should the tree be populated with vertices in a different way? I then populate the main vertex buffer by searching the quadtree's nodes, and I use the players position to decide which nodes to return. So, the nodes far away from the player will be all high level (level 1) nodes with low detail, and as the distance to the player gets closer, the search will drill deeper and deeper into the quad tree, so eventually the nodes returned will be the highest detail level possible. Is this in any way correct? My thinking on this is still quite hazy, even though I have done extensive research. Thanks for any help or advice!


Mapping noise to sphere surface I'm attempting to create a sphere with terrain (aka planet). I managed to procedurally create an icosahedron, and I am able to subdivide it (yay), but now I'm stuck on terrain. My current idea was to create a Perlin like "3D Noise Field" and sample density where each of the spheres vertices fall (as a height map value). this way i should be able to tweak the noise (add octaves, etc) to roughen the "NoiseField" and thus the spheres surface. pseudo example and result public void Terrain(float Scale) if (Scale lt 0.01) return List lt Vector3 gt terrain new List lt Vector3 gt () for ( int i 0 i lt surface.vertices.Count i ) Vector3 vert sphere.verts i Vector3 direction vert.normalized Vector3 newpoint vert Sample3DNoise(direction, Scale) terrain.Add(newpoint) this line replaces the original shape! surface.vertices terrain Debug.Log("terrain Update") public float Sample3DNoise(Vector3 point, float scale) Vector3 direction point.normalized float u point.normalized.x scale float v point.normalized.y scale float w point.normalized.z scale poor attempt at 3d noise field PerlinNoise(float, float ) float x Mathf.PerlinNoise(u , 0f) float y Mathf.PerlinNoise(0f, v) float z Mathf.PerlinNoise(u , v) the average of the coords, returns "density at this point" return (x y z) 3 edit so while it appears i was able to achieve this, it's is clearly not the "terrain on surface of sphere" look I was aiming for. Any suggestions on how can I change the "noise field" so my surface is more planet like? or how else can i achieve this?


Merging tesselated terrain with manually modelled In my flighsim visual system I am rendering large scale terrain using fixed grid mesh which is tesselated and displaced using height map. But for some relative small area (usually airports) we have much more detailed models including terrain, runways and so on. And here is a problem how can I merge tesselated terrain with modelled one? On the picture bellow grey is a tesselated terrain, and blue is modelled with 3dsmax.


How do we generate overhangs with simplex noise 3d? Now I use a simplex noise 2d function with x( voxel's x location ) and y(voxel's y location) to generate heightmap. How do we use simplex noise 3d to generate overhangs? What should the x y z inputs be? Pseudo code would help a lot.


How can I write a terrain into a .raw file? I want to generate a terrain through Perlin noise and store it into a .raw file. From Nehe's HeightMap tutorial I know the .raw file is read like this define MAP SIZE 1024 void LoadRawFile(LPSTR strName, int nSize, BYTE pHeightMap) FILE pFile NULL Let's open the file in Read Binary mode. pFile fopen( strName, "rb" ) Check to see if we found the file and could open it if ( pFile NULL ) Display our error message and stop the function MessageBox(NULL, "Can't find the height map!", "Error", MB OK) return Here we load the .raw file into our pHeightMap data array. We are only reading in '1', and the size is the (width height) fread( pHeightMap, 1, nSize, pFile ) After we read the data, it's a good idea to check if everything read fine. int result ferror( pFile ) Check if we received an error. if (result) MessageBox(NULL, "Can't get data!", "Error", MB OK) Close the file. fclose(pFile) pHeightMap is one dimensional, so I don't understand how I would write the x,y correspondence to a height value. I was planning to use either libnoise or the noise2 function on Ken Perlin's page, to make each value in a 1024x1024 matrix correspond to the height for the point, but the .raw file is stored in a single dimension, how can I make x,y correspondence work there?


Is Quadtree Terrain Decimation applicable today? It all started from that page. https www.gamasutra.com view feature 131841 continuous lod terrain meshing .php?print 1 I didn't quite got what it was all about, so I've looked at this. https www.researchgate.net publication 3410916 Terrain decimation through Quadtree Morphing Then I've got some understanding. It was about decimating the more distant patches of the terrain. And then I've just wondered about one thing. At every frame, the mesh is re generated and re uploaded. Wouldn't it be kinda of slow? Ran the demo provided in the first link and got just 3 fps. What's the big idea of this "optimization"? My current code has 1048576 vertices for 1024x1024 heightmap, undecimated, and it runs way faster. His code makes my laptop hot. Another link. Quadtree vs multiple resolution grids for terrain rendering That is more useful. It turns out that there might be some mipmapped meshes on the GPU, and the quadtree decides which of them are turned on. The first question. Is my last guess correct? Second am I right the first link isn't useful anymore? Third how this applies to modern Android development (I mean at least GLESv2).


How is the terrain generated in Commandos and Commandos game clones look alikes? The Commandos series of games and its similar western counterpart, Desperados, use a mix of 2D and 3D elements to achieve a very pleasing and immersive atmosphere. Apart from the concept that alone made the series a best seller, the graphics eye candy was also a much appreciated asset of that game. I was very curious on what was the technique used to model and adorn the realistic terrains in those titles? Below are some screenshots that could be relevant as a reference for whomever has a candidate answer The tiny details and patternless distribution of ornamental textures make me think that these terrains were not generated using a standard heightmap blendmap method.


How do I serialise a mesh to a text file? I'm building a game engine in OpenTK (OpenGL for C ). Is it ossible to take a terrain mesh (in any format) and convert it into a text file (or a really small character filled file, no more than a few bytes). Then, afterwards, I'd take that file and generate the terrain from it. The only reason I'm doing this is to save some memory on the computer. I think it would be more efficient if we had to quickly generate a crude terrain, and then smooth it instead of loading in a large mesh file. Is this possible, and if so, how could I do it?


How can I store and load large 3D environments (terrains or cities)? I am interested in how a large area 3D environment in games like Grand Theft Auto V or Far Cry can be stored (on disk, in what file format) and how that data can be retrieved when it is used in a game. By "the environment" I mean only static objects like terrain with vegetation, city areas with buildings, et cetera. I'm not referring to temporary or moving objects like people or cars. I am not interested in scene rendering. I guess it may be convenient to shard (horizontally partition) the data by location creating something like "tiles" because it is usually accessed by location and such tiling will help to keep data that is related together (and reads will be faster). Also I guess the data for sure is stored in some (compressed?) 3D format with the respect to tiling. There probably have to be mechanisms that will split one object to two (or more) parts if it does not fit into a single tile. I have found a somewhat related question (How a 3D game map is stored and handled) but it only briefly answers small part of my question.


Quadtree vs multiple resolution grids for terrain rendering I have been thinking about quad trees with regards to terrain rendering. From my understanding the basic functionality of quadtree terrain rendering is to frustum cull the terrain in such a manner function render() lod threshold if(lod threshold reached !has children()) draw terrain mesh() return for(child in children) if(child.bounds.intersect(viewing frustum)) child.render() where node.bounds is a 3d bounds calculated as containing the maximum heightmap value of the contained terrain My questions are the following If we are in fact testing a 2d portion of terrain with it's bounds calculated to include the maximum heightmap value against the 3d frustum, what is the preferred bounds calculation for generating the node.bounds in the quadtree? That a tree is necessary because that one has to iterate every portion of a 3d scene to calculate frustum occlusion in a general way. Eg, there is no shortcut algorithm to calculate the set of 3d cells generated from a 2d grid that intersect the viewing frustum. As a more general question and to question the obvious, is there a way to calculate cells in a viewing frustum without having to iterate every cell in a scene? Presumably not otherwise you wouldn't need trees for culling With regards to an alternative grid implementation Has this implementation been contemplated for general purpose terrain culling? I am presuming that some form of grid base terrain culling is certainly preferred in certain games, namely top down games where the possibility of terrain in the distance of being on camera is non existent. function calc cells in quadrilateral(frustum projection onto 2d terrain grid) calculate cells in the resulting quadrilateral projection of the frustum onto the grid without having to bounds test every cell at some point based on distance from camera, assign lod retrieve lod for each cell in the calculated set from lod grids have multiple (array2 or intmap) containing the terrain data at every lod for O(1) retrieval Is there is a way to calculate cells in a quadrilateral without having iterate every cell in a grid? eg, from shaving off cells from slopes or something? If there is, in what fashion should one assign the lod cell based on distance? I haven't contemplated this in detail because 1 may be impossible The terrain would not be optimally culled in this 2d culling algorithm against the quadrilateral frustum projection onto the heightmap, because the height value at the edges may be outside the screen, correct? http www.olhovsky.com 2011 03 terrain started In this post, he describes assigning lod from a grid and from a quad tree. The illustrations are confusing with regards to whether question 1 is correct and terrain rendering with quad trees serves to draw the terrain mesh against the frustum as opposed to just as a function of distance 360 around the camera as at appears to do with his grid implementation. Please specify whether it appears that he is infact not frustum culling in the grid implementation but is frustum culling the quadtree.


Proper updating of GeoClipMaps I have been working on an implementation of gpu based geo clip maps, but there is a section of the GPU Gems 2 article that I just can't seem to understand, specifically this paragraph, and more precisely the bolded part The choice of grid size n 2k 1 has the further advantage that the finer level is never exactly centered with respect to its parent next coarser level. In other words, it is always offset by 1 grid unit either left or right, as well as either top or bottom (see Figure 2 4), depending on the position of the viewpoint. In fact, it is necessary to allow a finer level to shift while its next coarser level stays fixed, and therefore the finer level must sometimes be off center with respect to the next coarser level. An alternative choice of grid size, such as n 2k 3, would provide the possibility for exact centering Let's take an example image from the article My "understanding" of the way the clip maps were updated was that you floor the position of the viewpoint to an int, and as such get the center vertex point. If this is not the same as the previous center point, you update the entire map. Now, this obviously is not the case. What I am failing to understand is this If you look at the image above, if the viewpoint was to move one unit to the right, then the inner ring (the one just around the view point white center square) would end up getting a 1 unit space on both the left and right side of itself. But there is nothing in the paper that deals with this. What I mean is that it would end up looking like this (excuse my crummy cut and paste editing of the above image) This is obviously not a valid state. So, would the solution be that a clip ring (layer) can only move in increments of the ring layer it's contained within? Wouldn't this end up being very restrictive? I feel like I am missing some crucial understanding of parts of the algorithm, but I have been over both this paper and the original paper from 2004 and I just can't see what I am not getting.


What algorithm to use for random terrain? (Please note, I am aware that the generation is not truly random and relies on mathematical equations, and that my language of choice is C ) So I've been learning programming for a while now and I'm looking to make a top down 2D game. I want this game to generate random terrain pretty much like Dwarf Fortress but with sprites, however for this question let's just say that there just ASCII characters. I want it to generate mountains, rivers, inland lakes etc. I know of algorithms but have not been able to find a list of them all. The ones i know of are Perlin Noise, Diamond Square, Midpoint Displacement and some other minor ones. However I don't know which one to use and struggle to find a good article on any of them. Is there one right for the job, or does it just come down to personal opinion? And if you can find a list of all the algorithms and maybe a good article on one it would really help. Thanks!


How to use ROAM algorithm to adapt terrain's mesh? I have a hard time understanding the idea behind ROAM algorithm "Real time, continuous level of detail rendering of height fields" Peter Lindstrom, David Koller, William Ribarsky, Larry F. Hodges, Nick Faust, Gregory A. Turner SAIC http dl.acm.org citation.cfm?id 237217 "ROAMing terrain real time optimally adapting meshes" Mark Duchaineau, Murray Wolinsky, David E. Sigeti, Mark C. Miller, Charles Aldrich, Mark B. Mineev Weinstein http dl.acm.org citation.cfm?id 267028 The problem that I cannot grasp is that the whole idea behind the algorithm is that the terrain mesh is at all times divided to isosceles right angled triangles but when we arrange the terrain in a non flat mesh then the triangles that we divided the mesh into are supposed to be extended(?) to meet the height field requirements? From what perspective is the terrain divided into those triangles and should they be isosceles right angled triangles generally or only when looked upon in up down projection?


Level of Detail and loading map tiles I'm making some visualization of the Earth. It just should display tiles from services like Google Map (OpenMap for example) on the Earth surface. This services provide Earth satellite image textures of different parts of Earth at different zoom levels (resolution). The goal is make something similar with Google Earth. Of course I want to load only visible tiles at appropriate zoom level depending on distance to the camera center. So I'm interesting in how to decide which tiles on which levels should I load depending on current camera position. I know how to find region on the Earth surface that currently visible depending on camera view and projection matrix. And I can calculate the desired resolution (zoom level) of tiles for each point inside this region. Now, how to find out tile coordinates and zooms that I need to download form OpenMap or similar services? Is there some algorithm to do it?


Where can I find an accurate map of Earth for a real time third person game? I want to create a game that will allow the player to move to any place on Earth. The game will not be first person, but it will be possible to zoom in quite close nonetheless. What I am lacking is an accurate height map of the planet. Textures such as albedo, specular or normal would also be very helpful. I don't know if such textures exist, but an "accurate" height map should have a resolution of at most a few meters. The textures do not have to be 100 real. Some parts can be procedurally generated, as long as they look "realistic".


How do I simplify terrain with tunnels or overhangs? I'm attempting to store vertex data in a quadtree with C , such that far away vertices can be combined to simplify the object and speed up rendering. This works well with a reasonably flat mesh, but what about terrain with overhangs or tunnels? How should I represent such a mesh in a quadtree? After the initial generation, each mesh is roughly 130,000 polygons and about 300 of these meshes are lined up to create the surface of a planetary body. A fully generated planet is upwards of 10,000,000 polygons before applying any culling to the individual meshes. Therefore, this second optimization is vital for the project. The rest of my confusion focuses around my inexperience with vertex data How do I properly loop through the vertex data to group them into specific quads? How do I conclude from vertex data what a quad's maximum size should be? How many quads should the quadtree include?


Is 1 pixel of a height map representative of 1 vertex on the mesh? I'm trying to get my head around heightmap terrain generation. If I have a plane say 64 x 64 verts will I need to create a 64px by 64px greyscale heightmap in order to displace the geometry of the plane correctly?


Large Scale GIS in a AAA Quality Game Engine? (Unreal, Cryengine, Unity, Etc.) I am working on a new simulation project that requires large scale, real world terrain and imagery (GIS). By large scale, I mean that I would like to support databases that cover something on the order of 10,000 square miles that include at least height data and satellite imagery. Using data of this size also means that the engine must be capable of managing the coordinate systems projections such that some reasonable precision can be maintained. To my knowledge OpenSceneGraph is the only graphics engine out there that makes this easy (via paged terrain support, osgEarth, etc.) However, it would be nice to be able to leverage many of the other great features AAA quality game engines bring to the table. (OSG is just a graphics engine, really. I've been using it for over a decade, but I don't want to be fixed only to what I know.) I've seen many tutorials online for importing small postage stamp sized bits of terrain into Unreal. I haven't seen anything on this scale. Asked here "Very large terrains in Unreal 4" there is a link to Unreal's "World Composition" feature. This seems to shift coordinates around and also doesn't seem geared towards using real world data. How can I represent real world terrain data on these scales in a mainstream game engine?


(XNA) Stretching Images (Sprites) without Blur (Rasterizing?) thanks for clicking on this question although it has likely one of the most un specific and confusing titles on this site. I am somewhat new to XNA and I have only posted 1 question on this site before which I didn't understand the answer to fully, but I'll give it another go. I am looking to create a game which allows the user to either go full screen or re size the window to a few preset values, like many mainstream games nowadays allow you to do. I believe I know how to do this in XNA, the problem is, when I toggle full screen, and it stretches the sprites, they appear blurry. I know this is a very obvious problem, as stretching blur (logically). The thing is, I was wondering if there was a way to make it so regardless of the zoom, your sprites look crisp and not blurry? I asked a friend of mine in real life and he said something about rasterizing (which i don't know anything about). The only other thing I can think of I've seen this done a few times in Flash. For examples of what I mean the only game I can think of is Super Smash Flash 2. It seems regardless of the screen size, most of the sprites and images appear crisp, even on the largest of screens. If anybody knows anything about this, please share! Thanks.


Is there a way to scale a texture via GPU rather than by CPU? For my game that I'm developing I want to have my cards dynamically drawn so if there is any changes done to them it could be drawn on the card itself. What I have currently is that the cards are drawn to a RenderTarget at their originally designed size of 2100x1480 px. (I'll probably for game purposes have to scale that down to 1050x740 for its native size, but was designed that way to have 600 dpi for physical versions). Anyway the way I want to do it is that after drawing everything to the RenderTarget I scale it down and store that scaled down texture to the card's texture (which will be 164 x 115 for the playing size, the 1050 x 740 is the zoomed in size that I want so players can view what the card does and stats). The issue that I'm facing is that the way I currently tried to do it was far too slow taking over 9 seconds to scale it down after drawing the original size to the RenderTarget. Is there a way to scale a texture via GPU rather than by CPU? I'm currently using a CPU method as I'm new to working with textures and drawing.


Can someone explain this occurrence with a fbx model in xna? Because this is kind of weird to explain, let's show you what I mean. This is in my game. When I import this base ship model, it should be at (1000,1000,1000), but the model acts like it's at (1000,1000, 0). Note it is positioned correctly when I use a .x model. So it has to be the model. I need to know what's wrong with it. Here is the model file, tell me if anything is wrong with it https dl.dropbox.com u 92848165 station2.FBX http i.imgur.com VsjH8.jpg EDIT The model works if you import it into Google Sketchup...but you lose the textures, not very nice.


Units issue when exporting from 3DS Max to XNA I am working on a XNA game where we have defined that 1 XNA unit equals to 1 meter. Then, I set meters as system unit in 3DS Max and set to meters the units in the FBX exporter. However, when I export my models, they are much bigger in the game. Am I missing something? What should I do to avoid problems with my units? Investigating the FBX file, I noticed that I it has two values called UnitScaleFactor and OriginalUnitScaleFactor. They both are 100 when I export the files... And if I manually change UnitScaleFactor to 1, it works fine S


Orthographic Camera Zooming In XNA I am using a spritebatch to render a board. I have created a camera class which can provide me a view and projection matrix. Currently I am supplying the view matrix to my sprite batch when I call begin. I can get the view matrix to correctly move everything around and do some zooming in and out. My problem is that I want to zoom in on a specific point (for now the center of the screen) but currently zooming just zooms in on the coordinate 0,0. Here is how I am constructing the view matrix ViewMatrix Matrix.CreateTranslation( new Vector3( ( Position.X Width Zoom 2), ( Position.Y Height Zoom 2), 0) ) Matrix.CreateScale(new Vector3( Zoom, Zoom, 1)) How could this be altered to make it scale correctly relative to the given point. Later I will probably want to zoom to the mouse position, but if someone has a simple example I'm sure I can work out how to adapt it.


How to fill a rectangle with tilable texture in XNA? So, question in the title. I don't know how to create infinite seamless background.


How do you create a .XNB Font file for use with CocosSharp? I know the .XNB file format is an XNA thing and that CocosSharp inherits this from its MonoGame roots. However there doesn't seem to be any information on how to create your own .XNB fonts to use with CocosSharp. I've tried searching but can find any information. Could someone explain it here or point me to a tutorial on how to create .XNB font file for use with CocosSharp? A site to download already compiled .XNB Fonts would also be acceptable. Update Another thing that makes this tricky is that I guess XNA Game Studio could be used, but it's not compatible with Windows 8.1 which is what I currently use for my dev machine...


Using an object as a model to avoid too many parameters XNA C I have 3 classes(Skill,Projectile and Status),Skill has Projectile and Projectile has Status, all of them need to read information from a txt and to avoid open it everytime I want to create an object I want to read all the txt on Skill and pass the information Projectile need as arguments and then on Projectile create Status passing the information needed as arguments too As Projectile going to create a lot of Status objects it need to receive Projectile's informations and Status's informations from Skill, to avoid too many parameters can I create a Status object on Skill and pass it to Projectile and everytime I need to create another status I use the first one as a model? As example public class Skill String skillName,projectileName,statusName int skillNumber,projectileNumber,statusNumber public Skill() Code to read txt and fill variables What is happening Projectile projec new Projectile(projectileName,statusName,projectileNumber,statusNumber) To avoid above Status status new Status(statusName,statusNumber) Projectile projec new Projectile(projectileName,projectileNumber,status) And then at Projectile public class Projectile Constructor,variables and methods Method that create Status public void Update() if(hitEntity) this status was received from Skills Status tempStatus new Status(status.statusName,status.statusNumber)


WP 8.1 XNA custom game loop (render when dirty?) I need to know whether it's possible to create a XNA game for Windows Phone 8.1 (which I've already) using monogame with a custom game loop. OpenGL ES has this possibility (GL RENDERMODE WHENDIRTY or sth. like that). Is there anything like that RenderMode for XNA MonoGame on WP 8.1 Note I'm new to Windows phone game programming.


XNA advanced rotation 3D I'm able to rotate any model with any angle I want, where I can not rotate my model around a given point. e.g My model rotates from the origin assigned in its .fpx file. I want it to rotate related to a point of its bottom plane, so that it is animated as falling


Tons of stuttering in XNA? As stated in the title, my program stutters like crazy, even though my program for the most part runs for 60 fps. During the moments it stutters, FPS momentarily drops down to 59(stats from FRAPS). Here is an video capture of the stuttering in action. If you look closely, you can see the game stutter around 3 4 times. It is much more noticeable in real life. http gfycat.com SevereCanineBabirusa CLR Profiler shows that garbage collection doesn't run at all during that time, never mind 4 times, so it's not that. Here's the code for movement Movement logic Increase the speed speed Math.Min(speed (speedIncrement (gameTime.ElapsedGameTime.Milliseconds 200.0f)), maxSpeed) for (int i fruits.Count 1 i gt 0 i ) Move the fruits fruits i .pos.Y speed gameTime.ElapsedGameTime.Milliseconds fruits i .rect.Y (int)fruits i .pos.Y Check if the fruit is past the screen. If it is, remove it from fruits if (fruits i .rect.Y gt screenHeight) fruits.Remove(fruits i ) IsFixedTimeStep is set to false, but SyncronizeWithVerticalTrace is on. Any idea what could be the cause of the stuttering? EDIT Apparently it was a combination of this http answers.microsoft.com en us windows forum windows 7 performance presentationfontcacheexe uses 50 of my cpu 4200fe85 458f 4f19 b791 1fe5395304da and f.lux eating up my CPU GPU cycles.


How do I make a more or less realistic water surface? I want to make a similar water surface like in this picture I need the water surface in the same view than in the picture. Is it possible to work without shaders? I want to develop a little game for Xbox Live Indie Marketplace, Windows Phone and maybe later iPhone iPad. How should I make the water surface, so that it works on multiple platforms?


Is there any quick and easy way to make all bodies visible with Farseer physics engine for XNA? I just want to be able to see all my bodies on the screen for debugging purposes and i cant think of an easy way, for example i have make some edge fixtures with curved arcs attached and i just want to see what they look like!


Creating mesh at run time I've a set of voxel data and I want to create a mesh out of it at run time. I've looked into MeshBuilder and MeshHelper but I haven't found anything useful or a good tutorial how to use them. Can anyone tell me how to create a mesh at run time?


Different ways to store a 2D map landscape in XNA I was looking around at this site about eight months ago and wish I saved the location of this topic but I was wondering the different map rendering styles that you can do in XNA. The one style I looked at was using a text file to pull characters like "X" would be a monster and "O" would be the player. Is there another way with out an external file that I can put tiles from a sprite sheet to randomly create a map. Of course when dealing with random buildings I would have certain building designs so that if some one was playing they wouldn't see a building with half a wall missing. This is for a top down 2D game.


How to correctly handle multiple Songs in XNA? I'm working on a (Windows only) game in XNA, and I have multiple music tracks. I don't want to load them all into memory, but play them on demand. To properly dispose them, I have a separate ContentManager just for music and a method that looks like this public void PlayMusic(MusicTracks trackToPlay) if (trackToPlay currentlyPlayingTrack) return MediaPlayer.Stop() musicContentManager.Unload() Song song null switch (trackToPlay) case MusicTracks.TitleMusic song musicContentManager.Load lt Song gt ("TitleMusic") break case MusicTracks.CreditsMusic song musicContentManager.Load lt Song gt ("CreditsMusic") break if(song ! null) MediaPlayer.Play(song) MediaPlayer.IsRepeating true currentlyPlayingTrack trackToPlay (MusicTracks is an enum). Is this the correct way to make sure I'm not using more RAM Resources than required? Or should I be looking into XACT? To be clear, I don't need to play multiple Songs at the same time (I do need to play 1 Song and a few SoundEffects though) and I don't need any crazy effects apart from setting the Volume of the music independently from the soundeffects, which should be straight forward with MediaPlayer.Volume.


How can I export a model using the CAT bone system into XNA? Has anyone successfully used the CAT bone system in 3ds Max and exported the file into XNA? If so, what was your method of doing so? There are a number of methods of doing this, apparently, but the ones I've tried have not worked. I used the Panda Exporter which creates an .X file. This seems to be the latest way of going about this, but when it's loaded in XNA, there is an error saying something about the bone weights. This happens when I export with and without CAT bones.


XNA GameTime before first Update Using XNA, is it possible to access the GameTime object before Update is called for the first time? Can it be used in the game constructor, Initialize or LoadContent methods?


Min Max of two vectors? This seems like a simple question, but i'm having trouble searching the internet for it. In XNA, during a collision detecting method, I would determin the minimum of some vectors. Get the minimum top point Vector2 minTopPoint1 Vector2.Min(topLeft1, topRight1) Get the minimum bottom point Vector2 minBottomPoint1 Vector2.Min(bottomLeft1, bottomRight1) Get the minimum of both the top and bottom points. Vector2 minPoint1 Vector2.Min(minTopPoint1, minBottomPoint1) I switched over to making a C engine, and am trying to replicate the collision formula (Honestly, it's confusing enough, I just need to replicate it from XNA) I made my own Vector2, and now I need to make this Min function. So, what is the minimum or maximum of two vectors? Is it just the magnitude of the two vectors measured against eatchother? Is it the x and y values min maxed somehow?


How can I track how "well lit" a player is so that I can determine if my AI can see him or her? I want to see how well lit the player character is in an environment so that my AI can react (or not) to the player when he or she is visible. Currently I am doing this by reading back the color data of the final render target and computing the brightness of the player's region. It seems expensive and taxing, so I was wondering if there is a better way to approach this?


How to convert screen space into 3D world space? I am trying to make a 3D model to look at the mouse position. Currently I have this code MouseState mouseState Mouse.GetState() Matrix world Matrix.CreateTranslation(0, 0, 0) Vector3 source new Vector3((float) mouseState.X, 1f, (float) mouseState.Y) Vector3 mousePoint GraphicsDevice.Viewport.Unproject(source, this.game.Camera.Projection, this.game.Camera.View, world) System.Console.Out.WriteLine("x " mousePoint.X ", Y " mousePoint.Y ", Z " mousePoint.Z) I get output such as this in the console x 0.1787011, Y 999.7204, Z 299.7723 x 0.08917224, Y 999.8602, Z 299.8862 x 0.05908892, Y 999.9069, Z 299.9241 x 0.04422692, Y 999.9302, Z 299.9431 x 0.03303542, Y 999.9477, Z 299.9573 x 0.03109217, Y 999.9508, Z 299.9598 x 0.02930491, Y 999.9535, Z 299.9621 x 0.02770578, Y 999.9559, Z 299.9641 x 0.0263205, Y 999.9581, Z 299.9659 The player is positioned at Vector3.Zero. The camera is positioned at new Vector3(0.0f, 1000.0f, 300.0f). I would like to get output such as X 300, Y 0, Z 300 when moving the mouse to screen top left and when moving the mouse to screen center where the model is located I want to have X 0, Y 0, Z 0. So I want the world coordinates of the mouse so that I can make the player rotate towards the mouse. Basically I want to map mouse X into world X, mouse Y to world Z and the world Y coordinate can be 0 at all times.


How to retrieve a cube collision by faces I work for a while on a minecraft game (voxel). I am front a problem for a long time about the collision detection. I want recover the cubes collision from my highlighted black's cube like on the picture , but only on the sides. And not on the edges ! Actually i got all cubes in red and green when i check with the boundingBox method. Actually i use the method with the class "BoundingBox" to check for collisions. Can anyone help me or direct me on the best way for retrive the right cube ? Code example with the boundingBox methode for check the collision List lt Node gt nodeParent regions modelSelected.regionIndex .Nodes modelSelected.Id .Where(m gt modelSelected.BoundingBox.Intersects(m.boundingBox)).ToList() i want to get only the green cube and not the red .. From the black cube in the middle Thank's a lot guy


2D Collision Check before or check after? I'm using velocity to move my character, I just add subtract 0.4f and then update the players position in the update loop. I was wondering, when would be the best place to check for collision? Do I go ahead move the player, and then if I colliding push him out of the wall until there's no collision? Or do I check collision as soon as the key is pressed, and if there is somehow find the distance and move the player? My problem is that my game is tile based, but the world is constantly rotating around the player I have a function that returns a list of objects of each block that the player is colliding with, and I'm having trouble separating wall collisions with floor collisions


Facilitating XNA game deployments for non programmers I'm currently working on an RPG, using the RPG starter kit from XNA as a base. (http xbox.create.msdn.com en US education catalog sample roleplaying game) I'm working with a small team (two designers and one music sound artist), but I'm the only programmer. Currently, we're working with the following (unsustainable) system the team creates new pics sounds to add to the game, or they modify existing sounds pics, then they commit their work to a repository, where we keep a current build of everything. (Code, images, sound, etc.) Every day or so, I create a new installer, reflecting the new images, code changes, and sound, and everyone installs it. My issue is this I want to create a system where the rest of the team can replace the combat sounds, for instance, and they can immediately see the changes, without having to wait for me to build. The way XNA's setup, if I publish, it encodes all of the image and sound files, so the team can't "hot swap." I can set up Microsoft VS on everyone's machine and show them how to quickly publish, but I wanted to know if there was a simpler way of doing this. Has anyone come up against this when working with teams using XNA?


Xna Texture2D from a png file I'm making a tile based game, and I'm working for support of tilesets. I'm trying to make it so that a Texture2D is set as a chosen PNG file. I can do this with no problem f I load the image into the content pipeline, but the level editor will be used by people without access to the content pipeline. How do I go about doing this?


Viewport.Unproject Checking if a model intersects a large sprite Let's say I have a sprite, drawn like this spriteBatch.Draw(levelCannons i .texture, levelCannons i .position, null, alpha, levelCannons i .rotation, Vector2.Zero, scale, SpriteEffects.None, 0) Picture levelCannon as being a laser beam that goes across the entire screen. I need to see if my 3d model intersects with the screen space inhabited by the sprite. I managed to dig up Viewport.Unproject, but that seems to only be useful when dealing with a single point in 2d space, rather than an area. What can I do in my case?


How does having the Debugger change the game execution on an XBOX 360? So I thought my issue was relating to the difference between a Debug and a Release build as per this question What 39 s the difference between a quot Release quot Xbox 360 build and a quot Debug quot one? but I've since found that if I go ahead and build a Creators Club version of the game using a Debug build and deploy to the XBOX, I get the same experience I had with the Release version of my game. However if I run the game from Visual Studio using F5 and having set the XBOX as the default platform, then the game runs as expected. If I change from Debug to Release and run with CTRL F5 then the game also works as expected. How would running the game with the debugger attached change the results I am getting in game? Is there any way that I can use the same approach or change the default compilation of the game so that I can use this approach to release my game?


Is Spine's XNA runtime missing an importer? I'm writing an XNA 4.0 game and use Spine for animation. Until now, I've been making spritesheets with Spine and using them with a custom animation class. I recently discovered there is an official Spine runtime for XNA. I've been trying to use it but encounter an error. The closest I've come (after adding the runtime's classes to my project) is this error Cannot autodetect which importer to use for "data goblins.atlas". There are no importers which handle this file type. Specify the importer that handles this file type in your project. Is there such an importer in the runtime and I simply missed it? If so, how can I get XNA to recognize it? If not, is there an alternative?


Timestep in multiplayer game I'm trying to wrap my brain around the concept of creating a server client multiplayer experience. My problem is mainly related to timestep. Consider the following scenario A client connects to a server. The client sends his inputs to the server to indicate he wants to move. Server simulates the input and determines the position of that client in the game world. Since the client and the server are both running on different timesteps, how do you accurately simulate so that all clients are in sync with the server? My server is currently set at at 30ms timestep. When I process client movements, there are potentially hundreds of requests waiting to be processed, yet no way to indicate how long it took between each one of the requests. I'm really not grasping how to properly simulate on the server based on time, in order to have everything sync up.


Tile based platformer, using larger tiles? So for my tile based platformer, It has a grid of tiles Occupying 1x1 block for each one. However, What if I want larger tiles? Maybe doors, tables, etc. They wouldnt fit in a 1x1 tile, so what I need is a way to let any method trying to access my tile array, know that a tile could be occupying a larger space. I can already render larger objects correctly, But I simply am looking for a method to let evrything else know a larger tile is there, So I can perform collision on it, and so other tiles cant be placed on it.


XNA WP7 accelerometer sample example ball rolling Does anyone know of a good WP7 accelerometer sample of a ball rolling around on a screen?


2D Magnet like repelling behavior If somebody wanted to develop a system between two intersecting rectangles so that the rectangles would, in a gradual process, push eachother away from one another until no longer intersecting, with the repelling force being stronger depending upon how deep the intersection is... what would the math look like?


Orienting a model to face a target I have two objects (target and player), both have Position (Vector3) and Rotation (Quaternion). I want the target to rotate and be facing right at the player. The target, when it shoots something should shoot right at the player. I've seen plenty of examples of slerping to the player, but I don't want incremental rotation, well, I suppose that would be ok as long as I can make the slerp be 100 , and as long as it actually worked. FYI Im able to use the position and rotation to do plenty of other things and it all works great except this last piece I cant figure out. Code samples run in the Target's class, Position the targets position, Avatar the player. EDIT Im now using Maik's c code he has provided and it works great!


Formula throwing a ball to destination I am throwing a ball using this double v, vx, vy, alpha, t2 0 if (Keyboard.GetState().IsKeyDown(Keys.Up)) alpha MathHelper.ToRadians(60f) v 1230d vy v Math.Sin(alpha) vx v Math.Cos(alpha) ball2pos.Y (float)((vy t2) (g t2 t2 2)) graphics.GraphicsDevice.Viewport.Height ball2.Height ball2pos.X (float)( vx t2) t2 t2 gameTime.ElapsedGameTime.TotalSeconds It works without a problem. It calculates the throw including the gravitation (g). vx is how much it moves per second on the X,vY the Y accelerration (running against gravity), v the strength of the throw and t2 the current time. But I want to change the formula to throw the ball to a given destination. Say I want to throw my ball from 60 degrees to a target. How much "strength" do I need for it? What would be the formula? I'm not really good at figuring out that and google doesn't give me what I want. To simplify let's assume that the Y of source and target are the same Given Angle, SourceLocation, TargetLocation, Gravitation Looking for Strength


Game Asset Management I am making my first small mobile game in C XNA. Lets say I have 3 screens, the main menu, options and game screen. A single game session usually lasts for 1 min, so the user will alternate frequently between the main menu and game screen. Therefore, once I load the textures for either screen, I want to keep them in memory to avoid frequent reloading. Both screens share some assets like their background textures, but differ in others. The first solution I came up with is making 2 texture factory classes, MainScreenAssetFactory and GameScreenAssetFactory, each with their own content manager, and ill store them in a globally accessible point so that they persist after either screen is destroyed. There is also a OptionsScreenAssetFactory, but that I dont want to cache it since the options screen is rarely visited. A typical Factory would look something like this public class MainScreenAssetFactory private readonly ContentManager contentManager public MainScreenAssetFactory(IServiceProvider serviceProvider, string rootDirectory) contentManager new ContentManager(serviceProvider) RootDirectory rootDirectory public Texture2D ListElementBackground get return contentManager.Load lt Texture2D gt ("UserTab") public Texture2D ListElementBulletPoint get return contentManager.Load lt Texture2D gt ("TabIcon") public Texture2D LoggedOutUser get return contentManager.Load lt Texture2D gt ("LoggedOutUser") Since both Main, Options and Game Screen share some common resources, instead of loading them more than once, I created another class CommonAssetTexFactory which holds the common stuff and stays in memory during the app lifetime. For example, this class gets passed to the options screen when it is created. However, given my small game with its few assets, I am already finding this solution cumbersome and inflexible. Changing anything would require looking to see if its already in the common factory, and if not, modifying existing factories and so on. And this is just considering textures currently, i didnt add sound files yet. I cant imagine bigger games with thousands of resources using this approach. A better idea must exist. Would someone please enlighten me?


XNA move from start position to target position exactly in 3D If I have a list of positions that map out a path a character should follow. What would be the best way to move at a constant speed to each position making sure the character lands exactly at each position before moving onto the next? For example the character is at position A, we then queue up position B and position C. The character cannot move towards position C until it reaches position B exactly. It would be great if the solution worked at slower frame rates update speeds as well.


Absorbtion 2d image effect I want to create a specyfic 2d image effect. It consists in modifying a sprite so it looks like it is being zoomed to a point or "absorbed" by that point. I'm not really sure what is the technical name of this effect so I cannot explain it correctly. Here you can see a video of what I'm talking about, it is the effect when the character absorbs the three glyphs. http www.youtube.com watch?v PIo GddsMcU amp t 4m45s What is the name of this effect? How can I implement it with XNA for 2D textures sprites?


How do I create a 3rd person camera? I currently have a camera class set up and have my model player loaded but I can't get my camera in the correct position by changing the x,y,z coordinates. I have set up my "game" with a separate class for the model player and a class for the camera. I am fairly new to XNA and most of what I have already got is from a tutorial from my lecturer. Here is my player model class public class Player public Model model public Matrix world Matrix.Identity public Vector3 position public Vector3 direction public Quaternion rotation Quaternion.Identity public BoundingSphere collision public float speed 2f public float moveForwards public float moveLeft public float forward Matrix transform public Player(Model m, Vector3 iPos) model m position iPos direction new Vector3(0, 0, 1) transform new Matrix m.Bones.Count m.CopyAbsoluteBoneTransformsTo(transform) foreach (ModelMesh mesh in m.Meshes) collision BoundingSphere.CreateMerged(collision, mesh.BoundingSphere) public Player() public BoundingSphere getSphere() return collision.Transform(world) public void sampleInputMovement(GamePadState player) moveForwards (player.ThumbSticks.Left.Y 5) moveLeft (player.ThumbSticks.Left.X 32) 1 public void update() rotation Quaternion.CreateFromAxisAngle(new Vector3(0, 0, 1), moveLeft) Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), moveForwards) Vector3 motion Vector3.Transform(direction, rotation) position motion forward world Matrix.CreateFromQuaternion(rotation) Matrix.CreateTranslation(position) public void Draw(Matrix projection, Matrix view) Matrix transforms new Matrix model.Bones.Count model.CopyAbsoluteBoneTransformsTo(transforms) foreach (ModelMesh mesh in model.Meshes) foreach (BasicEffect effect in mesh.Effects) effect.EnableDefaultLighting() effect.Projection projection effect.View view effect.World transforms mesh.ParentBone.Index world mesh.Draw() And here is my camera class public class Camera Vector3 position Vector3 newposition Quaternion cameraRotation Vector3 targetOffset new Vector3(0, 1f, 6f) public Matrix view Matrix.Identity public Matrix projection Matrix.Identity public Camera(Game game, Vector3 xPostion) position xPostion projection Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, game.GraphicsDevice.Viewport.AspectRatio, 1.0f, 1000000f) public void update(Matrix targetWorld) Quaternion rotation Vector3 target Vector3 scale targetWorld.Decompose(out scale, out rotation, out target) cameraRotation Quaternion.Lerp(cameraRotation, rotation, 0.15f) newposition Vector3.Transform(targetOffset, targetWorld) position Vector3.SmoothStep(position, newposition, 0.8f) Vector3 cameraup Vector3.Transform(new Vector3(0, 1, 0), Matrix.CreateFromQuaternion(cameraRotation)) view Matrix.CreateLookAt(position, target, cameraup) Could someone help me get my camera in the correct position?


Zune same features as WP7? (gesture, accelerometer) We don't have zune HD in Canada (yet) just wondering if it has the same programmable features as WP7? Like gestures and accelerometer. Basically if I am just making a game, with screen controls (thumbsticks on the screen) is this an easy port to zune? Thanks!


how to move the camera behind a model with the same angle? in XNA I'm having difficulty moving my camera behind an object in a 3D world. I'd like to have two view modes for fps (first person). external view behind the character (third person). I've searched the net for examples but they don't work in my project. Here is my code used to change the view when F2 is pressed Camera double X1 this.camera.PositionX double X2 this.player.Position.X double Z1 this.camera.PositionZ double Z2 this.player.Position.Z Verify that the user must not let the press F2 if (!this.camera.IsF2TurnedInBoucle) If the view mode is the second person if (this.camera.ViewCamera type CameraSimples.ChangeView.SecondPerson) this.camera.ViewCamera type CameraSimples.ChangeView.firstPerson Calcul position ?? Here my problem double direction Math.Atan2(X2 X1, Z2 Z1) 180.0 3.14159265 Calcul angle ?? Here my problem this.camera.position .. this.camera.rotation .. this.camera.MouseRadian LeftrightRot (float)direction IF mode view is first person else ....


Keeping the meshes "thickness" the same when scaling an object I've been bashing my head for the past couple of weeks trying to find a way to help me accomplish, on first look very easy task. So, I got this one object currently made out of 5 cuboids (2 sides, 1 top, 1 bottom, 1 back), this is just for an example, later on there will be whole range of different set ups. Now, the thing is when the user chooses to scale the whole object this is what should happen X scale top and bottom cuboids should get scaled by a scale factor, sides should get moved so they are positioned just like they were before(in this case at both ends of top and bottom cuboids), back should get scaled so it fits like before(if I simply scale it by a scale factor it will leave gaps on each side). Y scale sides should get scaled by a scale factor, top and bottom cuboid should get moved, and back should also get scaled. Z scale sides, top and bottom cuboids should get scaled, back should get moved. Hope you can help, EDIT I am asking you, if any of you have any idea on how to accomplish this scaling. I have tried whole bunch of things, from scaling all of the object by the same scale factor, to subtracting and adding sizes to get the right size. But nothing I tried worked, if one mesh got scaled correctly then others didn't. Donwload the example object.


How to get max viewable X Value in Viewport How can I calculate or get the farthest X Value of a Viewport during gameplay? Say a model is moving in from the right hand side (beyond Viewport) and starting from a certain X Value it is visible on the viewport. I'd like get that certain X Value. But the more I zoom out (Z Axis) the greater the farthest visible X gets (Max X). How could I approach this?


How do I make a more or less realistic water surface? I want to make a similar water surface like in this picture I need the water surface in the same view than in the picture. Is it possible to work without shaders? I want to develop a little game for Xbox Live Indie Marketplace, Windows Phone and maybe later iPhone iPad. How should I make the water surface, so that it works on multiple platforms?


Clarification on RenderTargetUsage in XNA 4.0 I'm trying to understand the exact meaning of RenderTargetUsage.DiscardContents. The documentation says Determines how render target data is used once a new render target is set. DiscardContents Always clears the render target data. Does calling GraphicsDevice.SetRenderTarget(null) to return to the back buffer count as setting a new render target (therefore clearing discarding any previous one)? Are the contents discarded either way at the end of the frame (i.e. when the graphic device presents), or do they persist into future frames even in this mode?


How to adjust GUI to screen resolution ? I've created a GUI for my XNA game and now I'm stuck with a problem. My GUI element positions are designed for a max resolution of 1920x1080, and if I try changing it to 640x480 they disappear from the screen. What I can change to keep them there?


Automating XNA Performance Testing? I was wondering what peoples approaches or thoughts were on automating performance testing in XNA. Currently I am looking at only working in 2d, but that poses many areas where performance can be improved with different implementations. An example would be if you had 2 different implementations of spatial partitioning, one may be faster than another but without doing some actual performance testing you wouldn't be able to tell which one for sure (unless you saw the code was blatantly slow in certain parts). You could write a unit test which for a given time frame kept adding updating removing entities for both implementations and see how many were made in each timeframe and the higher one would be the faster one (in this given example). Another higher level example would be if you wanted to see how many entities you can have on the screen roughly without going beneath 60fps. The problem with this is to automate it you would need to use the hidden form trick or some other thing to kick off a mock game and purely test which parts you care about and disable everything else. I know that this isnt a simple affair really as even if you can automate the tests, really it is up to a human to interpret if the results are performant enough, but as part of a build step you could have it run these tests and publish the results somewhere for comparison. This way if you go from version 1.1 to 1.2 but have changed a few underlying algorithms you may notice that generally the performance score would have gone up, meaning you have improved your overall performance of the application, and then from 1.2 to 1.3 you may notice that you have then dropped overall performance a bit. So has anyone automated this sort of thing in their projects, and if so how do you measure your performance comparisons at a high level and what frameworks do you use to test? As providing you have written your code so its testable mockable for most parts you can just use your tests as a mechanism for getting some performance results... Edit Just for clarity, I am more interested in the best way to make use of automated tests within XNA to track your performance, not play testing or guessing by manually running your game on a machine. This is completely different to seeing if your game is playable on X hardware, it is more about tracking the change in performance as your game engine framework changes. As mentioned in one of the comments you could easily test "how many nodes can I insert remove update within QuadTreeA within 2 seconds", but you have to physically look at these results every time to see if it has changed, which may be fine and is still better than just relying on playing it to see if you notice any difference between version. However if you were to put an Assert in to notify you of a fail if it goes lower than lets say 5000 in 2 seconds you have a brittle test as it is then contextual to the hardware, not just the implementation. Although that being said these sort of automated tests are only really any use if you are running your tests as some sort of build pipeline i.e Checkout Run Unit Tests Run Integration Tests Run Performance Tests Package So then you can easily compare the stats from one build to another on the CI server as a report of some sort, and again this may not mean much to anyone if you are not used to Continuous Integration. The main crux of this question is to see how people manage this between builds and how they find it best to report upon. As I said it can be subjective but as knowledge will be gained from the answers it seems a worthwhile question.


Scaling Rotating triangle I have a Triangle class and a list of triangles representing my 3D model shape. When I update the position, the rotation or the scale of my model, I also want my triangles list to be updated. I already made the function to update triangle position, but I can't make it for rotation scale... private void UpdateModelTrianglesPos(Vector3 oldPos, Vector3 newPos) Vector3 diff newPos oldPos for (int i 0 i lt trianglesPositions.Count i ) trianglesPositions i .UpdatePosition(diff) Thank you for your help!


MMORPG Server architecture How to handle player input (messages packets) while the server has to update many other things at the same time? This is more or less like what I'm thinking up to now while(true) if (hasMessage) handleTheMessage() But while I'm receiving the player's input, I also have objects that need to be updated or, of course, monsters walking (which need to have their locations updated on the game client everytime), among other things. What should I do? Make a thread to handle things that can't be stopped no matter what? Code an "else" in the infinity loop where I update the other things when I don't have player's input to handle? Or even should I only update the things that at least one player can see? These are just suggestions... I'm really confused about it. If there's a book that covers these things, I'd like to know. It's not that important, but I'm using the Lidgren lib, C and XNA to code both server and client.


How to draw to a surface, then draw that surface to the screen i have a 2D MonoGame Game (using DirectX), that was originally an XNA game. It involves prerendered shadows (they are Texture2Ds drawn with SpriteBatch.draw). Right now the shadows are being drawn with an alpha value, so overlapping shadows appear darker. This is NOT what i want. Overlapping shadows should be the same shade of black. So what i want to do is draw all these shadows to a surface, such that the shadows are completely black (alpha 255), and the surface background is completely transparent (alpha 0), and then take that surface and draw it to the screen using Color.White 0.25f to give alpha to the shadows at the end. I'm not sure how to switch rendering targets, or whatever the terminology is, and go about this. Can someone help? what ive tried so far GraphicsDevice.SetRenderTarget(RENTAR) RENTAR is the name of my RenderTarget2D GraphicsDevice.DepthStencilState new DepthStencilState() DepthBufferEnable true not really sure what this does but it was in examples GraphicsDevice.Clear(Color.White 0.0f) i clear it with a totally transparent white background, in other words, white with alpha 0 now draw shadows normally, but instead of Color.White 0.25f, i use Color.White so that the black shadows are drawn completely black, with no alpha GraphicsDevice.SetRenderTarget(null) switch render target back to the screen SpriteBatch.Draw(RENTAR, new Rectangle(0, 0, 800, 600), Color.White 0.25f) see i added the " 0.25f" to try to draw this texture with alpha, but it comes out totally blank So all of this works except that the shadows end up being completely black. I want them completely black in the RenderTarget, so that they dont overlap with any darker shades, and then i want to draw the final RenderTarget on the screen with an alpha of 0.25f, hence "Color.White 0.25f" in the final spritebatch draw. But its as if that 0.25f doesn't exit.


HLSL Gaussian blur pixelshader blur is not occurring I am trying to use postprocessing to create a gaussian blur, however, no blur is to be seen, what am I doing wrong? I have included the full code at the bottom of this post in a google docs link, but here are the most important bits and pieces. Part of the xna draw method RenderTarget2D renderTarget renderTarget new RenderTarget2D(this.device, screenWidth, screenHeight, true, pp.BackBufferFormat, pp.DepthStencilFormat) this.device.SetRenderTarget(renderTarget) this.device.Clear(ClearOptions.Target ClearOptions.DepthBuffer, Color.DeepSkyBlue, 1.0f, 0) Rectangle screenRectangle new Rectangle(0, 0, screenWidth, screenHeight) Set the effect parameters (the 'simple' technique creates a red lambertian shaded model, like is shown on the image below) effect.CurrentTechnique effect.Techniques "Simple" effect.Parameters "TextureWidth" .SetValue(screenWidth) device.DepthStencilState DepthStencilState.Default device.BlendState BlendState.Opaque Draw the model mesh.Draw() Render our scene this.device.SetRenderTarget(null) effect.CurrentTechnique effect.Techniques "GaussianBlur" spriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect) spriteBatch.Draw((Texture2D)renderTarget, screenRectangle, Color.White) spriteBatch.End() The pixelshader float Pixels 13 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, float BlurWeights 13 0.002216, 0.008764, 0.026995, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, 0.008764, 0.002216, float4 GaussianPixelShader(float2 TextureCoordinate TEXCOORD0) COLOR Pixel width float pixelWidth 1 TextureWidth float4 color 0, 0, 0, 1 float2 blur blur.y TextureCoordinate.y for (int i 0 i lt 13 i ) blur.x TextureCoordinate.x Pixels i pixelWidth color tex2D(TextureSampler, blur.xy) BlurWeights i return color What I have further found out by testing The code in the GaussianPixelShader does get executed (if I set it to just return a black color it gives an entire solid black screen) but just doesn't seem to work do the blurring. Images This is how currently my model looks (I cant see any blurring but maybe the blurring is just too light) image. Full Code Link to the shader code and the link to the xna c code.


Rendering the whole game world I'm trying to create a live minimap of the complete game world. In order to do that I'm taking a snapshot of the whole game world (not only the part that is displayed) every 100ms or so. The code I've used to take the snapshot is this (called every update()) if (game.time.time lt this.nextUpdate) return this.stage.drawFull(game.world) Draw our black border rect this.thumbnail.rect(0, 0, this.thumbnail.width, this.thumbnail.width, ' 000') And copy the stage capture to our Thumbnail (offset by 2px for the black border) this.thumbnail.copy(this.stage, 0, 0, this.stage.width, this.stage.height, 2, 2, this.thumbnail.width 4, this.thumbnail.width 4) this.thumbnail.update() this.nextUpdate game.time.time this.updateRate The code that creates these variable is this (called in create()) The Stage is a BitmapData the size of the Game window this.stage game.make.bitmapData(game.world.width, game.world.height) Thumbnail will hold our scaled down version ( 4px padding for the black border) this.thumbnail game.make.bitmapData(150, 150) And thumbContainer is a Sprite with the thumbnail for its texture this.thumbContainer game.make.sprite(game.width 150, game.height 150, this.thumbnail) Note we add the thumbContainer to the Stage, not the World, to avoid it being captured itself game.stage.addChild(this.thumbContainer) This is the result As you can see in the bottom right minimap The bitmap is rendered but the background isn't rendered for the whole thing (I think it's only rendered properly for the first 800x600 pixels). Also, if the player goes further down to the bottom ledge the minimap messes up completely It seems like a render issue, or a bitmap copy issue, but I can't find the problem. Does anyone have any idea why is this happening? Thanks!


How would I create a shadowy "Fog of War" effect in Game Maker Studio 2? You know if you ever played "StarCraft," as you explore the map it's dark until you go to that area. I am trying to replicate this effect in Gamemaker studio 2. I want to create a shadowed area effect on the map, so that when a "obj player" moves to a darkened area it reveals that part of the map. Here is a picture to help describe the effect i'm trying to achieve


Rendering 10M point that changing position (individualy) at 30Hz i'm able with openTk (vb.net) to draw 10M of points adn rendering it. The problem is that the bind operation take 114mS on every frame refresh. I need to refresh the position at 30 Hz , so what can i use for speeder this operation.


How do I efficiently determine what objects are visible to a camera? I want to call the rendering methods of only the game objects that are visible. How can I efficiently determine which objects or tiles are within the camera's rendered region?


Vulkan PushDescriptorSetTemplates (Can only parts of the UpdateTemplate be updated?) I'm exploring the VkDescriptorUpdateTemplate usage and really like the efficiency in coding this versus individual DescriptorSets, except I have one concern. When making an UpdateTemplate for each shader "program" with multiple UBOs, SSBOs, combined image samplers, etc. and attempting to update a single buffer sampler, I have to update them all based on the template. In reading the specification and googling (not much information on descriptor templates), it isn't clear if there is a way to update only part of the DescriptorTemplate and allow the remainder of the bindings to remain. Quick Code Example (Updating all three buffer sampler bindings). This works but in changing the sampler, I have to rebind the other buffers as well. FDescriptorInfo Sampler(LinearSampler, Tex gt ImageView, VK IMAGE LAYOUT SHADER READ ONLY OPTIMAL) FDescriptorInfo Desc VertexBuffer, CameraBuffer, Sampler vkCmdPushDescriptorSetWithTemplateKHR(Vulkan gt CommandBuffer, Vulkan gt MeshProgram.UpdateTemplate, Vulkan gt MeshProgram.Layout, 0, Desc) If I just want to update the combined image sampler is there a way to only update the 3rd binding? The example below gives validation errors along with attempting to just pass a single DescriptorInfo as there is no way to tell PushDesctiptor which binding I want to update versus all of them in the template. FDescriptorInfo Sampler(LinearSampler, Tex gt ImageView, VK IMAGE LAYOUT SHADER READ ONLY OPTIMAL) FDescriptorInfo Desc 0, 0, Sampler FDescriptorInfo Desc Sampler Also tried this but there is no way to tell vkCmdPushDescriptorSetWithTemplate I'm only updating the 3rd binding. vkCmdPushDescriptorSetWithTemplateKHR(Vulkan gt CommandBuffer, Vulkan gt MeshProgram.UpdateTemplate, Vulkan gt MeshProgram.Layout, 0, Desc) Is it possible to reduce re binding re pushing other buffers when utilizing the DescriptorSetTemplates? Thanks in advance for any advice.


Vertex buffers interleaved or separate? Interleaved all vertex data (position, normal, texcoord...) kept in 1 vertex buffer, separate each vertex attribute is kept in a separate vertex buffer (1 for positions, 1 for normals...). I know this question came up many times and I also know there's no 1 right answer (sadly). But I'd like to try to list the main advantages disadvantages of both. Or maybe you have some general rules of thumb for when to use each. Advantages of interleaved faster? (all data for 1 vertex is fetched at once? sth about cache working better)? less API calls (for creating and setting buffers but that's probably a very small difference) Advantages of separate when different shaders need different vertex attributes (e.g. one shader needs only position and another needs position, normal and texcoord) it's possible to provide each shader only the data it needs and there's no data duplication when updating only e.g. position of vertices it's not necessary to resend the other attribute data (e.g. normals and texcoords) If you see any other differences please write. From the above it generally looks like a struggle between memory and performance optimisation. But maybe I'm wrong? Maybe one is better worse in most cases? Edit One more concern, actually with interleaved buffers I could end up sending unnecessary data to GPU and the data bandwidth is a big bottleneck in today's cards. Should I worry about that?


Converting Cube Maps I have cube maps in lat long format, and i need to convert them to Horizontal Vertical Cross, and individual cross images, is there an utility to do that?


Pygame performance issue for many images I've made a script for generating a game world based off of image pixel data. Trying to make a python map editor My progress so far has resulted in a program which loads an image and draws sprites in positions correlating with the map, like this Now the problem is that even for small levels, I'm noticing a drop in frame rate. The provided example level will make pygame drop from 100 fps to 80 fps. If the map is 40 x 40 the frame rate will be around 17. This is concerning, for two reasons. The program is not doing anything else than drawing images right now, how bad will the frame rate be when game logic is also being calculated every frame? Second, the aim is to ultimately make a two player strategy game, in which the levels would be significantly larger than the example, and in that case 20 frames per second is way below acceptable parameters. Every sprite in the game is a 48x48 pixel png image with some portion of transparency. Everything except rendering the sprites is done once when the game starts. This is the only code being run on every frame def draw(self) self.screen.fill((0,0,0)) for e in self.map layout.fixed list self.screen.blit(e.picture, e.rect) I'm guessing pygame's method for rendering images does not scale very well. Windows task manager shows my CPU utilisation at 2 with a map of size 40x40. My question is What can I do to improve frame rate? I don't mind switching from (or complementing) pygame to something else, so long as the transition is not very difficult for a novice programmer like myself.


Deferred Shading and Transparency Clarification? So, this is a bit of a simple question, but I can't seem to find a real answer anywhere. I've been looking into implementing deferred rendering using MRT into my in progress render engine, but I'm a bit hesitant to for the following reason. I've read in a few places now that deferred shading does not support transparency natively, and if I wanted to achieve transparency, I would need to resort to forward shading of these transparent objects. But, the idea of "transparency" seems a bit vague because it seems as if there might (corrct me if I'm wrong) be two types of transparency. One type being the sort of overlay transparency, where I, say, tile a wall with a brick texture. Then I want the wall to be 50 transparent so I apply that on top of the already textured object. This appears to be one "mode" transparency in which the engine, as part of its rendering pipeline, inserts this transparency manually. The next type in my mind is using a texture that already has an alpha value associated with it, i.e. a 256x256 image of a person, where everything that isn't the person has an alpha value of zero. Then, if I were to billboard that image of the man onto a simple quad (which is what I'm actually trying to do in my game, for reference), would that sort of "native" transparency on the parts of the image with zero alpha still render as transparent, even in a deferred rendering situation? Does such a distinction exist between these two types of transparency, or are they merely two sides of the same coin when it comes to deferred rendering?


Triangle Strips of Tetraheron I am confused about the triangle strip representation of closed mesh .The vertex buffer for triangle strip representation of the a figure is shown below A(0,1) B(0,0) C(1,1) D(1,0)E(2,1) vertex buffer A,B,C,D,E where, T1 (A,B,C) T2 (B,C,D) T3 (C,D,E) Now, if I have a tetrahedron with four vertex A(0,0,0),B(1,0,0),C(0,1,0) and D(0,0,1) then what would be its vertex buffer representation? Thank you very much.


Camera rotation deforms objects I'm working on a ray tracer in C with an adjustable camera for a university assignment. I'm entirely new with graphics and I'm struggling with one thing. I have a matrix as a mat4 object (4x4 matrix with each cell saved in a 1D array) that I save in a Camera object that handles transformations of every point in the scene (which is currently just two spheres). Translations seem to be working fine, but when I attempt rotations, things break. The spheres deform, and it only gets worse the more I attempt to rotate the camera. This is where I set the camera matrix mat4 Renderer setCameraMatrix(const Camera amp camera) mat4 cameraToWorld mat4() Initialise 4x4 matrix. Translation. cameraToWorld.cell 3 camera.pos.x cameraToWorld.cell 7 camera.pos.y cameraToWorld.cell 11 camera.pos.z Rotation. cameraToWorld.cell 0 camera.orientmat.cell 0 , cameraToWorld.cell 1 camera.orientmat.cell 1 , cameraToWorld.cell 2 camera.orientmat.cell 2 cameraToWorld.cell 4 camera.orientmat.cell 4 , cameraToWorld.cell 5 camera.orientmat.cell 5 , cameraToWorld.cell 6 camera.orientmat.cell 6 cameraToWorld.cell 8 camera.orientmat.cell 8 , cameraToWorld.cell 9 camera.orientmat.cell 9 , cameraToWorld.cell 10 camera.orientmat.cell 10 return cameraToWorld This matrix is then used to set the origin and direction of the camera in the world space later on in the code vec3 orig transformpoint(vec3(0), cameraToWorld) ... vec3 dir transformvector(vec3(x, y, 1), cameraToWorld) orig dir.normalize() The transformpoint and transformvector functions basically multiply a vector v by a matrix M (M.v), except the former takes into consideration translations, and the latter doesn't. Their code can be found here. The orientmat matrix is calculated from the three separate orientation angles (orient.x, orient.y, orient.z) in this line of code cam gt orientmat mat4().rotatexyz(cam gt orient.x, cam gt orient.y, cam gt orient.z) Using this function mat4 mat4 rotatexyz(const float a, const float b, const float c) mat4 M const float ca cosf(a), sa sinf(a) const float cb cosf(b), sb sinf(b) const float cc cosf(c), sc sinf(c) M.cell 0 cb cc, M.cell 1 1 cb sc, M.cell 2 sb M.cell 4 sa sb cc ca sc, M.cell 5 1 sa sb sc ca cc, M.cell 6 1 sa cb M.cell 8 1 ca sb cc sa sc, M.cell 9 ca sb sc sa cc, M.cell 10 ca cb return M (This function basically creates this transformation matrix from the three camera orientation angles.) I've tried to keep this question as compact as possible but I can provide more code if needed. I'm completely baffled about why I'm getting this kind of deformation on my spheres, and some insight would be invaluable! Thanks.


What is a texture atlas? I've heard about this concept, but what is it?


Drawing pixels with SDL2 advice, is it fine to draw them one by one on the CPU? I want to make a raycaster and I figured out how to open a window and draw pixels to it with SDL2, but the way I am doing it now just doesn't seem very efficient, I figured out how to do it from briefly reading the documentation. For every pixel in the window, I am going through them one by one, setting the render color with SDL SetRenderDrawColor(), then drawing the pixel with SDL RenderDrawPoint() based on an array. It's surprisingly fast doing this but is there some way I can send like a pixel buffer to the GPU or something? I see there is a SDL RenderDrawPoints (plural version) function but it only takes positions, meaning all the pixels drawn with it would be the same color? I'm looking for a similar function but either it also takes the color data too or it is just a buffer of color data and its index determines its position. Rendering a bunch of pixels that are all the same color doesn't seem very useful to me. I later tested it by fading between colors and with window sizes of more than 600 x 400 the performance is horrible with my method, with 1200 x 800 it is like 5fps.


SDL 2 SDL BLENDMODE BLEND way faster. Why? I was just tinkering around with a simple ecs, when I noticed drawing like 20,000 rectangles killed my framerate ( 10 FPS). I thought ok, maybe it's just too many. Later I wanted to draw them transparent and set the blend mode to SDL BLENDMODE BLEND. Now I can draw around 60,000 of them with 60 FPS. I figured maybe it's because of pixel format conversion or something alike. When I use getWindowPixelFormat I get RGB888. No I'm even more confused because of the lacking alpha channel. Code (abbreviated) SDL Window window SDL CreateWindow( quot Test quot , SDL WINDOWPOS CENTERED, SDL WINDOWPOS CENTERED, 1280, 720, wndFlags) SDL Renderer renderer SDL CreateRenderer( window, 1, SDL RENDERER PRESENTVSYNC SDL RENDERER ACCELERATED) while(running) SDL RenderClear(renderer) SDL SetRenderDrawColor(renderer, 0xFF, 0x00, 0xFF, 0xFF) SDL RenderFillRect(renderer, amp rect) SDL RenderPresent(renderer) SDL SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF) Could someone enlighten me please?


Updating scene graph in multithreaded game In a game with a render thread and a game logic thread the game logic thread needs to update the scene graph used by the render thread. I've read about ideas such as a queue of updates. Can someone describe to a newbie at scene graphs what kind of interface the scene graph exports. Presumably it would be rather complicated. So then how does a queue of updates get implemented in C in a way that can handle the complexity of the interface of the scene graph while also being type safe and efficient. Again I'm a newbie at scene graphs and C .


Books that discuss practical rendering techniques? I'm looking for some books that discuss practical rendering topics like say rendering a bsp level or md2 3 mode, making a little quake like game as the goal or something to that effect. Any recommendations would be much appreciated.


How can state changes be batched while adhering to opaque front to back alpha blended back to front? This is a question I've never been able to find the answer to. Batching objects with similar states is a major performance gain when rendering many objects. However, I've been learned various rules when drawing objects in the game world. Draw all opaque objects, front to back. Draw all alpha blended objects, back to front. Some of the major parameters to batch by, as I understand it, are textures, vertex buffers, and index buffers. It seems that, as long as you are adhering to the above two rules, there's little to be done in regards to batching. I see one possibility to batch, while still adhering to the above two rules. Opaque objects can still be drawn out of depth order, because drawing them front to back is merely a fillrate optimization, meanwhile state changes may very well be far more expensive than the overdraw of drawing out of depth order. However, non opaque objects, those that require alpha blending at least, must be drawn back to front in order to avoid rendering artifacts. Is the loss of the fillrate optimization for opaques worth the state batching optimization?


Rotate around a 3d Object (Software Renderer) I have a simple 3d software renderer (SDL C ) which can load a 3ds Model and render it (shaded) and rotate it around X Y Z Axis. Now I would like to rotate move around the object, meaning, the object itself stands still, and everything in the scene is displayed from the angle of the view. Is that what a camera in 3d engines does, and how would I implement something like this ? (No OpenGL DirectX is used, just plain software)


How do you simulate UV light and materials with UV reflective fluorescent properties within a PBR renderer? I have a PBR setup, say, in Unity (or Unreal, doesn't really matter, I'm asking about the general principle, not specific implementation), and I would like to add a UV light source, and have control over how my materials respond to it, but still ideally have it conform to the rules of physically based rendering. Question is what do I need to extend with what kinds of properties, and what are the equations to wire them together, and where do I plug those? Do I need to actually do modifications like this, or does the fact that it already is PBR mean that I only need to plop in a light source with correct combination of settings, and correct responses to that UV source just naturally happen? Edit I am asking about fluorescence, where I want certain materials to glow in particular visible light colours in places where the invisible UV light hits them.


Forward Shading with multiple shadow casting lights I am currently thinking about how to organize shadowing and lighting. We use forward rendering and currently, our algorithm looks like this collect all items that are visible in the view for each item, collect a list of lights where the item is in the attenuation radius (each item keeps a list of lights) determine the shadow light by the distance of the main character (only one light can currently cast shadow) render the scene by using a constant buffer of the currently processed item to shade it (each item is rendered with a constant buffer which contains light properties. the number of lights per item is predefined so we have a Light 16 and numLights in the constant buffer) How would I do multiple shadow casting lights in an organisatory way? We do not want to go the deferred way, since we dont want to limit us to GBuffers.


Why would you want multiple render targets? In d3d11, you can bind multiple render targets ID3D11DeviceContext OMSetRenderTargets. But why would you want to do this?


Ray casting through terrain mesh Octree ( Mesh collision ) I'm currently in development of a terrain editor which i will use for my game. One thing that is partially stopping my development is that I don't have collision detection implemented between mouse ray cast and the terrain mesh. The terrain is consisted of triangles and can be lowered and raised.Also the x and y values of the mesh don't change. Of course what i need to do is ray cast through my mouse positions and get intersected triangle. I would get the point on the triangle using Barycentric coordinates. Just I'm not quite sure how does octree come into play here. As far as I understand it it works like a 3d quadtree, splitting the box into smaller box that the ray intersects. But which box do i choose ? How do i know which box is the closest one to the terrain, if either raised or lowered terrain ? How many subdivisions would i have? I was thinking on having as much as i have tiles( basically the last level of subdivisions would correspond to a x 3 box). Right now i'm just doing collision with the 0 Z value plane, and it works okay, but if the terrain is a bit raised then this can give faulty results. Other two methods that i found is to iterate through the mesh, which of course is insanely inefficient the other is to project the terrain in reverse and then i guess do some checking with the mouse coordinates (think it's called z buffer checking or something). If anyone has any other ideas i'm all ears. Just note that the algorithm should be an efficient one (of course this depends on the implementation) and accurate. Thanks !


Rendering large and high poly meshes Consider an huge terrain that has a lot polygons, to render this terrain I thought of following techniques Using height map instead of raw meshes Yes, but I want to create a lot of caves and stuff that simply wont work with height maps. Using voxels Yes, but I think that this would be to much since I don't even want to support changing terrain.. Split into multiple chunks and do some sort of LOD with the mesh Yes, but how would I do that? Tessellation usually creates more detail not less. Precompute the same mesh in lower poly version (like Mudbox does) and depending on the distance it renders one of these meshes Graphic memory is limited and uploading only the chunks won't solve that problem since the traffic would be too high. IMO the last one sounds really good, but imagine the following process Upload and render the chunks depending on the current player position. No problem Player will walk straight forward Now we maybe have to change on of the low poly chunk with the high poly one So, Remove the low poly chunk and load the high poly chunk Already to much traffic here, I think I am not very experienced in graphic programming and maybe the upper process is totally okay but somehow I think it is too much. And how about the disk space it would require.. I think 3 kind of levels would be fine but isn't that also too much? (I am using OpenGL but I don't think that this is important)


Unity 5 Mouse Disappears during runtime My mouse cursor disappears during runtime. When I click esc, it appears and the moment I click on something, it disappears again. This is what I have done so far to fix this. I have added this to a script on an empty gameobject in my scene. void Start() Cursor.visible true The problem persists and so I added the code to the update function. Still the same. I do not understand what am I missing here. Why is the cursor disappearing the moment I click and why doesn't it appear automatically onStart during runtime? I have also tried to implement a custom cursor and the same problem again. I am using 5.3.2f. I hope someone can point me in the right direction. Cant find a solution in any forums.


How to create a vertex buffer that provides this pattern? I have a series of vertices that I want to layout with the following configuration, but I haven't been able to find out how to do this with the square and X pattern. Most of the time I have generally seen a quad split into two triangles usually using triangle lists. I suspect this is using triangle strips but I am not exactly sure how to do it. Could anyone help?


How can I create a "cracked glass" material? I'm trying to figure out how the cracked and chipped glass effect in a Bioshock Infinite Burial at Sea Episode 2 works. My current guess is that it is essentially a transparent shader with gloss. It would have a map defining the direction of reflections from the environment, with the cracks being significantly different from the mesh's normals. It would also include some kind of model of the angular dependence of the amount of refraction transmission to reflection so that it can roughly approximate Fesnel's equations. It doesn't appear to be a full refractive model, so I'm wondering how exactly this is implemented? Am I right with what I have said above?


Techniques to mitigate microstuttering when the FPS is above 60fps and vsync is off The problem with first person shooters is that your input is important, and coupling it with VSync ruins it. The following frames per second data when rendering with OpenGL shows 60 100 fps annoying jitter 140 fps minor jitter, but certainly noticeable 200 fps very minor small jitter sometimes 260 fps either generally fine or very very small 300 fps perfectly fine The problem is other games I play that use similar rendering algorithms only stutter in the range of 60 100fps, whereas my range is 60 250fps (albeit it gets better when you get into the 200 range but you can still notice it if paying attention). At first I thought my game loop may have been wrong, but after going through it in great detail it is working just fine (and vsync works perfectly smooth with it too, if it was broken this would be an issue the update rate and the vsync monitor refresh rate are not divisible by each other). 60 100 fps is 62.5 10ms 100 250 fps is 10 4ms Not being able to go above 4ms would be pretty constraining! Because I'm using C (note I have zero GC, it doesn't run), I don't know if this means I'm somehow running into higher variability with the VM than I would when I did stuff in C . I don't know if being in the 4 10ms range means that sometimes it will spike. Now I did profile this, and this is what I've seen Ignoring the green line, the blue line is the uncapped version and orange is vsync. Since the vsync line has massive variability but seems to render fine, whereas the blue one has spikes but are all generally below the vsync line (and definitely not greater than the spikes from vsync), I don't understand whether I'm actually seeing those blue spikes and it's because of some kind of intermediate frame tear or not. It doesn't look like a frame tear to me, it just looks like a frame is lost and I lurch forward a bit more than normal like I was lagging online. So the question is... what can I do to diagnose this issue? Or is this normal? I was thinking of rendering to a framebuffer and just drawing that every 1 60 seconds in an attempt to smooth things out and emulate vsync but this comes with it's own drawbacks. Problem is... my back is against the wall and I'm worried I'll be doing potentially stupid and wasteful stuff. EDIT 1 Ticker code that does what I do (int, double) timerFunc() long currentTime GetCurrentTime() accumulation currentTime lastTimeSeen lastTimeSeen currentTime If it returns 1.27, then we have to run 1 tick, and interpolate at t 0.27 double tickFraction accumulation timePerGametick int ticksToRun floor(tickFraction) double fraction tickFraction ticksToRun if (ticksToRun gt 0) accumulation (ticksToRun timePerGametick) return (ticksToRun, fraction) EDIT 2 Game loop and basic logic (uses timerFunc data from above) void update(int ticksToRun) for i in ticksToRun foreach plane in planes that should move plane.Tick() foreach entity in entities entity.Tick() interpolation will be in 0.0, 1.0) void render(double interpolation) foreach plane in planes planeDelta (plane.current plane.prev) planeInterpolated plane.prev (planeDelta interpolation) render(planeInterpolated) foreach entity in entities entityDelta (entity.current entity.prev) entityInterpolated entity.prev (entityDelta interpolation) render(entityInterpolated) swapBuffers() void gameLoop() while (true) (int ticksToRun, double fraction) timerFunc() pollInput() if (ticksToRun gt 0) update(ticksToRun) render(fraction)


Why is my Tiled map distorted when rendered with LibGDX? I have a Tiled map that looks like this in the editor But when I load it using an AssetManager (full static source available on GitHub) it appears completely askew. I believe the relevant portion of the code is below. This is the entire method the others are either empty or might as well be. private OrthographicCamera camera private AssetManager assetManager private BitmapFont font private SpriteBatch batch private TiledMap map private TiledMapRenderer renderer Override public void create() float w Gdx.graphics.getWidth() float h Gdx.graphics.getHeight() camera new OrthographicCamera() assetManager new AssetManager() batch new SpriteBatch() font new BitmapFont() camera.setToOrtho(false, (w h) 10, 10) camera.update() assetManager.setLoader(TiledMap.class, new TmxMapLoader( new InternalFileHandleResolver())) assetManager.load(AssetInfo.ICE CAVE.assetPath, TiledMap.class) assetManager.finishLoading() map assetManager.get(AssetInfo.ICE CAVE.assetPath) renderer new IsometricTiledMapRenderer(map, 1f 64f)