improve textures

This commit is contained in:
2025-11-15 13:26:23 +01:00
parent dbbcd7f926
commit 9e86abe60b
10 changed files with 47 additions and 25 deletions

View File

@@ -82,11 +82,6 @@ public class GameScreen implements Screen {
60f, 60f, // viewport size
1f, 100f // near/far for the light camera
);
// initial values; DayNightCycle will start animating these
shadowLight.set(
1.0f, 0.85f, 0.9f, // light color
-0.7f, -1.0f, -0.3f // direction
);
environment.add(shadowLight);
environment.shadowMap = shadowLight;
@@ -96,9 +91,9 @@ public class GameScreen implements Screen {
// create the cycle controller
dayNightCycle = new DayNightCycle(shadowLight, ambientLight);
// optional: start at morning/noon/etc
dayNightCycle.setTimeOfDay(0.4f); // good sun
dayNightCycle.setTimeOfDay(0.2f); // good sun
dayNightCycle.setAxialTilt(30f);
dayNightCycle.setDayLength(60f * 5f); // 20 minutes
dayNightCycle.setDayLength(10f); // 5 minutes
}
private void initWorld() {

View File

@@ -12,14 +12,14 @@ public class DayNightCycle {
private final ColorAttribute ambientLight;
// base colors
private final Color dayAmbient = new Color(0.5f, 0.5f, 0.5f, 1f);
private final Color nightAmbient = new Color(0.05f, 0.05f, 0.1f, 1f);
private final Color dayAmbient = new Color(0.6f, 0.7f, 0.7f, 1f);
private final Color nightAmbient = new Color(0.2f, 0.15f, 0.2f, 1f);
private final Color daySunColor = new Color(1.0f, 0.85f, 0.9f, 1f);
private final Color daySunColor = new Color(1.0f, 0.9f, 1f, 1f);
private final Color nightSunColor = new Color(0.4f, 0.4f, 0.6f, 1f);
private final Color daySkyColor = new Color(0.5f, 0.6f, 1.0f, 1f);
private final Color nightSkyColor = new Color(0.02f, 0.02f, 0.06f, 1f);
private final Color daySkyColor = new Color(0.8f, 0.9f, 1.0f, 1f);
private final Color nightSkyColor = new Color(0.1f, 0.01f, 0.2f, 1f);
private final Color currentSkyColor = new Color();
private final Color tmpSunColor = new Color();

View File

@@ -46,7 +46,7 @@ public class FpsCameraController {
private int centerX;
private int centerY;
private int captureWarmupFrames = 0;
private static final int WARMUP_FRAMES = 6; // frames to ignore after capture
private static final int WARMUP_FRAMES = 10; // frames to ignore after capture
private Cursor invisibleCursor;

View File

@@ -15,16 +15,19 @@ public class ModelLibrary {
private final ModelBuilder builder = new ModelBuilder();
public final Texture groundTexture;
public final Texture pathTexture;
public final Texture houseTexture; // <-- new
public final Model groundModel;
public final Model unitCubeModel;
// new: town-related primitives
// town-related primitives
public final Model houseBlockModel;
public final Model pathTileModel;
public ModelLibrary() {
// --- ground texture + model (unchanged) ---
groundTexture = new Texture(Gdx.files.internal("textures/paving.png"));
// --- ground texture + model ---
groundTexture = new Texture(Gdx.files.internal("textures/rocky_grass_2.png"));
groundTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
groundTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
@@ -55,33 +58,54 @@ public class ModelLibrary {
);
groundModel = builder.end();
// generic 2x2x2 cube
// generic cube (still untextured)
unitCubeModel = builder.createBox(
1f, 1f, 1f,
new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
);
// simple “blocky house” primitive: 4x3x4
// --- house texture + model ---
// assumes textures/texture_09.png exists
houseTexture = new Texture(Gdx.files.internal("textures/texture_03.png"));
houseTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
houseTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
houseBlockModel = builder.createBox(
4f, 3f, 4f,
new Material(ColorAttribute.createDiffuse(0.9f, 0.8f, 0.7f, 1f)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
new Material(
TextureAttribute.createDiffuse(houseTexture)
// optionally tint:
// ColorAttribute.createDiffuse(0.9f, 0.8f, 0.7f, 1f)
),
VertexAttributes.Usage.Position
| VertexAttributes.Usage.Normal
| VertexAttributes.Usage.TextureCoordinates // <-- important
);
// flat path tile (2D quad slightly above ground)
// --- path tile texture + model ---
pathTexture = new Texture(Gdx.files.internal("textures/paving_2.png"));
pathTexture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
pathTexture.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
builder.begin();
Material pathMat = new Material(
ColorAttribute.createDiffuse(0.6f, 0.6f, 0.6f, 1f)
TextureAttribute.createDiffuse(pathTexture)
);
MeshPartBuilder pathMpb = builder.part(
"pathTile",
GL20.GL_TRIANGLES,
VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal,
VertexAttributes.Usage.Position
| VertexAttributes.Usage.Normal
| VertexAttributes.Usage.TextureCoordinates,
pathMat
);
float tHalf = 1f; // tile size 4x4
float y = 0.01f; // just above ground to avoid z-fighting
float tHalf = 1f; // 2x2 tile
float y = 0.01f;
pathMpb.setUVRange(0f, 0f, 0.5f, 0.5f);
pathMpb.rect(
-tHalf, y, tHalf,
tHalf, y, tHalf,
@@ -97,6 +121,9 @@ public class ModelLibrary {
unitCubeModel.dispose();
houseBlockModel.dispose();
pathTileModel.dispose();
groundTexture.dispose();
pathTexture.dispose();
houseTexture.dispose(); // <-- new
}
}