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, type: float,
name: lineSize name: lineSize
},
{
type: float3,
name: gridColor
} }
], ],
depthWrite : true, depthWrite : true,
depthCulling : true, depthCulling : true,
doubleSided: true, doubleSided: false,
shadingModel : unlit, shadingModel : unlit,
blending : transparent, blending : transparent,
transparency: twoPassesOneSide,
variantFilter : [ dynamicLighting, directionalLighting, shadowReceiver, skinning, ssr, stereo ], variantFilter : [ dynamicLighting, directionalLighting, shadowReceiver, skinning, ssr, stereo ],
culling : none, culling : none,
instanced : false, instanced : false,
@@ -80,7 +83,8 @@ fragment {
float fade = 1.0 - angle; float fade = 1.0 - angle;
fade *= 0.5 - smoothstep(0.0, materialParams.distance, dist - materialParams.distance); 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); vec3 planeAxes = vec3(1.0f, 0.0f, 1.0f);
@@ -99,23 +103,18 @@ fragment {
vec3 axes = getAxes(distanceToAxes, dAxes, 0.1); vec3 axes = getAxes(distanceToAxes, dAxes, 0.1);
vec4 color = vec4( vec4 color = vec4(
0.1f, materialParams.gridColor.r,
0.1f, materialParams.gridColor.g,
0.1f, materialParams.gridColor.b,
gridA gridA * fade
); );
color.a = max(color.a, axes.x);
color.rgb = (axes.x < 1e-8) ? color.rgb : AXIS_COLOR_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.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: GRID_GRID_OFFSET:
.int 0 .int 0
GRID_GRID_SIZE: GRID_GRID_SIZE:
.int 52018 .int 52094

View File

@@ -8,5 +8,5 @@ _GRID_PACKAGE:
_GRID_GRID_OFFSET: _GRID_GRID_OFFSET:
.int 0 .int 0
_GRID_GRID_SIZE: _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> #include <stdint.h>
#ifdef __cplusplus
extern "C" { extern "C" {
#endif
extern const uint8_t GRID_PACKAGE[]; extern const uint8_t GRID_PACKAGE[];
extern int GRID_GRID_OFFSET; extern int GRID_GRID_OFFSET;
extern int GRID_GRID_SIZE; extern int GRID_GRID_SIZE;
#ifdef __cplusplus
} }
#endif
#define GRID_GRID_DATA (GRID_PACKAGE + GRID_GRID_OFFSET) #define GRID_GRID_DATA (GRID_PACKAGE + GRID_GRID_OFFSET)
#endif #endif