Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 14 Mar 2008
Offline Last Active Today, 03:47 PM

#5310761 Edge smoothing

Posted by on 14 September 2016 - 09:10 AM

I'm looking to smooth out lighting discontinuities around hard edges when drawing low resolution geometry:


I considered blurring normals in screen space (or somehow mark hard edges), but as that seemed both expensive (large kernel sizes etc.) and prone to rendering artifacts, I opted for an edge bevel algorithm that operates on the actual geometry. Essentially, it lays out an additional strip of detail around a hard edge to secure its unwelded normal orientation, then smooths the normals of vertices on the original edge:


This properly softens the edges, but it does result in an almost x2 increment of vertices needed. (It's actually more, as lights that render shadow maps can still use the unbeveled geometry since I don't displace any vertices on the bevel).
I think it's a fair tradeoff, but I still wonder if this can somehow be done without creating any additional geometry. It seems to boil down to knowing the distance to the nearest hard edge from any point (pixel) on a mesh and blend normals based on that. Though I fear that would either require a lot of connectivity information tied to the mesh, or a search in screen space.

#5290640 Getting the look vector of a Matrix when the current rotation is 1.57(x-axis)

Posted by on 08 May 2016 - 07:15 AM

"D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);"


You're grabbing the third column from the matrix there, not the third row.


So the identity matrix transformed by a 1.57 rad rotation around the Y-axis results in:

0 0 [-1]

0 1 [0]

1 0 [0]

#5287013 My game uses "Tech" as a currency, what should it look like?

Posted by on 15 April 2016 - 04:40 AM



I like the microchip idea best too.

#5268705 Random Circles in a Circle

Posted by on 01 January 2016 - 08:27 AM

Sounds like you need something like a Poisson disc sample set: https://www.jasondavies.com/poisson-disc/


This can be used to distribute sample points with a minimal distance within a boundary.


Mitchell's Best Candidate algorithm might also work well: http://bl.ocks.org/mbostock/1893974

#5260288 Texture bleeding/tearing with UV texture atlas mapping

Posted by on 03 November 2015 - 05:33 AM

This is usually solved by making texels around uv-borders extend/bleed over said edges - enough to make sure there are never any outer 'undefined' texel values involved in a filtering operation.


- If you're baking this texture, modelling apps often have an option to 'expand uv-borders'.

- If your texture comes with an alpha map, one quick trick is to place a slightly blurred duplicate of the texture underneath the image. Or write a script that for any texel with a zero-alpha value duplicates the RGB value of the nearest texel with a non-zero alpha value.

#5245433 Tinted bloom?

Posted by on 10 August 2015 - 06:06 AM

The issue is, I'm not terribly sure where to put the disc center. All I got is a light direction for the "sun", not a position. All of this ties in with something else I have yet to implement, rendering the glowy sun disc, so no idea how to do that.


If any ray parallel to the light direction hits the sun in its exact center, regardless of where it originated or its length, then you'll have to define the size of the disc as a minimum of the dot product of the ray and the light-dir. e.g.: if(-dot(ray, light) > 0.98) hitsDisc();


Two of these discs slightly apart (that is, have near perpendicular light directions), one reddish/yellow the other a blue tint, added together should give white light in in their overlapping areas.

#5245080 Tinted bloom?

Posted by on 08 August 2015 - 06:53 AM

I'm not sure it's bloom/lens related. It seems the light has already been shifted somehow before it's reflected on the water surface and reaches the camera - that's why it looks upside-down. 


I would reflect the ray from the camera to the surface back to the light source, then colorize it based on where it hits the light disc.


Excess light is then blurred/redistributed afterwards.

#5229879 Triangulation

Posted by on 19 May 2015 - 12:34 PM

Any movement of vertices may cause connected triangles to flip around, so you'll have to check for that. Also it may no longer be the most optimal triangulation (slivers etc.).

#5225125 Collision Detection and Camera movement. C#/Monogame

Posted by on 23 April 2015 - 02:46 PM

1. Store an array of structs/classes instead of an array of integers. Every struct can contain a series of variables, including the index to the sprite, but also other properties like a boolean that tells a cell's collision condition.


2. Create a virtual camera. In this case that can simply be a pair of x, y coordinates. When you draw the playing field from bottom to top, you add these coordinates to an array indexing offset.


e.g.: for(y = 0; y < 25; ++y) for(x = 0; x < 25; ++x) cells[x + camera.x][y + camera.y].drawAt(x, y);


When moving the mouse cursor over the edge of the playing field, you can slowly increase/decrease the camera's .xy values.

#5203080 Cutting polygons by a grid.

Posted by on 09 January 2015 - 07:25 AM

Simplest alternative to clipping would be to generate a triangulated volume of the boundary (if you don't already have a volumetric representation) using something like poly2tri. Then subdivide the mesh until all its edge lengths are below a certain threshold (to prevent too much distortion when you map its vertices to a sphere). If the map itself is triangulated you don't have to draw the sphere underneath it, avoiding possible intersection/z-fighting issues.

#5154069 How to draw [these kind of] splines?

Posted by on 16 May 2014 - 12:01 PM

I suspect you'll be able to draw such a spline as a Hermite curve using only an outgoing and an incoming set of positions and (flat/horizontal) tangents.


You can use the Hermite routines that come with the D3DX-library.




Or you can use the cubic equations mentioned there directly.

#5152704 High Speed Quadric Mesh Simplification without problems (Resolved)

Posted by on 10 May 2014 - 11:23 AM

Based on what criteria do you prioritize one contraction over the other? I don't see you (re-)sorting the list of triangles.

#5152524 Aligning a path, along a another dynamically

Posted by on 09 May 2014 - 07:47 AM

This is probably easiest when the underlying road structure is defined as a network of interconnected splines. That way the center of the road and its tangent/direction are exactly defined. Also, you can do distance tests between the (tessellated) curve and surrounding points to see whether such points lie on the road. Lastly, a user-defined route becomes a simple series of (spline-)key-points.

#5151122 Having trouble with my Vertex Element Class

Posted by on 03 May 2014 - 02:54 AM

What are the VertexElements you feed it with? Do elements that share the same semantic-name have individually unique indices? A name + index pair defines a unique semantic.


It would be less error sensitive if you don't have to specify a semanticIndex, but calculate it based on the number of previous occurrences of the same name.

#5149175 D3DXMatrixLookAtLH vs Custom View Matrix

Posted by on 24 April 2014 - 09:26 AM

So basically the cross product for LH matrix doesnt seem to follow right hand thumb rule but rather left hand convention?


Yup. m_vecLookAtPoint faces away from you, so cross(LookAt, Up) would point to the left.