# Implementing directional lighting in voxel based polygon-engine

I'm having trouble implementing directional lighting. (I'm not that familiar with 3D.)

The problem is that the lighting does not "follow/flow with" the other blocks next to them.

How should I fix this.

At the moment all vertices have there own normals.

Should I combine or re-position normals if the blocks are next to each other?

(I tried combining the normals but then it just looks like a plain, as if its just one color.)

Should I maybe do that kind of behaviour with shadows and is directional lighting specifically for ambient lighting and not so much for diffused lighting?

This is a little bit of the code that contains the normals (the last 3 values).

        {0, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE                    , getBlockColor(), -1.0f, -1.0f, -1.0f}},
{1, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE                    , getBlockColor(), -1.0f,  1.0f,  1.0f}},

{2, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE                    , getBlockColor(),  1.0f,  1.0f, -1.0f}},
{3, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE                    , getBlockColor(),  1.0f, -1.0f, -1.0f}},

{4, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(), -1.0f, -1.0f,  1.0f}},
{5, {x * BLOCK_RENDER_SIZE                    , y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(), -1.0f,  1.0f,  1.0f}},

{6, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(),  1.0f,  1.0f,  1.0f}},
{7, {x * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, y * BLOCK_RENDER_SIZE                    , z * BLOCK_RENDER_SIZE + BLOCK_RENDER_SIZE, getBlockColor(),  1.0f, -1.0f,  1.0f}}


(I didn't add more code because I don't think its necessary)

• This looks more like a minecraft-style world of polygon boxes than a true voxel engine. – Philipp Jul 6 '14 at 21:44
• yes, but they share the same name – Duckdoom5 Jul 6 '14 at 21:55
• You are asking a question about graphics programming, where polygon-based rendering and voxel-based rendering are two completely different things. When you are looking for relevant information, you should always try to use the correct terminology. – Philipp Jul 6 '14 at 22:05
• According to that wiki page you just send me, Minecraft is a voxel engine. According to the Google Image search a voxel engine is also both a minecraft like game and a true voxel engine. But if its not the correct term, please tell me what the term should be and I'll edit the title for you. – Duckdoom5 Jul 6 '14 at 22:07
• There is exactly one sentence in that article which mentions minecraft, and that one sentence says that it uses a polygon-engine and not a voxel-engine. – Philipp Jul 6 '14 at 22:12