Tag Info

Hot answers tagged

56

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 ...


35

You could overlay a simple glow effect texture with soft transparent edges. If you want lighting/shadows similar to what you may find in a 3d world you could do something like this: http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/. However, if you are new to HLSL, then that may be a little bit too much. edit: I ...


32

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 ...


31

When you have a static (non-moving) light in a game, you have two options for rendering this light. You could render it the same as a dynamic light; that is, feed it through the shader pipeline which will calculate its effect on everything around it, every frame, on its way to the screen. This is obviously pretty expensive. Or, an editor can bake the light ...


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 ...


21

It uses a bloom shader. That's a post-processing effect that makes bright areas of the rendering appear to glow.


21

There are generally two methods for dealing with this. Nowadays, they are called forward rendering and deferred rendering. There is one variation on these two that I will discuss below. Forward rendering Render each object once for every light that affects it. This includes the ambient light. You use an additive blend mode (glBlendFunc(GL_ONE, GL_ONE)), so ...


19

Light, from point-like sources, falls of with the square of the distance. That's physical reality. Linear attenuation is often stated to appear superior. But this is only true when working in a non-linear colorspace. That is, if you don't have proper gamma correction active. The reason is quite simple. If you're writing linear RGB values to a non-linear ...


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 ...


16

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 ...


15

I've implemented something similar to this. I wrote up a post about it on my blog: byte56.com/2011/06/a-light-post. But I'll go into a little more detail here. While the codeflow article linked in another answer is pretty interesting. From what I understand, it's not how Minecraft does its lighting. Minecraft lighting is more cellular automata then ...


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


13

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; ...


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 ...


13

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. ...


12

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 ...


11

Assuming you don't want to use standard shadow mapping, you could use a signed distance field to do it. This involves building a texture that tells you, for each pixel, the distance to the nearest opaque surface in any direction. The distances are negative when you're inside an opaque object and positive when outside (this allows the surfaces to be ...


10

With the ambient light your objects appear too bright because the diffuse light is added to the ambient light, and the diffuse light defaults to 1.0. This adds up to 1.5, and everything above 1.0 is clamped. Set the diffuse light to 0.5: float difLight0[4] = {0.5f, 0.5f, 0.5f, 1.0f}; glLightfv(GL_LIGHT0, GL_DIFFUSE, difLight0); The second problem is ...


10

Neat idea for the game. The problem is that light really doesn't look like this. Light decay is NOT gausian :). That's for the begining. What i want to propose is adding simple (but relatively physicaly correct) fog or dust. Mean volumetric effect. You will have to implement volumetric raycasting on the gpu. Don't panic. It is not that hard as it might ...


10

Many effects use a standard lighting rig which uses 3 lights similar to how a movie company would film a movie. Here is a wiki link: http://en.wikipedia.org/wiki/Three-point_lighting here is an XNA specific blog about it (concepts can be applied to OpenGL too): http://blogs.msdn.com/b/shawnhar/archive/2007/04/09/the-standard-lighting-rig.aspx


10

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 ...


10

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. ...


9

I'm going to gamble on the fact that you really want to know how to achieve a similar effect, and not specifically how Minecraft does it, which wouldn't be an on-topic question. Do they use several skyboxes rendered over eachother? That is, one for the sky (which can turn dark and light depending on the time of the day), one for the sun and moon, and ...


9

Flexibility. Because you might want your lights to fall off linearly. It's there to give you that degree of control. It doesn't really need to be physically accurate (and the entire phong shading lighting equations are certainly not physically accurate either). Sometimes the quadratic model will give out light too fast near the source and leave "white ...


9

Indeed, that is all you need for radiosity. There are two different (but equal) formulations. The first is to "radiate" or shoot light from each patch (in your case probably a face), and the other is to "gather" or receive light into each patch. If you iteratively do this enough times, you get radiosity. The first step is to figure out where light ...


9

Simplest option is to grab the lighting from the block your standing on (or if possible the lighting on the block in the air that corresponds to the block the pickaxe is in) and use that for lighting the pickaxe/player. Or in other words, calculate the lighting for the pickaxe as if it was a block in that position. To get more realistic shadows you would ...


8

I think you are right. You would really like to tile your bricks, because it saves a lot of memory space and is also quick in your GPU. Baking the lighting does need a unique texturing, because no place is the same. You could tile some parts of your texture, for example, on really straight long places. (I'm no UV wrapper, but I do think that is possible to ...


8

Normally, lighting in 2D games is done by having a Normal Map for all of your sprites, then calculate the 3D lighting effects on your 2D sprites. This is known loosely as "2.5D". I would however not recommend doing this in your first game as it is complex. Here's an awesome video of someone who has done this in XNA: ...


8

tl;dr func 1 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 Or in your specific case: sin (- pi / 2 + 2 * pi * time / entireDay); Long tedious explaination in fine detail: If in military time: 00:00 ...


7

From the no-texture picture, I'm pretty sure the problem is that your cube models have inappropriate normals. You need to tell Blender that your cube edges are intended to be sharp, not smooth — what you have now are cubes that are acting like six-sided approximations of spheres. I don't know Blender so I can't tell you exactly how to accomplish this, but ...



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