update grid material

This commit is contained in:
Nick Fisher
2025-07-01 12:12:33 +08:00
parent 4379313932
commit a9b5ca786e
6 changed files with 2544 additions and 2545 deletions

View File

@@ -9,14 +9,17 @@ material {
{
type: float,
name: lineSize
},
{
type: float3,
name: gridColor
}
],
depthWrite : true,
depthCulling : true,
doubleSided: true,
doubleSided: false,
shadingModel : unlit,
blending : transparent,
transparency: twoPassesOneSide,
variantFilter : [ dynamicLighting, directionalLighting, shadowReceiver, skinning, ssr, stereo ],
culling : none,
instanced : false,
@@ -80,7 +83,8 @@ fragment {
float fade = 1.0 - angle;
fade *= 0.5 - smoothstep(0.0, materialParams.distance, dist - materialParams.distance);
float gridA = getGrid(P.xz, fwidthPos.xz, vec2(1.0, 1.0), materialParams.lineSize);
float gridA = 1.0f - getGrid(P.xz, fwidthPos.xz, vec2(1, 1), materialParams.lineSize);
gridA *= gridA;
vec3 planeAxes = vec3(1.0f, 0.0f, 1.0f);
@@ -99,23 +103,18 @@ fragment {
vec3 axes = getAxes(distanceToAxes, dAxes, 0.1);
vec4 color = vec4(
0.1f,
0.1f,
0.1f,
gridA
materialParams.gridColor.r,
materialParams.gridColor.g,
materialParams.gridColor.b,
gridA * fade
);
color.a = max(color.a, axes.x);
color.rgb = (axes.x < 1e-8) ? color.rgb : AXIS_COLOR_X;
color.a = max(color.a, axes.z);
color.rgb = (axes.z < 1e-8) ? color.rgb : AXIS_COLOR_Z;
color.a *= fade;
material.baseColor = color;
material.baseColor = color;
gl_FragDepth = 0.00001f;
gl_FragDepth = 1e-8;
}
}

View File

@@ -8,5 +8,5 @@ GRID_PACKAGE:
GRID_GRID_OFFSET:
.int 0
GRID_GRID_SIZE:
.int 52018
.int 52094

View File

@@ -8,5 +8,5 @@ _GRID_PACKAGE:
_GRID_GRID_OFFSET:
.int 0
_GRID_GRID_SIZE:
.int 52018
.int 52094

File diff suppressed because it is too large Load Diff

View File

@@ -3,15 +3,11 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
extern const uint8_t GRID_PACKAGE[];
extern int GRID_GRID_OFFSET;
extern int GRID_GRID_SIZE;
#ifdef __cplusplus
}
#endif
#define GRID_GRID_DATA (GRID_PACKAGE + GRID_GRID_OFFSET)
#endif