<commit_before>/* Copyright 2015 Samsung Electronics Co., LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gearvrf;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.lang.reflect.Method;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;

import android.os.Environment;

/**
 * Generates a vertex and fragment shader from the sources provided.
 * <p>
 * This class allows you to define your own custom shader and introduce
 * it into GearVRF.
 * Each shader generated has a unique signature so that the same shader
 * will not be generated twice. For shaders derived directly from
 * GVRShader, the signature is the simple Java class name.
 * <p>
 * The shader also defines descriptors that define the
 * names and types of all the uniforms, textures and vertex attributes
 * used by the shader. For uniforms and attributes, each entry is a
 * float or integer type, an optional count and the name of the
 * uniform (e.g. "float3 diffuse_color, float specular_exponent, int is_enabled".
 * For textures, the descriptor contains the sampler type followed by the name:
 * (e.g. "sampler2D u_texture; samplerCube u_cubemap")
 * <p>
 * Shaders derived from GVRShader cannot have variants and they ignore
 * light sources in the scene. To generate a more complex shader which
 * has multiple variants depending on what meshes, materials and
 * light sources it is used with, you can derive from @{link GVRShaderTemplate}
 *
 * @see GVRShaderTemplate
 */
public class GVRShader
{
    protected boolean mWriteShadersToDisk = true;
    protected GLSLESVersion mGLSLVersion = GLSLESVersion.V100;
    protected boolean mHasVariants = false;
    protected boolean mUsesLights = false;
    protected boolean mUseTransformBuffer = false;  // true to use Transform UBO in GL
    protected String mUniformDescriptor;
    protected String mVertexDescriptor;
    protected String mTextureDescriptor;
    protected Map<String, String> mShaderSegments;
    protected static String sBonesDescriptor = "mat4 u_bone_matrix[" + GVRMesh.MAX_BONES + "]";

    protected static String sTransformUBOCode = "layout (std140) uniform Transform_ubo\n{\n"
            + " #ifdef HAS_MULTIVIEW\n"
            + "     mat4 u_view_[2];\n"
            + "     mat4 u_mvp_[2];\n"<commit_msg>Disable writing shaders to the sdcard<commit_after>/* Copyright 2015 Samsung Electronics Co., LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gearvrf;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.lang.reflect.Method;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;

import android.os.Environment;

/**
 * Generates a vertex and fragment shader from the sources provided.
 * <p>
 * This class allows you to define your own custom shader and introduce
 * it into GearVRF.
 * Each shader generated has a unique signature so that the same shader
 * will not be generated twice. For shaders derived directly from
 * GVRShader, the signature is the simple Java class name.
 * <p>
 * The shader also defines descriptors that define the
 * names and types of all the uniforms, textures and vertex attributes
 * used by the shader. For uniforms and attributes, each entry is a
 * float or integer type, an optional count and the name of the
 * uniform (e.g. "float3 diffuse_color, float specular_exponent, int is_enabled".
 * For textures, the descriptor contains the sampler type followed by the name:
 * (e.g. "sampler2D u_texture; samplerCube u_cubemap")
 * <p>
 * Shaders derived from GVRShader cannot have variants and they ignore
 * light sources in the scene. To generate a more complex shader which
 * has multiple variants depending on what meshes, materials and
 * light sources it is used with, you can derive from @{link GVRShaderTemplate}
 *
 * @see GVRShaderTemplate
 */
public class GVRShader
{
    protected boolean mWriteShadersToDisk = false;
    protected GLSLESVersion mGLSLVersion = GLSLESVersion.V100;
    protected boolean mHasVariants = false;
    protected boolean mUsesLights = false;
    protected boolean mUseTransformBuffer = false;  // true to use Transform UBO in GL
    protected String mUniformDescriptor;
    protected String mVertexDescriptor;
    protected String mTextureDescriptor;
    protected Map<String, String> mShaderSegments;
    protected static String sBonesDescriptor = "mat4 u_bone_matrix[" + GVRMesh.MAX_BONES + "]";

    protected static String sTransformUBOCode = "layout (std140) uniform Transform_ubo\n{\n"
            + " #ifdef HAS_MULTIVIEW\n"
            + "     mat4 u_view_[2];\n"
            + "     mat4 u_mvp_[2];\n"
{'fraction_non_alphanumeric': 0.06907269901571404, 'fraction_numerical': 0.007252633396649974, 'mean_word_length': 3.925170068027211, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3435768', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1543, 'n_words': 688}