<commit_before>void transformToTS(in vec3 normal, inout vec3 lightDir, inout vec3 eyeDir)
{
    // derive the tangent space basis
    // we do this in the pixel shader because we don't have per-vertex normals
    // because of the LOD, we use a normal map
    // tangent is always +x or -z in object space depending on alignment
#ifdef TERRAIN_ALIGN_Y_Z
    vec3 tangent = vec3(0, 0, -1);
#else
    vec3 tangent = vec3(1, 0, 0);
#endif
    vec3 binormal = normalize(cross(tangent, normal));
    // note, now we need to re-cross to derive tangent again because it wasn't orthonormal
    tangent = normalize(cross(normal, binormal));
    // derive final matrix
    mat3 TBN = mtxFromRows(tangent, binormal, normal);

    lightDir = normalize(mul(TBN, lightDir));
    eyeDir = normalize(mul(TBN, eyeDir));
}

void blendTerrainLayer(in float blendWeight, in vec2 uv0, in float uvMul,
#ifdef TERRAIN_PARALLAX_MAPPING
                    in vec3 eyeDir, in vec2 scaleBias,
#endif
#ifdef TERRAIN_NORMAL_MAPPING
                    in sampler2D normtex, inout vec3 normal,
#endif
                    in sampler2D difftex, inout vec4 diffuseSpec)
{
    // generate UV
    vec2 uv = mod(uv0 * uvMul, 1.0);

#ifdef TERRAIN_PARALLAX_MAPPING
    SGX_Generate_Parallax_Texcoord(normtex, uv, eyeDir, scaleBias, uv);
#endif

    // sample diffuse texture
    vec4 diffuseSpecTex = texture2D(difftex, uv);
    // apply to common
    diffuseSpec = mix(diffuseSpec, diffuseSpecTex, blendWeight);

#ifdef TERRAIN_NORMAL_MAPPING
    vec3 TSnormal;
    // access TS normal map
    SGX_FetchNormal(normtex, uv, TSnormal);
    normal += TSnormal * blendWeight;
#endif
}<commit_msg>Terrain: fix precision issues on GLES2<commit_after>void transformToTS(in vec3 normal, inout vec3 lightDir, inout vec3 eyeDir)
{
    // derive the tangent space basis
    // we do this in the pixel shader because we don't have per-vertex normals
    // because of the LOD, we use a normal map
    // tangent is always +x or -z in object space depending on alignment
#ifdef TERRAIN_ALIGN_Y_Z
    vec3 tangent = vec3(0, 0, -1);
#else
    vec3 tangent = vec3(1, 0, 0);
#endif
    vec3 binormal = normalize(cross(tangent, normal));
    // note, now we need to re-cross to derive tangent again because it wasn't orthonormal
    tangent = normalize(cross(normal, binormal));
    // derive final matrix
    mat3 TBN = mtxFromRows(tangent, binormal, normal);

    lightDir = normalize(mul(TBN, lightDir));
    eyeDir = normalize(mul(TBN, eyeDir));
}

void blendTerrainLayer(in float blendWeight, in f32vec2 uv0, in float uvMul,
#ifdef TERRAIN_PARALLAX_MAPPING
                    in vec3 eyeDir, in vec2 scaleBias,
#endif
#ifdef TERRAIN_NORMAL_MAPPING
                    in sampler2D normtex, inout vec3 normal,
#endif
                    in sampler2D difftex, inout vec4 diffuseSpec)
{
    // generate UV
    vec2 uv = mod(uv0 * uvMul, 1.0);

#ifdef TERRAIN_PARALLAX_MAPPING
    SGX_Generate_Parallax_Texcoord(normtex, uv, eyeDir, scaleBias, uv);
#endif

    // sample diffuse texture
    vec4 diffuseSpecTex = texture2D(difftex, uv);
    // apply to common
    diffuseSpec = mix(diffuseSpec, diffuseSpecTex, blendWeight);

#ifdef TERRAIN_NORMAL_MAPPING
    vec3 TSnormal;
    // access TS normal map
    SGX_FetchNormal(normtex, uv, TSnormal);
    normal += TSnormal * blendWeight;
#endif
}
{'fraction_non_alphanumeric': 0.08527827648114901, 'fraction_numerical': 0.018850987432675045, 'mean_word_length': 3.2749360613810743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2248674', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1084, 'n_words': 357}