mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 12:49:13 +01:00
refactor(track): the ballast fades into that of the tracks joined, as the rails do
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// the rails of a track faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
// the rails and the ballast of a track faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
#texture (diffuse1, 1, sRGB_A)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// the ballast of a track mixed in grains into that of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_GRAIN 1
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
#texture (diffuse1, 1, sRGB_A)
|
||||
uniform sampler2D diffuse1;
|
||||
#texture (diffuse2, 2, sRGB_A)
|
||||
uniform sampler2D diffuse2;
|
||||
#texture (diffuse3, 3, sRGB_A)
|
||||
uniform sampler2D diffuse3;
|
||||
#include <trackblend.glsl>
|
||||
@@ -1,4 +1,4 @@
|
||||
// the rails of a track of a normal mapped material faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
// the rails and the ballast of a track of a normal mapped material faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
// the ballast of a track of a normal mapped material mixed in grains into that of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_GRAIN 1
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
#texture (diffuse1, 1, sRGB_A)
|
||||
uniform sampler2D diffuse1;
|
||||
#texture (diffuse2, 2, sRGB_A)
|
||||
uniform sampler2D diffuse2;
|
||||
#texture (diffuse3, 3, sRGB_A)
|
||||
uniform sampler2D diffuse3;
|
||||
#texture (normalmap, 4, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
#texture (normalmap1, 5, RGBA)
|
||||
uniform sampler2D normalmap1;
|
||||
#texture (normalmap2, 6, RGBA)
|
||||
uniform sampler2D normalmap2;
|
||||
#texture (normalmap3, 7, RGBA)
|
||||
uniform sampler2D normalmap3;
|
||||
#include <trackblend.glsl>
|
||||
@@ -1,4 +1,4 @@
|
||||
// the rails of a track of a parallax material faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
// the rails and the ballast of a track of a parallax material faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#define TRACKBLEND_PARALLAX 1
|
||||
#param (height_scale, 2, 1, 1, zero)
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
// the ballast of a track of a parallax material mixed in grains into that of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_GRAIN 1
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#define TRACKBLEND_PARALLAX 1
|
||||
#param (height_scale, 2, 1, 1, zero)
|
||||
#param (height_offset, 2, 2, 1, zero)
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
#texture (diffuse1, 1, sRGB_A)
|
||||
uniform sampler2D diffuse1;
|
||||
#texture (diffuse2, 2, sRGB_A)
|
||||
uniform sampler2D diffuse2;
|
||||
#texture (diffuse3, 3, sRGB_A)
|
||||
uniform sampler2D diffuse3;
|
||||
#texture (normalmap, 4, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
#texture (normalmap1, 5, RGBA)
|
||||
uniform sampler2D normalmap1;
|
||||
#texture (normalmap2, 6, RGBA)
|
||||
uniform sampler2D normalmap2;
|
||||
#texture (normalmap3, 7, RGBA)
|
||||
uniform sampler2D normalmap3;
|
||||
#include <trackblend.glsl>
|
||||
@@ -1,4 +1,4 @@
|
||||
// the rails of a track of a material with normal and specgloss maps faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
// the rails and the ballast of a track of a material with normal and specgloss maps faded into those of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#define TRACKBLEND_SPECGLOSS 1
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
// the ballast of a track of a material with normal and specgloss maps mixed in grains into that of the tracks joined at its ends, see trackblend.glsl
|
||||
#define TRACKBLEND_GRAIN 1
|
||||
#define TRACKBLEND_NORMALMAP 1
|
||||
#define TRACKBLEND_SPECGLOSS 1
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
#texture (diffuse1, 1, sRGB_A)
|
||||
uniform sampler2D diffuse1;
|
||||
#texture (diffuse2, 2, sRGB_A)
|
||||
uniform sampler2D diffuse2;
|
||||
#texture (normalmap, 3, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
#texture (normalmap1, 4, RGBA)
|
||||
uniform sampler2D normalmap1;
|
||||
#texture (normalmap2, 5, RGBA)
|
||||
uniform sampler2D normalmap2;
|
||||
#texture (specgloss, 6, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
#include <trackblend.glsl>
|
||||
@@ -1,7 +1,6 @@
|
||||
// a track drawn with the textures of the tracks joined at its ends blended in near them (world/TrackBlend.h): the weights of the
|
||||
// tracks joined at the ends p1, p2 and p4 of a switch in UserData.yzw, their textures in diffuse1..3, normalmap1..3. the
|
||||
// including shader declares the textures and sets:
|
||||
// TRACKBLEND_GRAIN the others come in as grains, as the stones of two ballasts would mix, rather than faded in
|
||||
// tracks joined at the ends p1, p2 and p4 of a switch in UserData.yzw, their textures in diffuse1..3, normalmap1..3, faded into
|
||||
// the texture of the track. the including shader declares the textures and sets:
|
||||
// TRACKBLEND_NORMALMAP with the normal maps of the four, lit as the shader of the material of the track: param[2].x 0 as
|
||||
// mat_default, 1 normalmap, 2 sunlessnormalmap, 3 shadowlessnormalmap
|
||||
// TRACKBLEND_SPECGLOSS the specgloss map of the track itself as well, the textures of the ends p1 and p2 alone (no room
|
||||
@@ -38,49 +37,6 @@ layout(location = 1) out vec4 out_motion;
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
#ifdef TRACKBLEND_GRAIN
|
||||
// grains per repeat of the texture: a ballast texture repeats every few metres, a grain is a handful of its stones
|
||||
const float GRAIN_CELLS = 28.0;
|
||||
|
||||
vec2 grain_hash2(vec2 p)
|
||||
{
|
||||
vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
|
||||
q += dot(q, q.yzx + 33.33);
|
||||
return fract((q.xx + q.yz) * q.zy);
|
||||
}
|
||||
|
||||
float grain_hash1(vec2 p)
|
||||
{
|
||||
vec3 q = fract(vec3(p.xyx) * 0.1031);
|
||||
q += dot(q, q.yzx + 33.33);
|
||||
return fract((q.x + q.y) * q.z);
|
||||
}
|
||||
|
||||
// the value of the grain the point lies in, 0..1: cells around points jittered on a grid, each of one value
|
||||
float grain_value(vec2 p)
|
||||
{
|
||||
vec2 cell = floor(p);
|
||||
vec2 inside = fract(p);
|
||||
float nearest = 8.0;
|
||||
float value = 0.0;
|
||||
for (int y = -1; y <= 1; ++y)
|
||||
{
|
||||
for (int x = -1; x <= 1; ++x)
|
||||
{
|
||||
vec2 offset = vec2(float(x), float(y));
|
||||
vec2 r = offset + grain_hash2(cell + offset) - inside;
|
||||
float d = dot(r, r);
|
||||
if (d < nearest)
|
||||
{
|
||||
nearest = d;
|
||||
value = grain_hash1(cell + offset + 17.31);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TRACKBLEND_PARALLAX
|
||||
// the texture coordinates shifted by the heights (b) of the normal map, as ParallaxMapping() of mat_parallax.frag
|
||||
vec2 parallax_coord(sampler2D heights, vec2 coord, vec3 viewdir, vec2 dcoorddx, vec2 dcoorddy)
|
||||
@@ -142,12 +98,6 @@ void main()
|
||||
vec2 dy = dFdy(f_coord);
|
||||
#ifdef TRACKBLEND_PARALLAX
|
||||
vec3 viewdir = normalize(vec3(0.0) - TangentFragPos);
|
||||
#endif
|
||||
#ifdef TRACKBLEND_GRAIN
|
||||
vec2 grainpos = f_coord * GRAIN_CELLS;
|
||||
// grains smaller than a pixel would shimmer, there the textures fade into each other instead
|
||||
float footprint = max(length(dx), length(dy)) * GRAIN_CELLS;
|
||||
float grained = 1.0 - smoothstep(0.35, 0.9, footprint);
|
||||
#endif
|
||||
vec2 coord = TRACKBLEND_COORD(normalmap);
|
||||
vec4 tex_color = textureGrad(diffuse, coord, dx, dy);
|
||||
@@ -156,15 +106,6 @@ void main()
|
||||
#endif
|
||||
if (total > 0.0)
|
||||
{
|
||||
#ifdef TRACKBLEND_GRAIN
|
||||
// the grain is of the track joined at the end whose share its value falls in, of the track itself past them
|
||||
float pick = grain_value(grainpos);
|
||||
float first = weights.x;
|
||||
float second = weights.x + weights.y;
|
||||
vec3 grain = vec3(float(pick < first), float(pick >= first && pick < second), float(pick >= second && pick < total));
|
||||
weights = mix(weights, grain, grained);
|
||||
total = weights.x + weights.y + weights.z;
|
||||
#endif
|
||||
vec4 blended = tex_color * (1.0 - total);
|
||||
#ifdef TRACKBLEND_NORMALMAP
|
||||
vec4 blendednormal = tex_normal * (1.0 - total);
|
||||
|
||||
Reference in New Issue
Block a user