67

This is one case where it's useful to steal ideas from Hollywood, who have been doing this for decades. Typical hollywood night scene, also related question from Movies.SE The picture above was filmed during the night time, but it's not actually a dark picture. Notice how the actors' faces are very well lit, although the sky is pitch black and the road is ...


44

The attenuation function you've got, att = 1.0 / (1.0 + 0.1*dist + 0.01*dist*dist) is a fairly common one in computer graphics - or, more generally, 1.0 / (1.0 + a*dist + b*dist*dist)) for some tweakable parameters a and b. To understand how this curve works it's helpful to play with the parameters interactively. This curve is nice because it approaches ...


43

Expanding on TomTsagk's correct answer, I thought it might help to describe a bit more about why games work like this. Light in games doesn't really "travel" from the source, to the surface, to the camera, getting obstructed along the way. To figure out how bright to draw each pixel of a surface based on a given light, we use (or approximate) a math ...


35

specular lighting of directional light more area has specular lighting when camera is far from an object Yep, looks right to me. The specular area for directional lights is supposed to be more or less constant w.r.t. the camera, given the same reflection surface. To compare, we can look at the phenomenon known as sunglint, which is basically specular ...


34

Real-life soft shadows have a shape that depends on the shape of the light source as it appears from the point of view of the shadowed surface. This is because penumbras occur due to partial occlusion of the light source from the shadowed surface's point of view. The shape of the shadow is therefore something like the shape of the occluder convolved with ...


32

Heads-Up: This answer is outdated. Unity now supports point light particles natively. Please see this answer for full details. I'll leave post this here for anyone curious, or using old versions of Unity, or needing more manual control than the native method offers - just note that the native support is likely to be much more efficient and scalable than ...


25

Use an animated texture.* There are some good ones in the store for < $10. Add a Halo. You can use the particle system, or just a transparent glow texture on a billboard in front of the sun with a script to re-position the texture when the camera moves. This hides the aliased edges of the sphere model, allowing you to use a lower poly model, and looks ...


23

This is simply a kind of optimization given that invSqrRadius = 1/SqrRadius, instead of calculating the inverse squared radius for each light every time they simply cache it, the reason is that division is usually a "slow" operation at least when compared to multiplication. This optimization is relevant especially: when the operation is done a huge amount ...


22

In traditional Blinn/Phong shading, you calculate the diffuse term for a pixel by measuring the cosine of the angle between the normal at the surface and the direction of the light. So, in this case, a simple shader would look something like this: float DiffuseCoeff(in float3 pos, in float3 normal, in float3 lightPos) { float3 lightDir = lightPos - pos; ...


22

Long story short, this happens for performance reasons. When there's a light on the screen, by default it shines on all objects (obstructed or not), so the game would need to make extra calculations to see which object is affected by what. This is easier to solve on static objects by using static and baked lighting, but this is not the same on dynamic ...


18

After initially being puzzled about this question, because it felt natural that objects don't change their brightness depending on the distance to the eye (or camera), but only depending on the distance to the light source, I did a quick google search and found this great article. It is about this exact topic in photography and explains why the distance ...


17

This is a much bigger topic than can be covered in an answer, but briefly: Physically-based shading means leaving behind phenomenological models, like the Phong shading model, which are simply built to "look good" subjectively without being based on physics in any real way, and moving to lighting and shading models that are derived from the laws of physics ...


17

Physically-Based Rendering You're on the right track when you say "it tries to mimic how light reflects in real life, which is it usually gets split to two components, specular and diffuse depending on the type of material." But we've been modelling materials with specular and diffuse in games & computer graphics for a long time. The trick is that we ...


15

How do objects show color? Well, an 100% red object looks red because it absorbs all other wavelengths of light (orange,yellow,green..you know, a rainbow) and reflects only red. So what if you shone pure blue light on a pure red surface? Well it would absorb the blue light and reflect.. nothing. Hence black. I'm sorry for the terrible picture


14

Select the Light object Go to Inspector Light And change rendered mode "Auto" to "important"


14

There are a huge number of ways of doing this. These will require the use of a shader and I am presuming that you are already doing per-pixel lighting. The following are some suggestions, however finding the technique that's right for you might take a lot more research. Quick and Dirty You can specify bounding boxes which define interior areas. If the ...


14

I imagine if I was going to build such a shader there are certain phenomenas that I will start with. First the sunlight is directional, meaning it does't have position nor attenuation. Second the diffuse component is simply calculated by taking a dot product between the sun direction and the surface normals, adding normal mapping might add to the detail. ...


13

Amit Patel has written a very nice article on 2D ray casting. This involves casting rays to each of the vertices inside the range of the light source to build a light mesh. All of the visual examples are interactive in the post and very easy to understand. You don't have to limit yourself to a box either, the perimeter you trace can be any shape you like....


13

Your lighting equation is physically correct. However, in real life, one almost never sees highly pure colors. (An exception is when lasers are involved.) That's probably why your intuition is that red * blue = violet - a more realistic red might be something like (1, 0.1, 0.1), and a blue (0.1, 0.1, 1). Multiply those and you get (0.1, 0.01, 0.1), which ...


12

The colors in a normal map represent the normals at each point. If a normal is (x, y, z), the corresponding pixel in the normal map will have each of x, y, and z mapped from the range (-1,1) to (0,255) to get the red, green, and blue components respectively. Now the z-axis is typically used as the direction away from the surface. A perfectly flat surface, ...


12

Going to try and doodle up what I mean here as soon as I finish typing this, but: What about merging the two? Use the second (occlude by base) for everything that isn't a wall and the first (occlude by tops) for lighting the walls? You actually did this by accident in your second example, with the wall that goes off the bottom of the image. Extending ...


11

The reason to use spherical harmonics is to approximate the incoming light distribution around a point—typically indirect light calculated by some global illumination algorithm. Then the BRDF is also approximated with spherical harmonics, to allow efficiently calculating the outgoing light seen by the viewer, by taking the dot product of the incoming light ...


11

In deferred shading all the material properties are rendered into the G-buffer, e.g. albedo, normals, roughness, metalness, etc. that are needed for BRDF evaluation. After this step shading is performed for pixels within light volumes using light and material properties as input to the BRDF. The problem with deferred shading is that more complex BRDF's (e.g. ...


11

It's a peak in a function defined in polar or spherical coordinates. If we look at the function y = cos(x) in rectangular coordinates, it looks like a wave, with peaks at 0 and 2pi: If we look at the function r = cos(theta) + 1 in polar coordinates, it looks like a bulge, or "lobe" that's greatest at 0: (Images above via Wolfram MathWorld) The same thing ...


10

tl;dr Func 1 on Wolfram Alpha: 1 - 2 * |(x mod 2) - 1| Or in your specific case: 1 - 2 * |((time % entireDay) - halfDay) / halfDay| You can even use a sinus wave instead (much more pretty). sin(x - pi/2) Sin Wave on Wolfram Alpha Or in your specific case: sin (- pi / 2 + 2 * pi * time / entireDay); Long tedious explaination in fine detail: If in ...


10

Other then the particale system and halo effects Vadim mentioned you could create your own shader effect. There is some introduction to shaders for Unity and the possibilities are endless.


10

The Cell Shader To create a similar effect you will need two or three diffuse textures for the same number of brightness steps. Use smoothstep with a small range to soften the colour band transitions. As BotW uses different colour hues not just brightness steps for the dark and bright areas of each "colours" you need different diffuse textures. You can't ...


9

One way to implement an effect like this is with the stencil buffer. This is an extra few bits the renderer keeps around for every pixel in a render target, that you can use for scratch notes about what you've drawn there or are allowed to draw later. You can create a new shader using one of Unity's built-in templates, and add some stencil operations to ...


8

I believe what you are looking for is called Deferred Rendering. It is a rendering technique that scales extremely well with a lot of lights, so well that it can used for dynamic indirect illumination. That means 1000s of lights on the screen. It is basically a technique in which you first render all your geometry data(position, normal, depth) into an ...


8

Light emiting particles is now a built in Unity feature in 5.5. Simply enable Lights in the particle inspector, throw in a reference to a light prefab (both point and spot lights work), and change the Ratio to 1. And voilĂ , particles that emit lights: Turns out, this is a rather optimized setup, running at 1500+fps on my rig even with maximum lights in ...


Only top voted, non community-wiki answers of a minimum length are eligible