Class: Shader

Inherits:
LiteRGSS::Shader show all
Defined in:
docs/0_Dependencies.rb,
docs/4_Systems_000_General_4_UI_Generics.rb

Overview

Note:

‘#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_PLATFORM == :macos ? "#version 120\n" : "#version 130\n"
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 =

Default shader when there’s nothing to do

"#{SHADER_VERSION}\nuniform 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_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

/\#version[^\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

Methods inherited from LiteRGSS::Shader

#load, new, #set_bool_uniform, #set_float_array_uniform, #set_float_uniform, #set_int_uniform, #set_matrix_uniform, #set_texture_uniform

Class Method Details

.create(name_sym) ⇒ Shader

Function that creates a shader by its name

Parameters:

  • name_sym (Symbol)

    name of the shader

Returns:



1694
1695
# File 'docs/0_Dependencies.rb', line 1694

def create(name_sym)
end

.load_shader_params(name_sym) ⇒ Array<String>

Function that loads the shader params by its name

Parameters:

  • name_sym (Symbol)

    name of the shader

Returns:



1699
1700
# File 'docs/0_Dependencies.rb', line 1699

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

Parameters:

  • name_sym (Symbol)

    name of the shader

Returns:



1704
1705
# File 'docs/0_Dependencies.rb', line 1704

def load_shader_params_from_pre_registered_shader(name_sym)
end

.load_to_string(filename) ⇒ String

Load a shader data from a file

Parameters:

  • filename (String)

    name of the file in Graphics/Shaders

Returns:

  • (String)

    the shader string



1709
1710
# File 'docs/0_Dependencies.rb', line 1709

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

Parameters:

  • name_sym (Symbol)

    name of the shader

  • frag_file (String)

    file content or filename of the frag shader, the function will look at void main() to know

  • vert_file (String) (defaults to: nil)

    file content or filename of the vertex shader, the function will look at void main() to know

  • tone_process (Boolean) (defaults to: false)

    if the function should add tone_process to the shader

  • color_process (Boolean) (defaults to: false)

    if the function should add color_process to the shader

  • alpha_process (Boolean) (defaults to: false)

    if the function should add alpha_process to the shader



1689
1690
# File 'docs/0_Dependencies.rb', line 1689

def register(name_sym, frag_file, vert_file = nil, tone_process: false, color_process: false, alpha_process: false)
end