When we talk about the brightness of a star, there are two different concepts of brightness to be aware of.
Intrinsic brightness or luminosity (
The apparent brightness or true brightness (
The further away you are from a star, the dimmer it appears, in accordance with the inverse-square law.
This is closely related to Irradiance at Higher.
The formula to calculate apparent brightness from intrinsic brightness can be derived from the idea of electromagnetic radiation spreading out in a sphere around a source.
You can use any other unit of distance as long as you're consistent - at astronomical scales, metres become incredibly impractical and astronomical units, light years and parsecs become more reasonable.
The Stefan-Boltzmann law relates the irradiance of a star to its surface temperature. It states that the irradiance of an ideal black body is directly proportional to the fourth power of its temperature.
Since stars can be considered approximate black bodies, we can use the Stefan-Boltzmann law to calculate the temperature of a star from its irradiance, or vice versa. This is very useful for getting a rough idea of the surface temperature of stars, which we obviously can't pop by for an afternoon visit.
is the irradiance of the star, in watts per square metre. is the Stefan-Boltzmann constant, about . is the surface temperature of the star, in kelvins.