Class: Shader
- Inherits:
- LiteRGSS::Shader show all
- Defined in:
- docs/0_Dependencies.rb,
docs/4_Systems_000_General_4_UI_Generics.rb
Overview
#version 120 will be automatically added to the begining of the file if not present
Defined Under Namespace
Modules: CreatureShaderForCreatureFaceSpriteHelper, CreatureShaderLoader
Constant Summary collapse
- SHADER_VERSION =
Shader version based on the platform
PSDK_SHADER_VERSION || ''
- COLOR_UNIFORM =
Color uniform
"\\0uniform vec4 color;\n"- COLOR_PROCESS =
Color process
"\n frag.rgb = mix(frag.rgb, color.rgb, color.a);\\0"- TONE_UNIFORM =
Tone uniform
"\\0uniform vec4 tone;\nconst vec3 lumaF = vec3(.299, .587, .114);\n"- TONE_PROCESS =
Tone process
"\n float luma = dot(frag.rgb, lumaF);\n frag.rgb = mix(frag.rgb, vec3(luma), tone.w);\n frag.rgb += tone.rgb;\\0"- ALPHA_PROCESS =
Alpha process
"\n frag.a *= gl_Color.a;\\0"- DEFAULT_SHADER_FRAG =
Default shader when there's nothing to do
"uniform sampler2D texture;\nvoid main() {\n vec4 frag = texture2D(texture, gl_TexCoord[0].xy);\n gl_FragColor = frag;\n}\n"- SHADER_CONTENT_DETECTION =
Part detecting the shader code begin
'void main()'- SHADER_VERSION_DETECTION =
Part detecting the shader version pre-processor
'#version '- SHADER_GL_COLOR_DETECTION =
Part responsive of detecting gl_Color in the shader
/\bgl_Color\b/- SHADER_GL_TEX_COORD_0_DETECTION =
Part responsive of detecting gl_TexCoord in the shader This is used to replace it with v_texture_coordinates
/\bgl_TexCoord\[0\](\b|)/- SHADER_GL_TEX_COORD_1_DETECTION =
Part responsive of detecting gl_TexCoord in the shader This is used to replace it with v_inv_texture_coordinates
/\bgl_TexCoord\[1\](\b|)/- SHADER_FRAG_FEATURE_ADD =
Part responsive of detecting where to add the processes
/\n( |)+gl_FragColor( |)+=/- SHADER_UNIFORM_ADD =
Part responsive of detecting where to add the uniforms
/\n(?=( |)+void main\(\))/- DEFAULT_PRECISION =
Default precision for OpenGL ES shaders
"\#ifdef GL_ES\nprecision mediump float;\n\#endif\n"- SHADER_FRAG_ADD_GL_ES_VARYINGS =
Addings of varyings for OpenGL ES shaders
"\#ifdef GL_ES\nvarying vec2 v_texture_coordinates;\nvarying vec2 v_inv_texture_coordinates;\nvarying vec4 sf_color;\n\#endif\n"- DEFAULT_SHADER_VERT =
Default vertex shader
"\#ifdef GL_ES\nuniform mat4 sf_texture;\nuniform vec2 factor_npot;\n\nvarying vec4 sf_color;\nvarying vec2 v_texture_coordinates;\nvarying vec2 v_inv_texture_coordinates;\n\n\#else\nconst vec2 factor_npot = vec2(1.0, 1.0);\n\#endif\nattribute vec2 position;\nattribute vec2 texCoord;\nattribute vec4 color;\n\nuniform mat4 sf_modelview;\nuniform mat4 sf_projection;\n\nvarying vec2 v_factor_npot;\n\nvoid main() {\n v_factor_npot = factor_npot;\n\#ifdef GL_ES\n sf_color = color;\n v_texture_coordinates = (sf_texture * vec4(texCoord, 0.0, 1.0)).xy;\n\#endif\n gl_Position = sf_projection * sf_modelview * vec4(position.xy, 0.0, 1.0);\n}\n"
Constants inherited from LiteRGSS::Shader
LiteRGSS::Shader::Fragment, LiteRGSS::Shader::Geometry, LiteRGSS::Shader::Vertex
Constants inherited from LiteRGSS::BlendMode
LiteRGSS::BlendMode::Add, LiteRGSS::BlendMode::DstAlpha, LiteRGSS::BlendMode::DstColor, LiteRGSS::BlendMode::One, LiteRGSS::BlendMode::OneMinusDstAlpha, LiteRGSS::BlendMode::OneMinusDstColor, LiteRGSS::BlendMode::OneMinusSrcAlpha, LiteRGSS::BlendMode::OneMinusSrcColor, LiteRGSS::BlendMode::ReverseSubtract, LiteRGSS::BlendMode::SrcAlpha, LiteRGSS::BlendMode::SrcColor, LiteRGSS::BlendMode::Subtract, LiteRGSS::BlendMode::Zero
Instance Attribute Summary
Attributes inherited from LiteRGSS::BlendMode
#alpha_dest_factor, #alpha_equation, #alpha_src_factor, #blend_type, #color_dest_factor, #color_equation, #color_src_factor
Class Method Summary collapse
-
.create(name_sym) ⇒ Shader
Function that creates a shader by its name.
-
.load_shader_params(name_sym) ⇒ Array<String>
Function that loads the shader params by its name.
-
.load_shader_params_from_pre_registered_shader(name_sym) ⇒ Array<String>
Function that loads the shader params by its name from pre-registered shaders.
-
.load_to_string(filename) ⇒ String
Load a shader data from a file.
-
.register(name_sym, frag_file, vert_file = nil, tone_process: false, color_process: false, alpha_process: false)
Register a new shader by it's name.
Methods inherited from LiteRGSS::Shader
#initialize, #load, #set_bool_uniform, #set_float_array_uniform, #set_float_uniform, #set_int_uniform, #set_matrix_uniform, #set_texture_factor_uniforms, #set_texture_uniform
Constructor Details
This class inherits a constructor from LiteRGSS::Shader
Class Method Details
.create(name_sym) ⇒ Shader
Function that creates a shader by its name
1863 1864 |
# File 'docs/0_Dependencies.rb', line 1863 def create(name_sym) end |
.load_shader_params(name_sym) ⇒ Array<String>
Function that loads the shader params by its name
1868 1869 |
# File 'docs/0_Dependencies.rb', line 1868 def load_shader_params(name_sym) end |
.load_shader_params_from_pre_registered_shader(name_sym) ⇒ Array<String>
Function that loads the shader params by its name from pre-registered shaders
1873 1874 |
# File 'docs/0_Dependencies.rb', line 1873 def load_shader_params_from_pre_registered_shader(name_sym) end |
.load_to_string(filename) ⇒ String
Load a shader data from a file
1878 1879 |
# File 'docs/0_Dependencies.rb', line 1878 def load_to_string(filename) end |
.register(name_sym, frag_file, vert_file = nil, tone_process: false, color_process: false, alpha_process: false)
Register a new shader by it's name
1858 1859 |
# File 'docs/0_Dependencies.rb', line 1858 def register(name_sym, frag_file, vert_file = nil, tone_process: false, color_process: false, alpha_process: false) end |