44 votes
Accepted

Why do some games show lights shine through walls?

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 ...
DMGregory's user avatar
  • 132k
36 votes
Accepted

Phong lighting - there is something very strange with specular lighting

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 ...
congusbongus's user avatar
  • 14.8k
31 votes

How can I make particles glow and cast light on its surroundings?

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 ...
DMGregory's user avatar
  • 132k
24 votes
Accepted

How can I model a star?

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 ...
Peter's user avatar
  • 9,955
23 votes

Why do some games show lights shine through walls?

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 ...
Tom Tsagkatos's user avatar
20 votes
Accepted

What is the difference between PBR and SSR?

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 ...
DMGregory's user avatar
  • 132k
18 votes
Accepted

Why is the distance from object to eye irrelevant in illumination models?

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 ...
LukeG's user avatar
  • 1,537
17 votes
Accepted

Invert the colour of pixels where 1 bit sprites are overlapping

We can do this by making a custom version of the standard sprite shader (so it still does everything the one you're used to can do), and modifying its blending operation. Start by going to the Unity ...
DMGregory's user avatar
  • 132k
11 votes
Accepted

Where to cast light/shadows in a 2.5D view?

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 ...
Draco18s no longer trusts SE's user avatar
11 votes

How do I implement flat shading in GLSL?

As @rutter says, your #1 option is the correct thing to do in the overwhelming majority of all cases. However, if you're really adamant that you want everything to be hard-edged, then you can do this ...
Trevor Powell's user avatar
11 votes
Accepted

How is this lantern glow effect achieved?

My best guess right now is that it's a billboarded transparent sprite, which is animated to give it a pulsing effect. Exactly that. This is simple enough even for older hardware. There's also some ...
Mario's user avatar
  • 8,442
10 votes

How can I replicate the look of Zelda: BotW in my own shaders?

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 ...
Stephane Hockenhull's user avatar
9 votes
Accepted

How can I implement a revealing light beam?

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 ...
DMGregory's user avatar
  • 132k
8 votes
Accepted

How can I make particles glow and cast light on its surroundings?

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 ...
eclmist's user avatar
  • 1,153
8 votes

How can I create light shafts like Journey's in Unity?

You mention you're using Unity so you can use their official "Sun Shafts" feature; it's built right into the engine: You can read these Unity Docs to get a good idea of what they're capable of and ...
Foggzie's user avatar
  • 1,222
8 votes

Random black pixels GLSL shader bug

Unexpectedly black pixels sometimes indicate that you've got an infinity or NaN in the shader somewhere. For example normalize(vec3(0,0,0)) will generate a NaN. To me, the most obvious candidate in ...
Adam's user avatar
  • 7,156
8 votes
Accepted

How do I implement flat shading in GLSL?

You may have heard 3D modelers talk about "hard edges" or "sharp edges", which are roughly equivalent to what you're looking for here. When modelers create a hard edge, their software will internally ...
rutter's user avatar
  • 746
7 votes
Accepted

procedural forest canopy for terrain lighting

This sounds like a job for Light Cookies. These have a number of advantages over the shadow mapping method you describe: Cookies can represent intermediate levels of brightness, helping you get ...
DMGregory's user avatar
  • 132k
7 votes

How to avoid "completely" dark shadow using directional light (as Sun) ?

You said you were using an "Eye Adaption" Plug-in. Disable that first to make sure the issue is not caused by that. At last you have several knobs to tweak the outcome. I recommend you use a balance ...
AzulShiva's user avatar
  • 669
6 votes
Accepted

How can I make a ball glow and cast light?

You can't use the emmisive property alone, that will simply cause the object to appear. If this is something you are positive you want (And realize that it may affect your FPS, especially if you have ...
PearsonArtPhoto's user avatar
6 votes
Accepted

Light Attenuation Formula Derivation

In real physics, light (like many other influences) falls off as the inverse square of distance from the source. You can visualize this by imagining a lightbulb giving off one instantaneous flash - ...
DMGregory's user avatar
  • 132k
5 votes

Memory-Efficient, Optimized Terraria-Like 2D Lighting

One option would be to load lighting information only as it appears on the screen. You would get one performance hit at the beginning as the full screen lighting is calculated, but from there you ...
Kelly Corcoran's user avatar
5 votes

How to set emission level through C#

You're bang on for a low-dynamic range emissive colour. To get access to brighter emission we need to move to a high-dynamic range, which is outside the range of the ...
DMGregory's user avatar
  • 132k
4 votes
Accepted

Efficient Per-Tile Lighting Technique

Use a lightmap. A lightmap is an array in memory which is as large as your map and represents the light level of each tile. When you create/remove a light source, add/subtract its light intensity ...
Philipp's user avatar
  • 118k
4 votes

How can I make particles glow and cast light on its surroundings?

Years ago, before dynamic lights were affordable, we would simply use a 2D-billboarded particle effect with additive blending. It would brighten the scene towards white. By drawing it with the correct ...
Steven's user avatar
  • 3,052
4 votes
Accepted

2D deferred lighting calculations not working

First Question: The dot product basically tells you how much two vectors are pointing in the same direction. So if a light points directly against the normal of a surface the surface will be brighter ...
Nils Ole Timm's user avatar
4 votes

How do I properly combine the colors of different lights?

Define "properly." There are multiple ways of blending color. Additive blending works as you describe, 0.1 + 0.1 = 0.2 because we don't care if this value goes ...
Draco18s no longer trusts SE's user avatar
4 votes
Accepted

How can I create light shafts like Journey's in Unity?

Use stretched particle to get the effect. In Renderer, choose "Stretched Billboard". Change Length Scale as you need. This can be used in both 3D and 2D scenes. If you are actually into effect stuffs ...
Sourav Paul Roman's user avatar
4 votes
Accepted

Unity - Small holes of light seems to go through my blender mesh

I believe that might be related to "shadow acne." Try lowering the bias of your directional lights. http://answers.unity3d.com/questions/925812/unity-5-real-time-lights-cast-shadows-with-gaps-li.html
Tashus's user avatar
  • 421

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