Questions tagged [lighting]

The simulation of light and illumination in games, including its interaction with the environment. A core element of games that can bring out vivacity into otherwise static worlds.

Filter by
Sorted by
Tagged with
16 votes
3 answers
13k views

Can I achieve a torchlight effect (lighter area around a light source) in a 2D game?

I am thinking of writing myself a simple 2D game. It will not shine with perfect graphics or gameplay at first, but I'd consider it my first step in PC game development. So, imagine such simple sprite-...
user avatar
58 votes
4 answers
31k views

How is 2D lighting implemented?

I am wondering what the best way to approach a "lighting" effect in 2D games is. For instance, if my main character is glowing, what techniques can I use to complete the visual effect of the character ...
user avatar
11 votes
3 answers
9k views

How do I implement occluded lighting in a block-based 2D game?

I want to have 2D lighting that can be blocked by in-game objects. My game has a top-down view and all game objects are described by rectangles. Let's say I have a 10x10 world and I place a light at ...
user avatar
  • 1,351
13 votes
2 answers
27k views

What is the difference between PBR and SSR?

I am very new to game development and I have been trying to understand the difference between Screen Space Reflection and Physically Based Rendering. I have read about PBR, and from what I understand,...
user avatar
17 votes
4 answers
15k views

How can I acheive a smooth 2D lighting effect?

I'm making a 2D tile based game in XNA. Currently my lightning looks like this. How can I get it to look like this? Instead of each block having its own tint, it has a smooth overlay. I'm assuming ...
user avatar
  • 1,039
15 votes
2 answers
13k views

How can I implement lighting in a voxel engine?

I am creating the MC like terrain engine, and I have thought that lighting would make it look a whole lot nicer.The problem is that the blocks are not being lit properly when a block which emits light ...
10 votes
3 answers
4k views

Lighting in a Minecraftian World

Minecraft is a game that is largely based on a heightmap and uses that heigtmap information to flood the world with light. From my understanding the highest point in the heightmap is the end of the ...
user avatar
10 votes
2 answers
4k views

What is physically correct lighting all about?

I can't find anything comprehensive using Google. I'm wondering what the core concepts of physically correct lighting are, and where I could read up on it. What's physically correct lighting all about?...
user avatar
  • 4,374
18 votes
3 answers
2k views

How can I create a lighting effect like this?

This is the most beautiful 2d lighting I have ever seen, and I'd like to perform lighting like this too. How do I do it? I don't care about the physics or how the particles are simulated - I only ...
user avatar
  • 759
14 votes
4 answers
7k views

How can I implement voxel-based lighting with occlusion in a Minecraft-style game?

I am using C# and XNA. My current algorithm for lighting is a recursive method. However, it is expensive, to the point where one 8x128x8 chunk calculated every 5 seconds. Are there other lighting ...
user avatar
6 votes
2 answers
2k views

2D lighting theory: day-and-night cycle, spot lights at night

I am writing a rogue-like 'zombie' management game. The game map will be similar to Prison Architect. A top-down 50 X 50 grid. I want to implemented a day night cycle and during the night I would ...
user avatar
3 votes
2 answers
16k views

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

Look at my scene: Sun is rising and as you can see the scene is realistic; I mean, that what is in shadow is almost completely dark. This is correct, but i would like something less "dark", like an ...
user avatar
  • 837
6 votes
3 answers
1k views

How can I change this isometric engine to make it so that you could distinguish between blocks that are on different planes?

I have been working on an isometric minecraft-esque game engine for a strategy game I plan on making. As you can see, it really needs some sort of shading. It is difficult to distinguish between ...
user avatar
3 votes
1 answer
627 views

How could I do simple per-fragment lighting on BSP geometries?

I am programming a graphics engine for an old game. The game uses a BSP geometry which I have rendering perfectly. For it's lights however, it simply has light instances with the standard x, y, z, ...
user avatar
2 votes
2 answers
834 views

Minecraft-Style Voxel Sunlight Algorithm

I'm implementing a pure Minecraft clone, and I want to implement sunlight. I have a basic sunlight algorithm working perfectly in 2D, and I understand how to scale it to 3D. But how do I make it so I ...
user avatar
2 votes
1 answer
3k views

Cave lighting in Unity

I have a cave that is inside a mountain (one mesh) that I created in Blender. I would like to make the cave quite dark inside so that either the player can light it up, or it is lit up with things ...
user avatar
20 votes
1 answer
26k views

GLSL Light (Attenuation, Color and intensity) formula

I'm implementing point lights in my Voxel engine, and I'm really struggling to get a good flow of light, from 100% near the light source to 0% at the light radius. I have 5 arguments for the function:...
user avatar
  • 1,043
19 votes
3 answers
12k views

Is there a way to use an arbitrary number of lights in a fragment shader?

Is there a way to pass an arbitrary number of light locations (and colors) for the fragment shader, and loop over them in the shader? If not, then how are multiple lights supposed to be simulated? ...
user avatar
  • 191
22 votes
3 answers
9k views

How can I model a star?

I'm trying to model a star in Unity, and it, sort of works, but it's not ideal. Currently, I'm using a large sphere with a self-illuminating material containing a star texture applied to it's surface, ...
user avatar
41 votes
1 answer
38k views

What does it mean to "bake lights"?

What does it mean to bake lightmap ? I heard this in Unity3d, and again found this LightUp plugin for sketchup that bakes lightmap. From what I observe, the lightmap baked gives the 3d object a much ...
user avatar
18 votes
9 answers
4k views

Does the linear attenuation component in lighting models have a physical counterpart?

In OpenGL (and other systems) the distance attenuation factor for point lights is something like 1/(c+kd+sd^2), where d is the ...
user avatar
  • 5,986
6 votes
2 answers
863 views

A big light with shadows

To have better texture2D quality in my 2D game, I had to recreate every textures with 300% of their original size. But the lights have to bright 3 times more. For lights, I'm using this : Catalin's ...
user avatar
16 votes
3 answers
10k views

How do I blend 2 lightmaps for day/night cycle in Unity?

Before I say anything else: I'm using dual lightmaps, meaning I need to blend both a near and a far. So I've been working on this for a while now, I have a whole day/night cycle set up for renderers ...
user avatar
9 votes
3 answers
14k views

How do I implement flat shading in GLSL?

I'm working with GLSL and trying to implement flat shading on a 3D model (rather than smooth shading). To illustrate what I mean, here are two screenshots of cubes in Blender. Here's one with flat ...
user avatar
  • 529
6 votes
2 answers
3k views

Grid/cell based light system

I am working on a top-down, 2d cell-based RPG game. I would like to implement a cell based lighting system, something like this and this. I basically have several light sources and light deteriorates ...
user avatar
  • 163
5 votes
1 answer
1k views

Converting time of day into a smooth day/night variable?

I'm trying to make a smooth day/night cycle for a game project that I've been working on. I've already set up a clock that adds deltaTime to seconds, wraps seconds to gameMinutes, etc. The issue that ...
user avatar
4 votes
1 answer
4k views

How does Minecraft render its sunset and sky?

In Minecraft, the sunset looks really beautiful and I've always wanted to know how they do it. Do they use several skyboxes rendered over eachother? That is, one for the sky (which can turn dark and ...
user avatar
  • 1,595
7 votes
1 answer
1k views

How can I implement a revealing light beam?

In SEARCHLIGHT, you control a ray of light that illuminates incoming enemies that are otherwise invisible in the night sky. Here is an illustration: How would I go about doing this, preferably in ...
user avatar
6 votes
2 answers
1k views

Rendering collections of light sources

I have a small test environment where small point lights are scattered. Players should able to collect them. The collectible lights are rendered using a simple billboard technique where two triangles ...
user avatar
  • 607
4 votes
2 answers
6k views

Unity 2D Alpha cutout layer for Sprites

I'm trying to make a simple Fog of War effect for my 2d game, similar to these: . I want to have a sprite layer of black and then have a sprite to cut out itself from the black layer, leaving a ...
user avatar
3 votes
1 answer
3k views

Achieving 2D Lighting for Terraria-Like Game

I'm trying to achieve the fog-of-war lighting style that Terraria and Starbound have. Terraria's lighting system seems to be more blocky/tile based, but Starbound's is a lot more smooth. The Desired ...
user avatar
3 votes
2 answers
9k views

How to achieve lighting like this in Unity for 2D games?

How could I accomplish a lighting effect something similar to this game?: I'm not talking about the shadows but about the glowing/lighting effect on the crystals and the torches. Anyone got any ...
user avatar
5 votes
1 answer
4k views

Fast pixelshader 2D raytracing

I'd like to do a simple 2D shadow calculation algorithm by rendering my environment into a texture, and then use raytracing to determine what pixels of the texture are not visible to the point light (...
user avatar
  • 4,374
4 votes
1 answer
2k views

How can I handle the combination of multiple shader effects?

To be able to work efficiently with effects, is there a good way to combine multiple reusable "base" effects to achieve a more complex final result? For example, say I have an effect that handles ...
user avatar
  • 773
6 votes
3 answers
2k views

Random black pixels GLSL shader bug

I've recently been following a tutorial for writing a game engine in Java using LWJGL 2. I followed the tutorial for writing a fragment shader that utilizes spotlights in GLSL. The example game ...
user avatar
5 votes
2 answers
2k views

Light Attenuation Formula Derivation

I understand that when sampling the brightness of a given point on the surface, a certain cutoff needs to be taken into consideration. Other words, when the light is further away, the intensity ...
user avatar
  • 445
5 votes
3 answers
4k views

2D - Smooth lighting with shadows for a tile-based game

for the last week or so I have been completely stuck on trying to implement efficient lighting. I've been researching and experimenting and I've looked everywhere that I have been capable of finding, ...
user avatar
4 votes
2 answers
7k views

How to set emission level through C#

I am willing to change emission level through code without affecting its color. (i.e., changing the brightness number shown in the box at the right side of the inspector, while keeping the emission ...
user avatar
4 votes
1 answer
649 views

Physically based shading - ambient/indirect lighting

I implemented a physically based path tracer after studying PBRT by M. Pharr and G. Humphreys. Now I'm trying to apply physically based rendering to real time graphics using OpenGL. I want to start ...
user avatar
4 votes
1 answer
198 views

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

I'm having an issue with my basic Blinn-Phong renderer, when looking at objects at very oblique angles: I don't think this is an issue with my code, although I'll post my fragment's GLSL below. ...
user avatar
  • 231
3 votes
2 answers
5k views

My Ambient lighting is not working correctly

I'm having a problem when using ambient lights in my opengl game. When I first started with my program, i had a positioned light, and the code was this: ...
user avatar
2 votes
1 answer
275 views

Rendering lighting only on specific objects

I have done something similar to this in monogame: My question is, what would I have to do to draw that lighting effect only on the pillar and not the background ? Is there something like ignoring ...
user avatar
  • 1,287
1 vote
1 answer
1k views

Grid-Based 2D Lighting Problems

I am aware this question has been asked before, but unfortunately I am new to the language, so the complicated explanations I've found do not help me in the least. I need a lighting engine for my ...
user avatar
  • 107
4 votes
1 answer
351 views

How do I autogenerate gradient lighting?

I am trying to think of a way to generate a gradient like this picture: Something like this GetGradientTexture(360f,100(width),100(height)), or if i want a ...
user avatar
  • 41
2 votes
1 answer
1k views

glsl directional light specular seems to be relative to origin not camera

I've been using the LearnOpenGL tutorials to calculate directional light. The diffuse works perfectly fine but the specular seems only work properly when the camera is near the origin and the specular ...
user avatar
2 votes
1 answer
3k views

Custom shadowmapping in Unity not working properly

To experiment with a certain technique, I'm implementing my own shadow mapping in Unity. I'm using a camera for the light "view", which is rendered to a RenderTexture after being post-processed with ...
user avatar
  • 173
1 vote
1 answer
1k views

Moving lights or scene objects in Unity seems to cause a second point light to shrink or dim

Moving a Point Light in 2d space seems to be dimming lights around it. What is this and how can I solve it?
user avatar
  • 139
1 vote
1 answer
305 views

Why specular reflection portion changes when we move in different direction?

We know that in Specular reflection rays reflected off surface at inverse angle;so camera position matters;creates bright highlights. I have taken one image where specular reflection is seen(Here ...
user avatar
1 vote
1 answer
4k views

How can I calculate a terrain's normals?

Im trying to implement basic lighting in Opengl 3+ (a sun) with this tutorial : http://www.mbsoftworks.sk/index.php?page=tutorials&series=1&tutorial=11 Im building a basic terrain and its ...
user avatar
  • 309
1 vote
1 answer
1k views

How can I implement "cut outs" for lighting in OpenGL?

So, I'm working with OpenGL (I'm not exactly sure of the version), and I want to do an old-style lighting setup by essentially drawing a black rectangle over the screen, and drawing white circles over ...
user avatar
  • 131