Class: Shader

Inherits:
LiteRGSS::Shader show all
Defined in:
docs/00000_Dependencies.rb

Overview

Note:

‘#version 120` will be automatically added to the begining of the file if not present

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:



962
963
# File 'docs/00000_Dependencies.rb', line 962

def create(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



967
968
# File 'docs/00000_Dependencies.rb', line 967

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



957
958
# File 'docs/00000_Dependencies.rb', line 957

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