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
Linear Zoetrope
Nov 28, 2011

A hero must cook

TerraGoetia posted:

Trying to compute line of sight is causing me headaches. I wrote something up based on what I remember from high school algebra, but I end up seeing through walls sometimes. I want line of sight to be useful for targeting ranged abilities, so I can't pass it off as a quirk.

Generally the way you want to be checking LOS is to verify if the target is in the view frustum (basically, within max distance and view angle) of the entity doing the check, and, if so, run something like a Bresenham test between them for any colliders like walls. If objects can fall in multiple buckets, or you have things like windows, you may want to do multiple Bresenham checks between the point you chose as your entity's "eye" and every cell the target's body inhabits.

Obviously this won't test for things like really tiny windows unless you make your cells equally tiny, and Bresenham is coarse grained so it may give false negatives. You can always tweak cell size or do bonafide ray casting when you get a negative to double check. There's a lot of ways you can optimize LOS tests depending on the specifics of your game.

E: Note, Bresenham has issues around diagonals. You can skirt around this by "thickening" the line to its neighboring cells around where its error is under 0.

Linear Zoetrope fucked around with this message at 07:00 on Jan 8, 2018

Adbot
ADBOT LOVES YOU

Tiler Kiwi
Feb 26, 2011
Depending on the context, like in some top down 2d game or something involving tiles, LoS can get kind of weird if you just rely on drawing lines. If thats the kind of problem you're dealing with, this might lead you to something useful.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
How crazy are you Unity people getting with the MonoBehaviours? For my ring menu, I wanted to add a basic zoom-in/zoom-out effect when opening/closing the menu. I could just slap a pile of conditional logic and supporting variables to fuss over that in ring menu GUI code, but I want to just throw some little MonoBehaviours around like candy to take care of this for me.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

How crazy are you Unity people getting with the MonoBehaviours? For my ring menu, I wanted to add a basic zoom-in/zoom-out effect when opening/closing the menu. I could just slap a pile of conditional logic and supporting variables to fuss over that in ring menu GUI code, but I want to just throw some little MonoBehaviours around like candy to take care of this for me.

Small is good, generally. the overhead for a MonoBehaviour isn’t huge, and being able to re-use them is extremely useful.

In my current project at work, things like that are either handled by a Unity animation or a tween behavior. I generally prefer the tweens unless the animation is complex in some way.

Spatial
Nov 15, 2007

DDA is the right tool for the job. It doesn't skip and touches the minimal number of cells.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

leper khan posted:

I generally prefer the tweens unless the animation is complex in some way.
How are you doing tweens in Unity?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

How are you doing tweens in Unity?

At work we have a small lib someone here wrote with a bunch of MonoBehaviours. On my personal projects usually I use http://dotween.demigiant.com or similar.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

leper khan posted:

At work we have a small lib someone here wrote with a bunch of MonoBehaviours. On my personal projects usually I use http://dotween.demigiant.com or similar.
Is the non-pro version sufficient or did you put out the dinero?



Alright, maybe it's time I asked that question: What assets are people finding useful? I'm wondering how many wheels I'm reinventing or accidentally about to reinvent.

I'm currently getting a lot of use out of:
The ProTools Suite
InControl
Ink Unity Integration
UI - Builder: Got on the cheap and haven't really gotten into this yet...
Unity Test Tools
TextMesh Pro
Unity Logs Viewer

Things I probably shouldn't have written and reused:
My memoization/serialization suite
The dialog system I created to interface with the Ink engine
I suspect my timing system is dumb and implemented 5,000 times better 5,000 times before
I wrote my own pathfinding stuff but I suspect this one was hard to dodge. I'm doing top-down 2.5d and wanted to auto-build my network based on my level data. I just couldn't find anything I trusted.

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you
Does this video demonstrate sufficiently good enough ability as a gameplay programmer? In other words, is it "portfolio worthy"? I've been posting progress on it for the past couple of weeks in the Games thread and on the AwfulJams Discord server. Altogether, I've clocked about 35 hours of time investment and productivity into the project. I also put it in its current state on my Github thing for portfolio purposes and I want to show it to you guys and get your opinions on whether it's sufficiently "portfolio material" as a gameplay programmer.

https://www.youtube.com/watch?v=D97kQJAYswY

Here's my Trello board that I've been using to manage the project: https://trello.com/b/1TP9El03

Basically I need someone to tell me that I am still poo poo at programming or that I'm officially "good enough" on the "you must be this good to even think about getting a job doing this kind of thing for a living" scale.

Love Stole the Day fucked around with this message at 21:06 on Jan 8, 2018

Boz0r
Sep 7, 2006
The Rocketship in action.
For some reason I can't post on the UE forum so maybe you guys can help me.


I'm trying to compile the UT source by following this guide.

When I try to build the Agent project I get an error:
code:
Error    CS0103    The name 'Properties' does not exist in the current context    UnrealControls    E:\Projects\UnrealTournament\Engine\Source\Programs\UnrealControls\XButton.cs    34    Active
The code in question looks like this:
code:
        public XButton()
        {
            InitializeComponent();

            Bitmap template = Properties.Resources.XButton;				// This is where the Properties reference gives me an error
            mXBitmap = template.Clone(new Rectangle(0, 0, template.Width, template.Height), template.PixelFormat);
            mXBitmap.MakeTransparent(Color.White);
        }
What have I missed?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

Is the non-pro version sufficient or did you put out the dinero?



Alright, maybe it's time I asked that question: What assets are people finding useful? I'm wondering how many wheels I'm reinventing or accidentally about to reinvent.

I'm currently getting a lot of use out of:
The ProTools Suite
InControl
Ink Unity Integration
UI - Builder: Got on the cheap and haven't really gotten into this yet...
Unity Test Tools
TextMesh Pro
Unity Logs Viewer

Things I probably shouldn't have written and reused:
My memoization/serialization suite
The dialog system I created to interface with the Ink engine
I suspect my timing system is dumb and implemented 5,000 times better 5,000 times before
I wrote my own pathfinding stuff but I suspect this one was hard to dodge. I'm doing top-down 2.5d and wanted to auto-build my network based on my level data. I just couldn't find anything I trusted.

Biggest productivity gain I bought for myself in a team setting is “Console Pro” (though I’ve has some issues with the remote console which seems like it would be nice).

I also like Odin Inspector, but my office hasn’t (and likely won’t) spring for licenses for the team.

TextMeshPro is a must have, and now free :D

Unity Test Tools has since been rolled into the engine proper iirc. I shamefully use it less often than it warrants.

Ranzear
Jul 25, 2013

leper khan posted:

TextMeshPro is a must have

Unless you want Chinese or extensive Japanese support :argh:

BirdOfPlay
Feb 19, 2012

THUNDERDOME LOSER

Boz0r posted:

For some reason I can't post on the UE forum so maybe you guys can help me.


I'm trying to compile the UT source by following this guide.

When I try to build the Agent project I get an error:
What have I missed?

I'm not an Unreal dev, but I'm confused. You have a C# file and C# error, but your guide doesn't mention C# at all. Is this supposed to be a C++ class/file? If it's supposed to be C#, how are you using C# in UE?

Love Stole the Day
Nov 4, 2012
Please give me free quality professional advice so I can be a baby about it and insult you

BirdOfPlay posted:

I'm not an Unreal dev, but I'm confused. You have a C# file and C# error, but your guide doesn't mention C# at all. Is this supposed to be a C++ class/file? If it's supposed to be C#, how are you using C# in UE?

Because with UE4, you use C++ for everything except the sort of project "metadata" stuff, which is done in C#. So every UE4 project has a few .cs files in there whose only purpose is to configure the engine. Don't know why they use C# for it, really. Also I don't know what's up with his issue, but it probably has something to do with that somehow?

BirdOfPlay
Feb 19, 2012

THUNDERDOME LOSER

Love Stole the Day posted:

Because with UE4, you use C++ for everything except the sort of project "metadata" stuff, which is done in C#. So every UE4 project has a few .cs files in there whose only purpose is to configure the engine. Don't know why they use C# for it, really. Also I don't know what's up with his issue, but it probably has something to do with that somehow?

:what:

Because I'm stupidly helpful, I signed up for the UnrealEngine source on Github. And, wow, this stuff is from the source and is C#. Sorry about that.

First, is the body of XButton.cs in the UnrealControls namespace*? Next, do you have "Resources.Designer.cs" in ".../Programs/UnrealControls/Properties? Finally, does that define the UnrealControls.Properties namespace?

*If you're unfamilar with C# you should see something like this after the using's:
code:
namespace UnrealControls {
...
}
If all that checks out, it could be that your build is missing the includes for some of these files/directories. I've always struggled with setup for VisStudio, so I can't help you there. Still, it's odd how your base setup is bugged like this.

xgalaxy
Jan 27, 2004
i write code

Boz0r posted:

For some reason I can't post on the UE forum so maybe you guys can help me.


I'm trying to compile the UT source by following this guide.

When I try to build the Agent project I get an error:
code:
Error    CS0103    The name 'Properties' does not exist in the current context    UnrealControls    E:\Projects\UnrealTournament\Engine\Source\Programs\UnrealControls\XButton.cs    34    Active
The code in question looks like this:
code:
        public XButton()
        {
            InitializeComponent();

            Bitmap template = Properties.Resources.XButton;				// This is where the Properties reference gives me an error
            mXBitmap = template.Clone(new Rectangle(0, 0, template.Width, template.Height), template.PixelFormat);
            mXBitmap.MakeTransparent(Color.White);
        }
What have I missed?


Is it possible you downloaded 'develop' or 'master' instead of the one of the 'release' branches?
Also make certain you ran the appropriate bash/shell scripts to download third party sources and other files.

Polo-Rican
Jul 4, 2004

emptyquote my posts or die
Can any Unity people help me out with a simple script? I'm trying to store references to enemies and to the controller script components attached to each enemy.

This code gives me: "NullReferenceException: Object reference not set to an instance of an object"

code:
private GameObject[] enemies = null;
private MonoBehaviour[] enemycontrollers = null;
...
for(int a=0;a<5;a++){
	GameObject oneenemy = Instantiate (enemy, new Vector3(a*3,0,5), enemy.transform.rotation) as GameObject;
	enemies [a] = oneenemy;
	MonoBehaviour thiscontroller = oneenemy.GetComponent<EnemyController> ();
	enemycontrollers [a] = thiscontroller;
}
The below code DOES partially work, but it's stupid. Also, I'm able to store references to the enemies with this method, but still can't figure out a way to store references to the scripts inside the enemies.

(I can make the game work this way by finding the scripts at runtime with GetComponent in the Update function, but I've heard that it's much better for performance to store references.)

code:
private GameObject[] enemies = null;
private MonoBehaviour[] enemycontrollers = null;
...
for(int a=0;a<5;a++){
	GameObject oneenemy = Instantiate (enemy, new Vector3(a*3,0,5), enemy.transform.rotation) as GameObject;
	oneenemy.tag = "GameEnemy";
	// MonoBehaviour thiscontroller = oneenemy.GetComponent<EnemyController> ();
	// enemycontrollers [a] = thiscontroller;
}
enemies = GameObject.FindGameObjectsWithTag("GameEnemy");

Polo-Rican fucked around with this message at 05:07 on Jan 9, 2018

BirdOfPlay
Feb 19, 2012

THUNDERDOME LOSER

Polo-Rican posted:

Can any Unity people help me out with a simple script? I'm trying to store references to enemies and to the controller script components attached to each enemy.

This code gives me: "NullReferenceException: Object reference not set to an instance of an object"

code:
private GameObject[] enemies = null;
private MonoBehaviour[] enemycontrollers = null;
...
for(int a=0;a<5;a++){
	GameObject oneenemy = Instantiate (enemy, new Vector3(a*3,0,5), enemy.transform.rotation) as GameObject;
	enemies [a] = oneenemy;
	MonoBehaviour thiscontroller = oneenemy.GetComponent<EnemyController> ();
	enemycontrollers [a] = thiscontroller;
}
The below code DOES partially work, but it's stupid. Also, I'm able to store references to the enemies with this method, but still can't figure out a way to store references to the scripts inside the enemies.

First things first, I'm assuming that the NullRef is firing on the GetComponent line, because that's the only time that you're doing anything with a reference. The simple assignment lines wouldn't do that and the Instantiate call is identical between the two snippets.

This would mean that oneenemy isn't a valid reference. This could be because enemy isn't a GameObject and the as operation would result in a null.

If I'm wrong about my assumption, which line is causing the NullRef?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Ranzear posted:

Unless you want Chinese or extensive Japanese support :argh:

Doesn’t it work if you shove all the glyphs you need into the font generator?

I was able to get Arabic working a few years ago, even with their different chars for in the middle of words or not.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Polo-Rican posted:

Can any Unity people help me out with a simple script? I'm trying to store references to enemies and to the controller script components attached to each enemy.

This code gives me: "NullReferenceException: Object reference not set to an instance of an object"

I'm just looking in and I don't know anything about Unity, but are you creating those arrays somewhere before you try and assign to them?

Lork
Oct 15, 2007
Sticks to clorf

baka kaba posted:

I'm just looking in and I don't know anything about Unity, but are you creating those arrays somewhere before you try and assign to them?
I do know some things about Unity and that was my assumption at a glance as well. Remember that you can double click on the exception output in the Unity editor and it'll take you right to the offending line, which should aid in pinpointing the issue.

Polo-Rican
Jul 4, 2004

emptyquote my posts or die
I fixed the problem.

Originally I'd just defined the array at the top of my code like this:

code:
private GameObject[] enemies = null;
It turns out that, if you do that, you can't directly add stuff at indexes (enemies[0] = whatever) until you initialize the array like so:

code:
GameObject[] enemies = new GameObject[10];
I was being thrown off because, when looking at the error in the console, I mistakenly thought the GameObject I was instantiating was reading as null for some reason, when the problem was actually with the array not being initialized. Additionally, you don't need to initialize the array if you fill it using FindWithTag (enemies = GameObject.FindGameObjectsWithTag("Enemy"));

One thing that sucks about Unity is the amount of bad advice out there. If you google lots of issues, you find so much bad code!

Polo-Rican fucked around with this message at 16:30 on Jan 9, 2018

Ranzear
Jul 25, 2013

leper khan posted:

Doesn’t it work if you shove all the glyphs you need into the font generator?

I just know there are far too many to fit in one, let alone a dozen, textures. If we were making a game about dragons, we would actually have been missing 竜

The prior solution was to constrain the writers to a limited Japanese character set, but that won't work for Chinese. Don't even get me started on emoji support.

Rasterizing entire fonts to a texture should be a crime.

Ranzear fucked around with this message at 19:53 on Jan 9, 2018

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Update on this:

leper khan posted:

At work we have a small lib someone here wrote with a bunch of MonoBehaviours. On my personal projects usually I use http://dotween.demigiant.com or similar.

I gave this a shot this morning and was impressed. I was able to consolidate a bunch of bullshit code and state from a MonoBehaviour and encapsulate everything I needed to do in one tween.

In particular, I tried it for the code I ran when closing the ring menu. I wanted the menu to "zoom out" by having the scale transform go from 1x to 0x over a very short duration. Before this I needed to track when I told it to close and interpolate across that in Update() to do the scaling. Once the animation finished, I wanted to unpause and hand control back to the main game. I was able to put all that code in a OnComplate callback in the tween declaration. It put all the code nicely in one spot and got rid of all the crap variables I was using to do all this across the file.

What depresses me is that I didn't even really know what a tween was before this, and I was able to embark on my own code to move across variables over a time span.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Ranzear posted:

I just know there are far too many to fit in one, let alone a dozen, textures. If we were making a game about dragons, we would actually have been missing 竜

The prior solution was to constrain the writers to a limited Japanese character set, but that won't work for Chinese. Don't even get me started on emoji support.

Rasterizing entire fonts to a texture should be a crime.

If you have the source version of TMP, you can probably make multiple atlases and index into each one based on the character you’re looking at. Definitely not a simple thing I guess.

SDF fonts basically require you to render into a texture though, so :shrug:
They’re really great for most other languages.

Boz0r
Sep 7, 2006
The Rocketship in action.
I downloaded the newer version of UE and plopped it into the UT project and it compiles. I hope it doesn't break anything.

Spek
Jun 15, 2012

Bagel!
Anyone ever implemented on gpu octrees? I'm looking at https://developer.nvidia.com/gpugems/GPUGems2/gpugems2_chapter37.html and cannot make heads or tails of it. Specifically the part about how it's stored on the gpu/the lookup shader quoted in that article. Even with the source, which is here: http://http.download.nvidia.com/developer/GPU_Gems_2/CD/Index.html , I cant figure out what's going on. That the file that handles the actual octree structure (CHrdwTree) is essentially uncommented and confusingly written doesnt help. (nor does that I havent used c++ in like 5 years :( )

I don't understand how the shader is ever getting a child octant, it looks to me like the IndirPool from tree_lookup() in the shader files just takes one sampler3D, which is just 2x2x2 if I'm reading the article right, so wouldnt offer the resolution that the application is clearly getting. But I dont get it, should I be using an array of 3d textures? If so how is the lookup function from the article going from one sampler3d to the next, and wouldnt creating hundreds, if not thousands or even tens of thousands, of small 3d textures be horribly inefficient? I feel like it's doing something trickier than that but I cant figure it out.

At any rate I'm trying to get this whole concept running in Unity but I've hardly any clue how to handle the cpu-gpu communication for this sort of thing. Any help is appreciated.

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!
Out of curiosity, why is it so normal to put fonts into textures, and so not normal to transform truetype fonts into triangles in a vertex buffer on the fly? Seems like triangle-based fonts would have a lot more flexibility rendering-wise, and you'd be able to just use truetype font files and a not that complicated library for the transformation. I realize truetype has curves in it, but at font scales most curves could be readily approximated as like 4-6 straight lines. The 'holes' in truetype fonts make for trickier transformation, but I've done that kind of transformation, it's not like it's an intractable problem.

TerraGoetia
Feb 21, 2011

A cup of spiders.
Thanks for the advice. I found that I was able to program Bresenham's Algorithm for my line of sight based on the notes at https://csustan.csustan.edu/~tom/Lecture-Notes/Graphics/Bresenham-Line/Bresenham-Line.pdf.

I've had some irregularities regarding seeing behind "around" some walls, but only if I'm looking at them from a north-south perspective. I can probably just design my level's sight line around these issues and test carefully.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Polo-Rican posted:

I fixed the problem.

Originally I'd just defined the array at the top of my code like this:

code:
private GameObject[] enemies = null;
It turns out that, if you do that, you can't directly add stuff at indexes (enemies[0] = whatever) until you initialize the array like so:

code:
GameObject[] enemies = new GameObject[10];
I was being thrown off because, when looking at the error in the console, I mistakenly thought the GameObject I was instantiating was reading as null for some reason, when the problem was actually with the array not being initialized. Additionally, you don't need to initialize the array if you fill it using FindWithTag (enemies = GameObject.FindGameObjectsWithTag("Enemy"));

One thing that sucks about Unity is the amount of bad advice out there. If you google lots of issues, you find so much bad code!

There's a few fundamental misunderstandings here that are gonna get you in a lot of trouble down the road, let's sort that out!

So first of all, null represents nothing. It's like a special object that means "there's nothing here". It definitely isn't an array, so you can't assign values to it, which is what you were trying to do. It's ok to set a variable as = null, but you need to make sure you've set it to an actual instance of your object before you try and treat it as one, or you get that crash (which is really there to help you find and fix the problem, when you're trying to do something that doesn't make sense). That's what you're doing in your solution where you call new GameObject[], that's why it works - enemies is set to an actual array now, instead of null

The second point ties into that - when you go
code:
private GameObject[] enemies = null;
you're not creating an array. There are two things happening here - on the left side, you're creating a variable, private GameObject[] enemies. That is basically just a label, called 'enemies', and you're saying it's going to point at something that should be treated as a GameObject[]. You're just creating the label, not the actual array it's going to point at

The equals obviously assigns a value to that label, you're telling it what object to point at, basically. So the right hand side is where you provide that object - you can create one with new, or call a function that returns a GameObject[], or put another GameObject[] variable there (so both labels end up pointing to the same object), or put null if you don't actually want to assign an actual object. Point is, if you want to create an array, it happens on the right side of that assignment.

So private GameObject[] enemies = null; creates a label for a GameObject array but points it at null, so that's what you get when you try and access it.

GameObject[] enemies = new GameObject[10]; creates the label, but also creates an actual array object, and then points the label at it. So this works when you try and access it as a real array!

enemies = GameObject.FindGameObjectsWithTag("Enemy"); is taking the label which you've already created (otherwise it wouldn't know what 'enemies' even refers to), calling that method that returns an array of GameObjects, and pointing the label at the array it produces. Now there's an array there and you can use it

You don't actually need to set the variable to anything when you create it, you can just do the left hand side bit and create the label -
code:

GameObject[] enemies;
That's different to assigning null to it - you haven't assigned anything yet, it doesn't point at anything*, you'll get a compiler error if you try and read it before you set it. null is different, it's an actual valid object you can assign and read, it's just a special one that doesn't do anything, it just represents a lack of a real instance.


That was way longer than I meant it to be but I don't have time to cut it down, I hope it makes sense! I'd honestly recommend going through something like the banana book and just getting a handle on the language and the core stuff you need to be aware of. It'll definitely help you fight through all the bad advice and code examples



*C# sets fields (the top level variables in your class) for object references to null if you don't assign anything - bla bla technical language stuff, point is you don't need to set a thing to null unless you want it to be null, say as a default value. Just creating the label can make your intent clearer since you're explicitly not giving it a value just yet

Suspicious Dish
Sep 24, 2011

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

roomforthetuna posted:

Out of curiosity, why is it so normal to put fonts into textures, and so not normal to transform truetype fonts into triangles in a vertex buffer on the fly? Seems like triangle-based fonts would have a lot more flexibility rendering-wise, and you'd be able to just use truetype font files and a not that complicated library for the transformation. I realize truetype has curves in it, but at font scales most curves could be readily approximated as like 4-6 straight lines. The 'holes' in truetype fonts make for trickier transformation, but I've done that kind of transformation, it's not like it's an intractable problem.

delaunay triangulation is O(n^3). and often times, a lot of triangles is a bad case for rasterization. there's other algorithms which might be faster (e.g. lorenzetto http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.11.4259&rep=rep1&type=pdf ), but r&d is ongoing.

and then you also have to do grid fitting / stem darkening for legibility at small sizes. honestly for lots of small shapes cpu rasterization extremely outperforms gpu rasterization, especially when you can do curve interpolation on the cpu.

Workaday Wizard
Oct 23, 2009

by Pragmatica
can’t you use your os to render text on an image and use that as a texture? why the extra work? do you actually need 3d text or something?

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

leper khan posted:

I also like Odin Inspector, but my office hasn’t (and likely won’t) spring for licenses for the team.
What's the big whoop on Odin Inspector? Does it just generally expose properties better by default? I saw it touting serialization as well as not having to write custom inspectors, but I didn't understand what they did to be able to brag about that. All I could really see were the examples of the additional variable types they were able to expose, as well as how they changed how some existing stuff was exposed, which admittedly looked pretty good.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

What's the big whoop on Odin Inspector? Does it just generally expose properties better by default? I saw it touting serialization as well as not having to write custom inspectors, but I didn't understand what they did to be able to brag about that. All I could really see were the examples of the additional variable types they were able to expose, as well as how they changed how some existing stuff was exposed, which admittedly looked pretty good.

There’s a[n optional] custom serializer they wrote which will handle more types (eg dictionary).

They wrote a bunch of custom editors for things like Quaternion so you can have the editor show them as Euler angles (I don’t have 3d math galaxy brain). See also colors and a bunch of other stuff.

More cool, in my opinion, are all of the attributes. You can tag fields as supposed to be filled with a scene object or prefab and then it tells you if the contract is broken. There are a lot of new attributes, and many are neat/useful. Others I just haven’t bothered to get to yet :shrug:
Scene validation is an incredibly useful tool for larger projects where things can start changing out from under you.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

leper khan posted:


Scene validation is an incredibly useful tool for larger projects where things can start changing out from under you.
Oh yeah I just remembered that because I have been doing something similar. I had to write out a few assertions that my extension looks for with Reflection and then runs to tell me if I've hosed up having or not having things in the scene. This thing can do something similar?

An example of the rules:
1. There should be a default player start point (warning, just used for testing)
2. However, there definitely does have to be at least one way into the scene
3. There shouldn't be any cameras because I have something taking care of that; flag existing cameras in the scene

Is this something that can be written simply with that?

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

Oh yeah I just remembered that because I have been doing something similar. I had to write out a few assertions that my extension looks for with Reflection and then runs to tell me if I've hosed up having or not having things in the scene. This thing can do something similar?

An example of the rules:
1. There should be a default player start point (warning, just used for testing)
2. However, there definitely does have to be at least one way into the scene
3. There shouldn't be any cameras because I have something taking care of that; flag existing cameras in the scene

Is this something that can be written simply with that?

Some of those things can be done with just an attribute on a field (eg the Required attribute) yes

ApproachingInfinity
Sep 14, 2008

Shinku ABOOKEN posted:

can’t you use your os to render text on an image and use that as a texture? why the extra work? do you actually need 3d text or something?

This is pretty much what Unity's built-in text system does (or well, they probably use FreeType or similar but same deal). Doing this is fast enough that you can, if you want to, render to that texture on-demand and just display the letters at the size/style you want without much issue. Even better, if you need the same glyph again, you just pull the one you already rendered out of the texture. You can also pre-render all the glyphs you think you'll need beforehand for even more speed. The problem with this method is that you're pre-rendering text at fixed sizes; glyphs rendered at 16 pt just aren't going to look good at 80 pt size.

One solution to this, which TextMeshPro uses, is to instead render the glyphs out and then generate signed distance field textures from them. With these you do just a bit of extra math to determine your final alpha, and you can get very smooth-looking fonts rendered at very disparate sizes out of a single glyph texture, and the texture doesn't even have to be that big. There's also certain kinds of effects (glow, soft drop shadow, among others) that become really easy and cheap to render with SDF fonts.

The issues with this method:
- Generating the signed distance field texture is, relatively, very slow. Because of how slow it is, you pretty much _have_ to pre-render all your glyphs. This means you can't easily ask for new ones on-demand. If you're localizing for East-Asian languages this can quickly become a big problem, because now you have to either pre-render a crapload of SDF textures, or try to pick which ones you think will or won't get used and add some limitations.
- At very small sizes (IMO) SDF-rendered fonts are much harder to read than with the traditional method, or at least with TMP they are. You could probably mitigate that by smoothing in the shader or anti-aliasing, but with the traditional method you'll get properly rendered fonts at exactly the size you want, every time.

Some links:

https://en.wikipedia.org/wiki/Signed_distance_function - Wikipedia's articles about these kinds of things are generally very unhelpful for me (I am a math dummy), but it's probably technically super-precise or something
https://www.youtube.com/watch?v=CGZRHJvJYIg - A video showing pretty well what the results are of SDF fonts visually

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

leper khan posted:

Some of those things can be done with just an attribute on a field (eg the Required attribute) yes

I'm not following how that would work. The situation is that I need to ensure that there are GameObjects in the scene that meet these rules--or that there aren't GameObjects in the scene meeting other rules. How would I assign attributes to make such rules work?

In other news, I discovered the RequireComponent attribute while trying to look that up.

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!

roomforthetuna posted:

Out of curiosity, why is it so normal to put fonts into textures, and so not normal to transform truetype fonts into triangles in a vertex buffer on the fly?
If the text is being rendered at a single size with no rotation, scaling, or other subpixel motion (like in typical web scenarios), the best thing to do is render it at the size it's being displayed to take advantage of font hinting features that improve the legibility of the text. When that's done, there's not really much point in keeping polys around because the rasterized result is always the same.

If that's not possible, then there are three major problems with mesh fonts:

One is that they're not really any cheaper to render except at large sizes, polygon data is fat (8 bytes per vert, at least 2 per edge), and the triangles have to be rasterized.

Second is that it's much harder to handle holes. The glyph for "o" for example is just two circles, the hole is cut out by the rendering process. When rendering to a texture (and there are some GPU rasterizing algorithms...), that's pretty easy because overlap can be cancelled out using stencil invert, even/odd checks, and other techniques, but if the hole has to be done by cutting it out of the geometry, then you're basically talking doing CSG.

Third is that they are bad at low resolutions if they're rendered directly into the scene because they rely on geometric anti-aliasing like MSAA, post-processing shaders like FXAA, or temporal. Texture filtering by itself is pretty good at minimizing artifacts from subpixel motions, and when that's not enough, you can do fancy stuff in the shader.

OneEightHundred fucked around with this message at 09:55 on Jan 11, 2018

Adbot
ADBOT LOVES YOU

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Rocko Bonaparte posted:

I'm not following how that would work. The situation is that I need to ensure that there are GameObjects in the scene that meet these rules--or that there aren't GameObjects in the scene meeting other rules. How would I assign attributes to make such rules work?

In other news, I discovered the RequireComponent attribute while trying to look that up.

.... you just put the attributes on things. I don’t understand what the issue is.

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