Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
horriblePencilist
Oct 18, 2012

It's a Dirt Devil!
Get it?

Mooey Cow posted:

You can use Euler angles to define orientations, but they are no good for rotations in general. They represent a composition of three rotations; around the x-axis, the y-axis and the z-axis, but the order of composition is not defined. So a Euler vector of (90,0,90) in one library could be a completely different rotation in a another one.

If what you want is a rotation 90 degrees around the x-axis, it's better to just create a quaternion that directly represents this rotation.

If your algorithm breaks when you rotate the coordinate system, you may have to rotate your rotations as well. This is a hosed up process with Euler angles, but trivial with quaternions; just multiply them together (but make sure you get the order of multiplication right).

I figured it was something like that. How do I figure out the correct values of the appropriate Quaternion?

Adbot
ADBOT LOVES YOU

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug

horriblePencilist posted:

I figured it was something like that. How do I figure out the correct values of the appropriate Quaternion?

Unity has a function for that: Quaternion.AngleAxis. I'm not sure what axes your Euler vectors would translate to though, but maybe your source for the algorithm knows what they should be.

(The formula for that function is also simple: If a is the angle, then the scalar part of the quaternion is cos(a/2), and the vector part is sin(a/2) times your axis vector. From which it is clear that any rotation of 0 degrees is always the identity quaternion (0,0,0,1) ).

If it turns out you do need to rotate your rotations along with the coordinate system, you should send the quaternions as arguments to your recursive function.

horriblePencilist
Oct 18, 2012

It's a Dirt Devil!
Get it?

Mooey Cow posted:

Unity has a function for that: Quaternion.AngleAxis. I'm not sure what axes your Euler vectors would translate to though, but maybe your source for the algorithm knows what they should be.

(The formula for that function is also simple: If a is the angle, then the scalar part of the quaternion is cos(a/2), and the vector part is sin(a/2) times your axis vector. From which it is clear that any rotation of 0 degrees is always the identity quaternion (0,0,0,1) ).

If it turns out you do need to rotate your rotations along with the coordinate system, you should send the quaternions as arguments to your recursive function.

I don't think the definition of the rotations using Euler is the problem - if I create a rotation by multiplying two Quaternions defined by AngleAxis it's the same as if I just used Euler. I tried passing the rotated Quaternions like you suggested, but it's not quite right either.
The first corner is rotated correctly, but after that all subsequent corners have the same orientation. And as before, rotating the gameobject causes the rotations to get mixed up as well. Again, here's the code, I must be getting something wrong.

Absurd Alhazred
Mar 27, 2010

by Athanatos

OneEightHundred posted:

Well, found an efficient way to compress ETC1/ETC2 textures, should have it finished off in a week. It's already like 4x as fast as etc2comp, just need to finish off the SSE2 port and then it'll be probably 20x as fast.

Sweet! How are you licensing it?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Absurd Alhazred posted:

Sweet! How are you licensing it?
MIT license.

Main caveat is it won't support alpha or 11-bit in the initial version.

e: Also it's not good for image types that use weird error metrics that etc2comp supports (like normal maps) and can't support weight-by-alpha.

OneEightHundred fucked around with this message at 06:02 on Feb 5, 2019

horriblePencilist
Oct 18, 2012

It's a Dirt Devil!
Get it?
I finally managed to pinpoint my error: The possible rotations were defined using the default coordinate system, when they needed to be defined with the currently used one. Instead of defining the array at the start of the script, I just had to initialize it within the recursive function.

Now to figure out how to make it work for a dodecahedral structure and come up with a nearest neighbor algorithm :smithicide:

KillHour
Oct 28, 2007


You probably need to depth test those.

Absurd Alhazred
Mar 27, 2010

by Athanatos

OneEightHundred posted:

MIT license.

Main caveat is it won't support alpha or 11-bit in the initial version.

:yosnice:

horriblePencilist
Oct 18, 2012

It's a Dirt Devil!
Get it?

KillHour posted:

You probably need to depth test those.

Oh, this is just the Debug.DrawLine function, it doesn't occlude itself. I just needed a way to visualize the progression.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Well, turns out the speed test had a problem with it, and the SIMD port didn't yield as much as expected.

It's about 2x as fast as etc2comp with default parameters, but quality on par with -effort 100 a.k.a. max quality.

Early version if you want to take it for a spin. Channel weights don't work yet (so it's only comparable to using -errormetric rgbx).
https://github.com/elasota/cvtt/tree/cvtt/ConvectionKernels

Absurd Alhazred
Mar 27, 2010

by Athanatos

OneEightHundred posted:

Well, turns out the speed test had a problem with it, and the SIMD port didn't yield as much as expected.

It's about 2x as fast as etc2comp with default parameters, but quality on par with -effort 100 a.k.a. max quality.

Early version if you want to take it for a spin. Channel weights don't work yet (so it's only comparable to using -errormetric rgbx).
https://github.com/elasota/cvtt/tree/cvtt/ConvectionKernels

Sweet! Can't make any promises, but I'll PM you if I get anywhere with it.

FuzzySlippers
Feb 6, 2009

Is there a high performance way to check collision on a sprite animation that's accurate to transparency? I can create a box that contains just the non-transparent pixels of a sprite frame but obviously it'll still contain a lot of transparent space. Checking the actual pixels on every collision is pretty bad. I can create a mesh tight on the non-transparent shape but doing that every time the sprite changes in an animation isn't great.

How did old games do it? I know Doom has fairly loose collision but was that common? I'm not terribly concerned about extra hits except something like hit particles would look kinda awkward spurting from the empty space under an arm or something.

Setting up hit boxes is kind of a pisser with multi-directional animations as you gotta do that per frame + per direction. I could voxelize them at X accuracy and store that info (then on collision check if the voxel is filled or not) though that's not a trivial amount of data to store for every frame of every animation in every direction.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Most old games just make a slightly small bounding box and don't fuss much about minor inaccuracies. In general, if you err towards being generous to your players, they won't complain.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

TooMuchAbstraction posted:

Most old games just make a slightly small bounding box and don't fuss much about minor inaccuracies. In general, if you err towards being generous to your players, they won't complain.
This, and also if you think about it do you actually want pixel accuracy - should something touching your hair kill you?

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Touching my hair might get you killed 💅

Doc Block
Apr 15, 2003
Fun Shoe
Also if it really is necessary you could always just pre-compute the collision polygons, or use something like Physics Editor.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
There are definitely a bunch of old games (especially on Mac) that had pixel-precision sprite collision checks and used them to sometimes interesting effect where you could dodge things by razor-thin margins. Sprite-sprite overlap checks are cheap, just make a collision bitfield, use bit shifts to line them up, and bitwise-AND the bitfields to see if there's any overlap. Ray-sprite checks can be cheapened somewhat too depending on how aligned the ray is with an axis: You can create series of bits in a register with 3 instructions, bitwise-AND them with the collision bitfield, and even find the collision depth in 1 instruction with CLZ/FFS or equivalent.

Colliding sprite transforms with rotations, determining collision depth of sprite-sprite collisions, and any kind of restitution are much harder though.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
love when platforming depends on where i am in the walk cycle animation

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

Suspicious Dish posted:

love when platforming depends on where i am in the walk cycle animation
The only time when that was okay was Prince of Persia, and that's because it pre-emptively arranged for the animation to be at the right place when you reach the end of a ledge.

FuzzySlippers
Feb 6, 2009

To be clearer this is a first person game and not a platformer.

*snip*

edit: you know with some testing I'm designing here for the extreme edge case of a monster throwing his arms out everywhere. A tight box does almost everything I want. Also, the animation where the hitbox looked worst was a death animation. Oi that's some overthinking it.

FuzzySlippers fucked around with this message at 10:53 on Feb 8, 2019

Doc Block
Apr 15, 2003
Fun Shoe
Maybe determine where on the textured quad you’re hitting, and use the UV coords of the hit to do a check against precomputed 2D collision shapes like you would in a 2D game?

Since they’re precomputed, keeping a different set for each animation frame shouldn’t be that big of a deal, and since you aren’t hit testing them in 3D it should be fast (just testing if the hit point UV coord is inside any of the current frame’s 2D collision shapes).

Lork
Oct 15, 2007
Sticks to clorf

FuzzySlippers posted:

To be clearer this is a first person game and not a platformer.

I wasn't aiming to be absurdly precise but something a bit better than a vague bounding box. Like I'm aiming for the same vague precision you get with a 3d model with large hitboxes parented to the bones. You can score a hit anywhere mostly near the sprite, but say a sprite character has its arms spread out. If I'm doing a bounding box of the visible sprite I end up with all the space under the arms and to the floor as a 'hit'. That seems large enough to be a bit off putting (like watching a hit particle spray from midair next to a guy). I could solve that with a mesh of the outline but doing that for every frame hasn't been great performance (at least how I've been doing it) since these are animated sprites.

I'm not really sure how I grok what OneEightHundred is saying in the context of a 3D space that I'm trying to raycast against.

I know Doom did essentially 2D overhead collision checks (that were fairly simple) but I dunno what other later games with elevation did.
Doom's collision detection was not 2D at least as far as projectiles and bullets went. You could walk under projectiles, for example.

Anyway, here's what the 'hurtboxes' look like in Quake 3:


In Quake 1 they were even bigger and more imprecise. You could draw blood from the empty space in front of an enemy standing around the corner from you. Nobody noticed or cared.

I actually like the reduced emphasis on precision in old shooters and kind of miss not having to worry so much about meticulously placing every shot.

Mooey Cow
Jan 27, 2018

by Jeffrey of YOSPOS
Pillbug
If you're just tracing rays, and don't need full sprite->sprite collisions, then it should be a simple matter of intersecting your ray with the sprite's plane, then transform the hit point to the sprite's local 2D space. Then you can check if the point is even within the sprite's quad, and also get the texture coordinates of that point. You can use those to easily calculate the pixel coordinates and simply check the texture data at that point if it's transparent or not. It will most likely be a lot faster than checking a bunch of polygons.

You'll want to keep the texture data in main memory though; if you have to download it from graphics memory it will not necessarily be very fast.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Mooey Cow posted:

You'll want to keep the texture data in main memory though; if you have to download it from graphics memory it will not necessarily be very fast.

Yeah, and if you want to reduce your memory utilization, you can keep a downsampled texture on the CPU end, at the cost of lower precision.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I've added leaderboards to my game, but how am I supposed to handle usernames like 絕望類型? The font I'm using obviously doesn't have those characters.

Is there a font I can use that just has all the characters? How does this work?

Doc Block
Apr 15, 2003
Fun Shoe

Mooey Cow posted:

You'll want to keep the texture data in main memory though; if you have to download it from graphics memory it will not necessarily be very fast.

A copy of it, yes. Also, a check to see if a 2D point is inside a handful of 2D collision shapes is incredibly fast, and gives you the option of being selective about what non-transparent pixels count as a hit, so you can exclude hair or a cape or a glow effect or whatever.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

baby puzzle posted:

I've added leaderboards to my game, but how am I supposed to handle usernames like 絕望類型? The font I'm using obviously doesn't have those characters.

Is there a font I can use that just has all the characters? How does this work?

The font called Arial Unicode MS works a treat, but that isn't free as far as I can tell.

pseudorandom name
May 6, 2007

Noto is SIL Open Font Licensed.

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
I was looking into that but its like a gig of dozens of files... If there was like a "best hits of Noto" on one file, that would be great.

It is starting to seem like this isn't something I can support, and that some users are just going to see squares instead of their names.

roomforthetuna
Mar 22, 2005

I don't need to know anything about virii! My CUSTOM PROGRAM keeps me protected! It's not like they'll try to come in through the Internet or something!

baby puzzle posted:

I was looking into that but its like a gig of dozens of files... If there was like a "best hits of Noto" on one file, that would be great.

It is starting to seem like this isn't something I can support, and that some users are just going to see squares instead of their names.
I think the least-bad way to deal with this is to do one of:
1. check that all characters in a string exist in the font you're using, and if not, search fonts on the current system for one that does support the string and then use that. I found this for a way to do that, it's super gross.
2. check that all characters in a string exist in the font you're using, and if not, make the user enter a different string for their name so you can still use your font.
3. always make the user enter a string for their name, and don't accept any characters that aren't in your font (a lot of games limit to just the ASCII characters).
4. Just let them see squares.

These are in order of best to worst, and also coincidentally in order of hardest to easiest!

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.
Your number 1 is what I was thinking I'd have to do... probably the correct way. These are steam usernames so I have no way to control their contents.

pseudorandom name
May 6, 2007

Noto Sans Regular is like ~30 MB, less if you filter out the non-UI variants for the languages that have UI variants (which I didn't bother to do).

baby puzzle
Jun 3, 2011

I'll Sequence your Storm.

pseudorandom name posted:

Noto Sans Regular is like ~30 MB, less if you filter out the non-UI variants for the languages that have UI variants (which I didn't bother to do).

Where do you get that from? NotoSans-Regular.ttf from the google font site is only 406kb and doesn't support these characters.

e: Oh are you talking about using a bunch of different ttf files and not just one?

pseudorandom name
May 6, 2007

Yeah, the Unicode coverage is spread out across a bunch of different font files.

Absurd Alhazred
Mar 27, 2010

by Athanatos

pseudorandom name posted:

Yeah, the Unicode coverage is spread out across a bunch of different font files.

Might as well call it Multicode at this point.

pseudorandom name
May 6, 2007

One code to rule us all...

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

Absurd Alhazred posted:

Sweet! Can't make any promises, but I'll PM you if I get anywhere with it.
Moved it to a stand-alone repository (outside of the DirectXTex fork it was originally created in):
https://github.com/elasota/ConvectionKernels

Also false alarm on the underwhelming speed: There was a bug making the error calculations (which is the vast majority of the processing time) take 3 times as long. :downs:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

baby puzzle posted:

Your number 1 is what I was thinking I'd have to do... probably the correct way. These are steam usernames so I have no way to control their contents.

The "real" system here is something known as a "font shaping engine", where you feed it a string of code points and it comes back with a bunch of font/glyph pairs (along with their location). Harfbuzz is the open-source one and it's decently simple to use. Pair it with a font renderer like stb_truetype.h for something quick and easy.

xgalaxy
Jan 27, 2004
i write code
Its not free but Slug is pretty awesome: http://sluglibrary.com
I recently learned that Path of Exile now uses it.

Adbot
ADBOT LOVES YOU

Absurd Alhazred
Mar 27, 2010

by Athanatos
Bad news:

https://twitter.com/eevee/status/1095149563562811392

I hope this is just an unfounded rumor.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply