<commit_before>#ifdef GL_ES
precision highp float;
#endif

varying vec3 vNormal;

uniform sampler2D uReflectionEnvMap;
uniform float uFlipZ;

#define PI 3.1415926
#define TwoPI (2.0 * PI)

/**
 * Samples equirectangular (lat/long) panorama environment map
 * @param  {sampler2D} envMap - equirectangular (lat/long) panorama texture
 * @param  {vec3} wcNormal - normal in the world coordinate space
 * @param  {float} - flipEnvMap    -1.0 for left handed coorinate system oriented texture (usual case)
 *                                  1.0 for right handed coorinate system oriented texture
 * @return {vec4} - sampledColor
 * @description Based on http://http.developer.nvidia.com/GPUGems/gpugems_ch17.html and http://gl.ict.usc.edu/Data/HighResProbes/
 */
vec4 texture2DEnvLatLong(sampler2D envMap, vec3 wcNormal, float flipEnvMap) {
    float phi = acos(-wcNormal.y);
    float theta = atan(wcNormal.x, flipEnvMap * wcNormal.z) + PI;
    vec2 texCoord = vec2(theta / TwoPI, phi / PI);
    return texture2D(envMap, texCoord);
}

void main() {
    vec3 N = normalize(vNormal);
    float flipEnvMap = 1.0;
    if (uFlipZ != 0.0) {
        flipEnvMap = uFlipZ;
    }
    gl_FragColor = texture2DEnvLatLong(uReflectionEnvMap, N, flipEnvMap);
}<commit_msg>assets/glsl SkyboxEnvMap added comment about envmap orientation<commit_after>#ifdef GL_ES
precision highp float;
#endif

varying vec3 vNormal;

uniform sampler2D uReflectionEnvMap;
uniform float uFlipZ;

#define PI 3.1415926
#define TwoPI (2.0 * PI)

/**
 * Samples equirectangular (lat/long) panorama environment map
 * @param  {sampler2D} envMap - equirectangular (lat/long) panorama texture
 * @param  {vec3} wcNormal - normal in the world coordinate space
 * @param  {float} - flipEnvMap    -1.0 for left handed coorinate system oriented texture (usual case)
 *                                  1.0 for right handed coorinate system oriented texture
 * @return {vec4} - sampledColor
 * @description Based on http://http.developer.nvidia.com/GPUGems/gpugems_ch17.html and http://gl.ict.usc.edu/Data/HighResProbes/
 */
vec4 texture2DEnvLatLong(sampler2D envMap, vec3 wcNormal, float flipEnvMap) {
    //I assume envMap texture has been flipped the WebGL way (pixel 0,0 is a the bottom)
    //So top was at 0,0 and now is at 0,1 therefore we flip wcNorma.y as acos(1) = 0 but we want 1
    float phi = acos(-wcNormal.y);
    float theta = atan(wcNormal.x, flipEnvMap * wcNormal.z) + PI;
    vec2 texCoord = vec2(theta / TwoPI, phi / PI);
    return texture2D(envMap, texCoord);
}

void main() {
    vec3 N = normalize(vNormal);
    float flipEnvMap = 1.0;
    if (uFlipZ != 0.0) {
        flipEnvMap = uFlipZ;
    }
    gl_FragColor = texture2DEnvLatLong(uReflectionEnvMap, N, flipEnvMap);
}
{'fraction_non_alphanumeric': 0.101238164603059, 'fraction_numerical': 0.028040786598689003, 'mean_word_length': 3.4378029079159935, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2858952', 'n_tokens_mistral': 985, 'n_tokens_neox': 933, 'n_words': 275}