Class TexturedTriangle
java.lang.Object
eu.svjatoslav.aukio.e3d.renderer.raster.shapes.AbstractShape
eu.svjatoslav.aukio.e3d.renderer.raster.shapes.AbstractCoordinateShape
eu.svjatoslav.aukio.e3d.renderer.raster.shapes.basic.texturedpolygon.TexturedTriangle
- Direct Known Subclasses:
LightmappedTriangle
A textured triangle renderer with perspective-correct texture mapping.
Quake-style subdivided perspective correction: (u/z, v/z, 1/z) are interpolated linearly in screen space and the exact texture coordinate is recovered with one reciprocal per subdivision interval, with affine stepping in between. This makes screen-size tessellation unnecessary — triangles of any size render with correct perspective.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final AtomicLongTriangles facing away (engine winding convention).static final AtomicLongTriangles discarded by vertical render-bounds clamp.static final AtomicLongPixel loop iterations across all spans.static final AtomicLongScanline spans drawn.static final AtomicLongTriangles with screen bounding box below 2x2 pixels.static final AtomicLongpaintTriangle invocations.Fields inherited from class AbstractCoordinateShape
shapeId, verticesFields inherited from class AbstractShape
cachedBoundingBox, mouseInteractionController -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTexturedTriangle(Texture texture) Constructor for flat-array-backed subclasses (MeshTriangle) that carry noVertexobjects and paint exclusively throughpaintFlat(RenderingContext, Texture, boolean, Point2D, Point2D, Point2D, Point2D, Point2D, Point2D, double, double, double, double, double), which computes the mipmap metric inline.TexturedTriangle(Vertex p1, Vertex p2, Vertex p3, Texture texture) Creates a textured triangle with the specified vertices and texture. -
Method Summary
Modifier and TypeMethodDescriptionvoidReturns to painting the bare texture (stage-1 preview over).voidReturns to the haze-free span path (atmosphere off or too near).Returns the current texture.booleanChecks if backface culling is enabled for this triangle.static booleanReturns whether perspective-correct texture mapping is enabled.voidpaint(RenderingContext renderBuffer) Paints this shape onto the rendering context's pixel buffer.static voidResets all profiling counters.protected final voidRecomputes the mipmap-selection metric after texture coordinates are replaced post-construction (used by generated-UV subclasses like lightmapped triangles).voidsetBackfaceCulling(boolean backfaceCulling) Enables or disables backface culling for this triangle.voidsetGiShade(float r, float g, float b) Stamps a uniform GI light triplet on this triangle (stage-1 preview): the span loops multiply every sampled texel by triplet / 255 untilclearGiShade()is called.voidsetHaze(float mulR, float mulG, float mulB, float addR, float addG, float addB) Stamps this triangle's haze blend: the span loops computetexel * mul / 255 + addper channel — the attenuation half of the haze rides the light multiply that already exists, so the per-pixel price is one add per channel, no extra multiplication.static voidsetPerspectiveCorrectionEnabled(boolean enabled) Enables or disables perspective-correct texture mapping.voidsetTexture(Texture texture) Atomically swaps the texture.Methods inherited from class AbstractCoordinateShape
clippedVertices, getBoundingBox, getScreenXMargin, getScreenYMargin, getZ, getZ, onScreenMaxX, onScreenMaxY, onScreenMinX, onScreenMinY, setSlotScreenState, setZ, transform, translateMethods inherited from class AbstractShape
getTransformWeight, invalidateBounds, setMouseInteractionController
-
Field Details
-
PROF_TRIS
paintTriangle invocations. -
PROF_BACKFACE
Triangles facing away (engine winding convention). -
PROF_OFFY
Triangles discarded by vertical render-bounds clamp. -
PROF_TINY
Triangles with screen bounding box below 2x2 pixels. -
PROF_SPANS
Scanline spans drawn. -
PROF_PIXELS
Pixel loop iterations across all spans.
-
-
Constructor Details
-
TexturedTriangle
Creates a textured triangle with the specified vertices and texture.- Parameters:
p1- the first vertex (must have textureCoordinate set)p2- the second vertex (must have textureCoordinate set)p3- the third vertex (must have textureCoordinate set)texture- the texture to apply
-
TexturedTriangle
Constructor for flat-array-backed subclasses (MeshTriangle) that carry noVertexobjects and paint exclusively throughpaintFlat(RenderingContext, Texture, boolean, Point2D, Point2D, Point2D, Point2D, Point2D, Point2D, double, double, double, double, double), which computes the mipmap metric inline.totalTextureDistanceis set to a neutral 1 — never read on that path.- Parameters:
texture- the texture the subclass paints with
-
-
Method Details
-
setPerspectiveCorrectionEnabled
public static void setPerspectiveCorrectionEnabled(boolean enabled) Enables or disables perspective-correct texture mapping. When disabled, rendering falls back to plain affine mapping, which visibly warps textures on large on-screen triangles at steep angles.- Parameters:
enabled-truefor perspective-correct mapping
-
isPerspectiveCorrectionEnabled
public static boolean isPerspectiveCorrectionEnabled()Returns whether perspective-correct texture mapping is enabled.- Returns:
truewhen perspective correction is active
-
getTexture
-
setTexture
Atomically swaps the texture. Painters pick up the new texture at the next paint call; a triangle in flight finishes with the old one.- Parameters:
texture- the new texture
-
setGiShade
public void setGiShade(float r, float g, float b) Stamps a uniform GI light triplet on this triangle (stage-1 preview): the span loops multiply every sampled texel by triplet / 255 untilclearGiShade()is called.- Parameters:
r- red light units (255 = full)g- green light unitsb- blue light units
-
clearGiShade
public void clearGiShade()Returns to painting the bare texture (stage-1 preview over). -
setHaze
public void setHaze(float mulR, float mulG, float mulB, float addR, float addG, float addB) Stamps this triangle's haze blend: the span loops computetexel * mul / 255 + addper channel — the attenuation half of the haze rides the light multiply that already exists, so the per-pixel price is one add per channel, no extra multiplication.- Parameters:
mulR- red shade multiplier including (1-f) (255 = full)mulG- green multipliermulB- blue multiplieraddR- red additive sky term (sky × f)addG- green additive termaddB- blue additive term
-
clearHaze
public void clearHaze()Returns to the haze-free span path (atmosphere off or too near). -
profReset
public static void profReset()Resets all profiling counters. -
refreshTextureDistance
protected final void refreshTextureDistance()Recomputes the mipmap-selection metric after texture coordinates are replaced post-construction (used by generated-UV subclasses like lightmapped triangles). -
paint
Description copied from class:AbstractCoordinateShapePaints this shape onto the rendering context's pixel buffer.This method is called after all shapes have been transformed and sorted by depth. Implementations should use the transformed screen-space coordinates from
Vertex.transformedCoordinate(RenderingContext)to draw pixels.- Specified by:
paintin classAbstractCoordinateShape- Parameters:
renderBuffer- the rendering context containing the pixel buffer and graphics context
-
isBackfaceCullingEnabled
public boolean isBackfaceCullingEnabled()Checks if backface culling is enabled for this triangle.- Returns:
trueif backface culling is enabled
-
setBackfaceCulling
public void setBackfaceCulling(boolean backfaceCulling) Enables or disables backface culling for this triangle.- Parameters:
backfaceCulling-trueto enable backface culling
-