- Home /
Vertex Color error
Hey I have this code:
byte currentLight = World.instance.GetLightData(worldPos + new Vector2(0,0));
byte topLight = World.instance.GetLightData(worldPos + new Vector2(0, 1));
byte topLeftLight = World.instance.GetLightData(worldPos + new Vector2(-1, 1));
byte topRightLight = World.instance.GetLightData(worldPos + new Vector2(1, 1));
byte bottomLight = World.instance.GetLightData(worldPos + new Vector2(0, -1));
byte bottomLeftLight = World.instance.GetLightData(worldPos + new Vector2(-1, -1));
byte bottomRightLight = World.instance.GetLightData(worldPos + new Vector2(1, -1));
byte leftLight = World.instance.GetLightData(worldPos + new Vector2(-1, 0));
byte rightLight = World.instance.GetLightData(worldPos + new Vector2(1, 0));
// Bottom-Left Vertex
byte vertexColor = (byte)((leftLight + currentLight + bottomLight + bottomLeftLight) / 4);
terrainVertexColors.Add(new Color32(vertexColor, vertexColor, vertexColor, 0));
// Top-Left Vertex
vertexColor = (byte)((topLeftLight + topLight + currentLight + leftLight) / 4);
terrainVertexColors.Add(new Color32(vertexColor, vertexColor, vertexColor, 0));
// Top-Right Vertex
vertexColor = (byte)((topLight + topRightLight + rightLight + currentLight) / 4);
terrainVertexColors.Add(new Color32(vertexColor, vertexColor, vertexColor, 0));
// Bottom-Right Vertex
vertexColor = (byte)((currentLight + rightLight + bottomRightLight + bottomLight) / 4);
terrainVertexColors.Add(new Color32(vertexColor, vertexColor, vertexColor, 0));
And this is the result:
I found this, scroll down to "Details regarding meshing".
But I still don't know how to fix this. Does anyone have an idea?
Thanks!
lighting.png
(124.8 kB)
Comment
you have to zoom in in its unclear, even at full brightness i can see anything shocking,just a tiny shade issue, put the mesh screenshot too because i cant see if every square is a quad.
This is how it should look, but it does only on left corners.
This is how it looks on right corners:
Your answer
Follow this Question
Related Questions
2D lighting question (Normal Maps?) 0 Answers
Terraria / Starbound Style Lighting 3 Answers
Collision/scripting for tiles 0 Answers
Unity 2D Lights Shader 0 Answers
How do I get my tiles to overlap my Background sprite? 2D 1 Answer