<@include gpu/Config.slh@><$VERSION_HEADER$>// <$_SCRIBE_FILENAME$>// Generated on <$_SCRIBE_DATE$>//// Created by Zach Pomerantz on 2/16/2016.// Copyright 2016 High Fidelity, Inc.// Copyright 2024 Overte e.V.//// Distributed under the Apache License, Version 2.0.// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html// <@include gpu/ShaderConstants.h@><@include gpu/Paint.slh@> <@if not HIFI_USE_FORWARD@> <@include DeferredBufferWrite.slh@> INPUT(RENDER_UTILS_ATTR_PREV_POSITION_CS, vec4, _prevPositionCS);<@else@> OUTPUT(0, vec4, _fragColor0);<@endif@> struct Grid { vec4 period; vec4 offset; vec4 edge;}; UNIFORM_BUFFER(0, gridBuffer) { Grid grid; }; INPUT(GPU_ATTR_TEXCOORD0, vec2, varTexCoord0);INPUT(GPU_ATTR_TEXCOORD1, vec2, varTexCoord1);INPUT(GPU_ATTR_COLOR, vec4, varColor); void main(void) { float gridLine = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), float(grid.edge.z == 0.0)); // TODO: this is temporary until Grid can get an // entity property for toggling the radius fade<@if HIFI_USE_TRANSLUCENT@> const float SQRT_2 = 1.4142135623730951; // multiply by sqrt(2) to hide the chunk pop-in on the corners float fade = clamp(1.0 - (length(varTexCoord1) * SQRT_2), 0.0, 1.0); float gridWeight = gridLine * fade;<@else@> float gridWeight = gridLine;<@endif@> if (gridWeight <= 0.0) { discard; } vec4 color = varColor; color.a *= gridWeight; <@if not HIFI_USE_FORWARD@> <@if not HIFI_USE_TRANSLUCENT@> vec3 NORMAL = vec3(1.0, 0.0, 0.0); packDeferredFragmentUnlit(_prevPositionCS, NORMAL, 1.0, color.rgb); <@else@> packDeferredFragmentTranslucentUnlit(color.a, color.rgb); <@endif@><@else@> _fragColor0 = color;<@endif@>}
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Zach Pomerantz on 2/16/2016.
// Copyright 2016 High Fidelity, Inc.
// Copyright 2024 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/ShaderConstants.h@>
<@include gpu/Paint.slh@>
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
INPUT(RENDER_UTILS_ATTR_PREV_POSITION_CS, vec4, _prevPositionCS);
<@else@>
OUTPUT(0, vec4, _fragColor0);
<@endif@>
struct Grid {
vec4 period;
vec4 offset;
vec4 edge;
};
UNIFORM_BUFFER(0, gridBuffer) {
Grid grid;
};
INPUT(GPU_ATTR_TEXCOORD0, vec2, varTexCoord0);
INPUT(GPU_ATTR_TEXCOORD1, vec2, varTexCoord1);
INPUT(GPU_ATTR_COLOR, vec4, varColor);
void main(void) {
float gridLine = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
float(grid.edge.z == 0.0));
// TODO: this is temporary until Grid can get an
// entity property for toggling the radius fade
<@if HIFI_USE_TRANSLUCENT@>
const float SQRT_2 = 1.4142135623730951;
// multiply by sqrt(2) to hide the chunk pop-in on the corners
float fade = clamp(1.0 - (length(varTexCoord1) * SQRT_2), 0.0, 1.0);
float gridWeight = gridLine * fade;
<@else@>
float gridWeight = gridLine;
<@endif@>
if (gridWeight <= 0.0) { discard; }
vec4 color = varColor;
color.a *= gridWeight;
<@if not HIFI_USE_FORWARD@>
<@if not HIFI_USE_TRANSLUCENT@>
vec3 NORMAL = vec3(1.0, 0.0, 0.0);
packDeferredFragmentUnlit(_prevPositionCS, NORMAL, 1.0, color.rgb);
<@else@>
packDeferredFragmentTranslucentUnlit(color.a, color.rgb);
<@endif@>
<@else@>
_fragColor0 = color;
<@endif@>
}