Skip to main content
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
  • 135k
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
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
  • 135k
12 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,497
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
  • 135k
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,384
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
  • 135k
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

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
  • 135k
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
  • 135k
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
4 votes
Accepted

How can I make shadows darker in unity5 without changing light intensity?

Use a spot light with increased Range and Spot Angle. Use full shadow Strength.
Sourav Paul Roman's user avatar
4 votes
Accepted

Java 2D Lighting

This may not be a perfectly satisfactory answer, but: Modifying a BufferedImage in the main memory and uploading it to the video memory in each frame simply causes ...
Marco13's user avatar
  • 673
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

Physically based shading - ambient/indirect lighting

Disclaimer: the following answer was published in its entirity by Nathan Reed an a similar question the asker posted on the Computer Graphics Stack Exchange. Real-time graphics deploys a variety of ...
4 votes
Accepted

Cave lighting in Unity

Some information on the Grow Home/Grow Up art direction here if you're still interested :) We relied very heavily on our custom Fresnel shader for... well... the entire look of the game. But it was ...
Jack's user avatar
  • 56
4 votes

Unity - how to remove standard sky but keep the lighting?

In your scene, select your Main Camera and, in the Inspector, change its "Clear Flags" settings in the Camera component from "Skybox" to "Solid Color." Then choose ...
Foggzie's user avatar
  • 1,222
4 votes
Accepted

Lighting large scene with dynamic lights - Unity3D

I ended up using occlusion culling like a few people suggested in the comments. It worked wonders for my situation. Setting it up is very simple as well. First, you have to mark everything you want ...
Sub 6 Resources's user avatar
4 votes
Accepted

How to implement a clipped shadow in 2D?

1)Cast a set of rays from origin to the ground evenly distributed through the width of your object. 2)Draw your shadow as a small portions of black sprites with varying height so you can round the ...
Ocelot's user avatar
  • 1,433
4 votes
Accepted

Minecraft-Style Voxel Sunlight Algorithm

For each block that you visit as you're doing your light propagation, store an offset/direction to the brightest light shining onto it from a neighbour (eg. if a block is receiving a value of 5 from ...
DMGregory's user avatar
  • 135k
4 votes

How to create a glowing corona/halo around a sun and make it emit light

In order for that shiny halo to appear around HDR-colored materials, you need to add a Bloom post-processing effect to your scene. How to do that and what settings that filter has available differs a ...
Philipp's user avatar
  • 120k
4 votes
Accepted

Issue with specular light at highly oblique angles with Blinn-Phong

TL;DR: Multiply your specular value by dot(normal, lightNormal). (And do clamp that dot product to a minimum of 0!) I, and I suspect (from seeing all the tutorials out there) many others, have been ...
D0SBoots's user avatar
  • 251
4 votes
Accepted

Scene lightning is wrong when scene is loaded from a different scene

It appears that my Lighting Settings went corrupt and Unity went back on default settings, similar to when none are added. Unlike when they are missing fully, the error did not throw the usual "...
Zibelas's user avatar
  • 4,346
3 votes
Accepted

Determining how much of a tile is intersected by a ray to help calculate lighting and deal with shadow issues

First of all a ray isn't going to help you with this. You will need at least 2 rays. "How much of a tile a ray intersects" is not really a meaningful question, since the ray will always split a tile ...
Nils Ole Timm's user avatar
3 votes

Make a light only affect one object

Taken from Unity Answers: Yes, this is what Layers are for. Assign your objects to a specific layer (use an existing layer, or create your own custom layer). Then go to the light's inspector ...
starikcetin's user avatar
  • 5,295

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