# tonemgub

Member

439

2009 Excellent

• Rank
Member

## Personal Information

• Role
Technical Artist
• Interests
Art
Audio
Design
DevOps
Education
Production
Programming

## Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

1. ## Basic OpenAL sound manager for your project

Same as Jack, cannot find the source code
2. ## 2D Triangle rasterization algorithm

Hello, I’m writing research paper on software rasterization algorithms and at one point I gave example of triangle rasterization algorithm. The algorithm is really basic. If the triangle is flat top or flat bottom it’s possible to determine the minimum and the maximum x values for each scan line using the equation of line for the edges. Then for each scan line fill the pixels between minimum x and maximum x values. If the triangle is of other kind it’s possible to split it to flat top and flat bottom triangles (finding the fourth vertex) and draw it using the previous algorithm. I need to cite a reference for this algorithm. I saw it in some book in the ‘90s and I can’t just write it without a reference. The problem is that I can’t remember where I saw it. I already tried to look at “Computer Graphics: Principles and Practice” but the only similar algorithm there is the polygon rasterization algorithm, which is over engineered for this kind of problem, same with "Computer Graphics: C Version". I also tried to look at “Black Art of 3D Game Programming”, which have similar algorithm but the algorithm that I saw was in another book and slightly different. Anyone know a book with this kind of algorithm? Any help is appreciated. Thanks.
3. ## Annoying things about Fauerby's and Nettle's sphere-mesh collision detection guides

I don't think these are mistakes. The sliding collision response done with floating point is supposed to move the sphere away from the sliding plane by a small value. Otherwise, the floating point errors would cause the sphere to pass through the plane. The veryCloseDistance value also might not be a mistake. I'm guessing that the veryCloseDistance value is the distance from the plane projected onto the velocity vector. Maybe this value was already available earlier during the algorithm, and it is being used instead of deriving a new value along the normal, which would increase the floating point error effect. The rest of the algorithm probably also does distance calculations based on the velocity instead of the plane normal.   It might be also that the veryCloseDistance is velocity-based in order to stop the sphere from colliding gradually, based on the angle of the velocity vector to the plane. This is because floating point errors cause more trouble at sharper angles. In any case, the velocity veryCloseDistance will never be smaller than the normal-based one, so this is not really going to cause the algorithm to fail. It will just spread the actual collision detection across the next frames, until the veryCloseDistance value is the same as the normal-based value. And from what you said, this is exactly how the algorithm is supposed to work, right?   I haven't read the document though - just guessing.
4. ## VBO problem/weird rendering

I'm not sure if this is the problem but you are storing 4 vertex coordinates of a quad followed by 4 texture coordinates in your vertex buffer. Instead, you should store the texture coordinate corresponding to each vertex immediately after the vertex coordinates of that vertex. I think part of your texture coordinates are being drawn as the vertices which form that weird grid. Your vertex format declaration might also be bad.
5. ## how Nvidia does the balls collision detection in Flex without using a 3D grid?

Volume Tiled Resources. Same as in this demo:   Here's a slideshow: http://developer.download.nvidia.com/assets/events/GDC15/Dunn_Alex_SparseFluidSimulation.pdf

8. ## How to do collision like mario with gap dash?

Actually, I believe this is exactly what Mario used. I played different versions of Mario a lot, and IIRC the player could still fall through gaps even when running, when just speeding up (or when slowing down to normal speed).   Most likely, the gap-skip would happen in only one or two frames, and the gravity didn't have time to kick in in that amount of time. To increase the effect, you could also round the position of the player to integers (and round gravity to lower bounds). I think Mario does this, since it always displays the character at pixel coordinates.
9. ## Need help. 2D Text with transparency, without using ID3DXFont

Why do you want to mimic FlattenPath? Just use something simple, like a multiple of the text size for Bezier resolution (resolution = number of segments, which also defines the final number of triangles). A safe resolution to use would probably be glyph_wdth * glyph_height, since no Bezier curve leaves the glyph's bounding box, and the worst-case scenario for a Bezier would be to cover all of the pixels in the box (just hypothetically - this will never actually happen).   Alternatively, you could always use a constant and high enough Bezier resolution, that it looks good at the highest text size you're going to draw, and it will look ok even when scaled down, even if you do end up with 1000 segments (or triangles) covering the same pixel.   Anyway, like I've been saying - you really have your work cut out for you if you decide to go ahead with tessellating the font data yourself.   If you just want to draw screen-space text, you should use GDI to draw each character into a texture, then use that as a texture atlas for drawing text. I believe this is what you originally intended, and I've also already explained how you can deal with your alpha-blending problem in my first reply. And after investigating a bit, it seems that this is also how ID3DXFont works - it can only be used for screen-space fonts. When I mentioned tessellation, I was thinking of what D3DXCreateText does, not D3DXCreateFontIndirect - I never used any of these myself, only made some assumptions based on the samples I saw, so sorry if I misled you.

12. ## Foliage Collision

It doesn't look like actual collision to me. That would probably be too expensive (but what do I know? :) ).   Google turned up this: http://codea.io/talk/discussion/comment/19977/#Comment_19977
13. ## Need help. 2D Text with transparency, without using ID3DXFont

ID3DXFont does not use GDI. It tessellates font glyphs straight into polygons. That's because GDI is slower.   But anyway, I did implement the exact thing you are trying to once. I used an ARGB texture though, initially filled to black, and after drawing text, I filled the alpha values to 0 "manually" for every black pixel (because I used a black color for SetBkColor). For better performance, you can also use DrawText to get the rectangle of the drawn text, and only fill the alpha values from that rectangle. Clearing the whole texture to black (before getting the DC and drawing the text) should be done on the GPU, since it's probably faster and you can also clear the alpha to 0.0. IIRC, I decided to do it this way because I wanted to experiment with other GDI stuff, like the AlphaBlend function. This way you also have per-pixel alpha, so you can apply different transparency levels to different text drawn on the same texture (but you'd have to implement that separately like I described).   If you don't want to use an alpha channel texture, then you can also do the same thing in a pixel shader. Just return a 0.0 alpha value from your pixel shader, whenever the input texel is black. When it is another color, you can return 1.0 for opaque text, or the value you already have from from the vertices' diffuse color for transparent text. Compared to my method above, this way you will have to draw the text to the texture and the fullscreen quad every time you want to change the transparency of the text, since there's no per-pixel alpha in the texture.     As for setting the blending states: http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-10
14. ## Single pixel holes in GBuffer

Wow. I like that simple explanation a lot. I tried to make sense of this once, but it's way too tedious, and you'd have to be a genius to figure out the side-effects of T-junctions from all that.
15. ## VBE 2.0+ Set Display Start for Page Flipping

I found that info about 7h using memory addresses here: http://www.phatcode.net/res/221/files/vbe20.pdf . Sorry, I thought you were using the same document. Heck, I didn't even know there was a 3.0 version. All PM BIOS VESA functions use memory addresses, IIRC.   I don't know the reason why GetDisplayStart is returning 0 for you. If you change it to something else with SetDisplayStart, does it return the new values?