Workaround for texture coordinate problem on border of terrain “chunk”?

It took me a while to diagnose what was going on here but I think I’ve figured out what the problem is, I’m just not sure how to go about fixing it. I’m working on a streaming clipmap terrain where a large heightmap is split into a grid of smaller heightmaps, then at runtime I load in a (at the moment 11×11, but it’s configurable) grid of heightmap chunks into a 2D texture array, along with a small layer index map that I can sample at chunk coordinates (x, y) to determine which array layer that chunk’s heightmap is stored. Layers become recyclable when the camera moves out of range, and new chunks get loaded in.

So far the heightmapping works perfectly, there are no gaps in the terrain. However now I have added normal mapping in using the same method (another identically sized 2D texture array using the same layer indexes as the heightmap array for simplicity), I’ve come across an issue that happens with polygons on the outer edges of each chunk.

Terrain normal map artefact

Terrain normal map artefact wireframe

In the screenshots above the axis helper is placed exactly on (x, z) = (512.0, 512.0) (Y is "up"). Each square of terrain vertices at the lowest clipmap resolution is always equal to 1 pixel of heightmap and normal map. This makes determining vertex height a simple matter of using texelFetch. I’ve added a variable called IVS (intra-vertex spacing) to control how many world units each pixel represents. In all my screenshots I’m using a 32×32 grid of 1024×1024 heightmaps with an IVS of 0.5, so each chunk is 512u and 1024 pixels.

Unfortunately if I colour the terrain based on normal map coordinates I can see the problem (I am pretty sure) is on the edge squares. For the squares on the chunk edges the face of the poly is shaded from tex coordinate 1023/1024 to 0.0, rather than from 1023/1024 to 1024/1024/1.0, or that’s at least what it looks like from this:

NOTE: in this screenshot, 511 should be 511.5. Apologies. Terrain coloured by normal map coordinates

Essentially because the texture coordinates for a vertex at the "start" (top left) of a chunk are always 0,0, at no point do any vertices get assigned 1,1. Is there a way I can tell OpenGL that I want world coordinates 512,512 to be texture coordinates 1,1 when shading the triangles between it and 511.5,511.5, and 0,0 for the ones on the other side?

In case my analysis was wrong or my explanation wasn’t great here’s my shader code. Maybe there is something easy I have missed in here, but from what I can tell the numbers work:

//Vertex shader for terrain. #include <attributes>  uniform mat4 ModelViewMatrix; uniform mat3 NormalMatrix; uniform mat4 MVP;  uniform float Scale; uniform vec2 Offset; uniform mat4 RotMatrix; uniform float IVS; uniform float MinHeight; uniform float MaxHeight; uniform int ChunkSize; uniform int MapWidth; uniform int MapHeight; uniform sampler2DArray Heightfield; uniform sampler2D LayerIndexMap;  out float Height; out vec3 NormalMapCoords;  void main() {     // Get the XZ world coordinates of the vertex.     vec2 vertXZ = Offset + (RotMatrix * vec4(VertexPosition, 1.0)).xz * Scale;     float chunkWorldSize = ChunkSize * IVS;      // Get the chunk xy and the layer index to sample from.     int chunkX = int(floor(vertXZ.x / chunkWorldSize));     int chunkY = int(floor(vertXZ.y / chunkWorldSize));     float layerIdx = texelFetch(LayerIndexMap, ivec2(chunkX, chunkY), 0).r * 256.0;      // Scale the vertex coords to the chunk image size.     vec2 pixelXY = vec2(         mod(vertXZ.x, chunkWorldSize) / IVS,         mod(vertXZ.y, chunkWorldSize) / IVS     ); // if IVS = 0.5 and vertXZ = 511.5, then pixelXY = 1023     float sampledHeight = texelFetch(Heightfield, ivec3(pixelXY.x, pixelXY.y, layerIdx), 0).r;      NormalMapCoords = vec3(         pixelXY.x / float(ChunkSize),         pixelXY.y / float(ChunkSize),         layerIdx     );      float heightMod = int(chunkX >= 0 && chunkX < MapWidth && chunkY >= 0 && chunkY < MapHeight);     sampledHeight = sampledHeight * heightMod;      Height = ((MaxHeight - MinHeight) * sampledHeight) + MinHeight;     vec3 finalPos = vec3(VertexPosition.x, Height, VertexPosition.z);      // Set the vertex position.     gl_Position = MVP * mat4(1.0) * vec4(finalPos, 1.0); } 
//Fragment shader for terrain. uniform vec3 SunVec; uniform sampler2DArray NormalMap; uniform int MeshType; //TODO debug uniform int RotIndex; //TODO debug  in float Height; in vec3 NormalMapCoords;  out vec4 fragColor;  // All components are in the range [0…1], including hue. vec3 hsv2rgb(vec3 c) {     vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);     vec3 p = abs(fract( + * 6.0 - K.www);     return c.z * mix(, clamp(p -, 0.0, 1.0), c.y); }  void main() {     //vec3 baseCol = vec3(hsv2rgb(vec3(106.0 / 255.0, 1, 1))); // Flat colour.     //vec3 baseCol = vec3(hsv2rgb(vec3(Height, 1, 1))); // Colour by height.     vec3 baseCol = vec3(hsv2rgb(vec3((NormalMapCoords.x + NormalMapCoords.y) / 2.0, 1, 1))); // Colour by normal map coords.      vec3 ambient = vec3(0.1, 0.1, 0.1); //TODO use a combination of colour control maps and daylight in-shadow light intensity to calc this (col * intensity)      vec2 normalXZ = texture(NormalMap, NormalMapCoords, 0).rg;     float normalY = 1.0 - (normalXZ.x + normalXZ.y);     float sunlight = max(0.0, dot(normalize(vec3(normalXZ.x, normalY, normalXZ.y)), normalize(SunVec)));      vec3 finalCol = (ambient + sunlight) * baseCol;     fragColor = vec4(finalCol, 1.0); } 

The normal map is using LINEAR for both filters and CLAMP_TO_EDGE for S and T wrapping, and I should also point out a chunk is not a single mesh. The clipmap follows the camera around and covers multiple chunks.

Border of multiple details tags in one html row are not working responsive [closed]

I have a proble on my website: . I have several accordion menus which I made with pure css without any javascript and everything works perfect, except for one problem:

When I click on the categories to expand the tag, all other boxes which are collapsed with the detail tag which are on the same row will expand their border from the .div. Is there any way to fix this problem without using javascript? I tried to only draw the border if the details tag is open, however then I run into the problem that the border is smaller than the .div because it will be only assigned to the details tag. The best way would be to be able to select the parent element from the details[open] tag. However after doing some research that is not possible with css3 only. Anyone has ideas how to fix this problem? On mobile it works perfectly fine because only one row is displayed….

Here is an image of the problem: CSS Problem

How to move axis and ticklables in RegionPlot to the top? How to change border line color?

I use this code

RegionPlot[Sin[t^(1/3)*y] > 0, {y, 0, 5}, {t, 0, 8},   FrameLabel -> {"y", Rotate["t", 270 Degree]}] 

and the result is

enter image description here

Now, I have three questions:

  1. How can I move the $ y$ axis (and ticklabels) to the top instead of bottom?
  2. How can I change border lines color?
  3. Is it possible to change the color of one of the blue parts?

Can a Divination wizard in the Border Ethereal use the Portent feature to influence rolls of creatures on the Material Plane?

A particular School of Divination wizard is native to the Ethereal Plane (he was created by a wish spell replicating simulacrum cast on that plane).

While this wizard is in the Border Ethereal, can he use his Portent feature to affect the rolls of creatures on the Material Plane?

Is there any mundane way to travel from the Border Ethereal of a plane to the plane itself?

Say a commoner with no spells, class features, or magic items is Plane Shifted from the Material Plane to the Border Ethereal.

The DMG makes mention of "curtains" that allow travel from the Deep Etheral to the Border Ethereal, but nothing of any portals in the Ethereal plane itself.

Is there any way for this individual to return to the Material Plane?

When should an input validation border change?

When I was working on validation just now, I came up with a couple of questions with regard to validation. When should an input border’s color change?

  • When should it turn from (a default or) no color to e.g. a green-colored border?
  • when should it turn from (a default or) no color to e.g. a red-colored border?
  • When should it turn from e.g. a red-colored border to e.g. a green-colored border?

Most of the time I see that either the input’s border color changes on the submition of the form or when the input’s value changes (see below as an example).


Isn’t changing the color on the submition too late?

Isn’t changing the color on input’s value change too broad? (What about if I fill in a number inside a text input field, the border will change from red to green whilst the value inside related input is actually, in fact, invalid?)

Is there any best practice or are there any guidelines for the handling of input validation when it comes to user experience?