Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
[2016.10] Sprite:setBlendMode(src, dst) - Page 2 — Gideros Forum

[2016.10] Sprite:setBlendMode(src, dst)



  • hgy29 said:

    but you can override the shader to use with a custom one on a sprite by sprite basis.

    I dont get it :D

    The only thing I can think is this:

    local fragmentShaderText = 
    uniform lowp vec4 fColor;
    uniform lowp sampler2D fTexture;
    varying mediump vec2 fTexCoord;
    void main(){
    	vec4 col = texture2D(fTexture, fTexCoord);
    	vec3 gammCorrection = pow(col.rgb, vec3(1.0/2.2));	
    	gl_FragColor = vec4(gammCorrection, col.a);
    local vertexShaderText = [[
    attribute highp vec3 vVertex;
    attribute mediump vec2 vTexCoord;
    uniform highp mat4 vMatrix;
    varying mediump vec2 fTexCoord;
    void main() {
    	vec4 vertex = vec4(vVertex,1.0);
    	gl_Position = vMatrix*vertex;
    local shader=Shader.new(vertexShaderText,fragmentShaderText,Shader.FLAG_FROM_CODE,
    function Sprite:postInit()

    Likes: hgy29

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    edited March 2020
    @rraptor, sure you can do that :)

    But that shader won't work for non textured shapes, particles, Path2D, etc...

    There are 11 shaders types used in Gideros:
    - Basic (Solid color, no texture, no per vertex color)
    - Color (Per vertex color)
    - Texture (Texture + color multiplier)
    - TextureAlpha (colored grey-scale/alpha texture, for fonts)
    - TextureColor (Texture + per vertex color)
    - TextureAlphaColor (Alpha Texture + per vertex color)
    - Particle (For liquidfun particles rendering)
    - Particles (For Gideros Particle sprite)
    - 3 shaders for Paths2D to render curves and outlines

  • well, i mostly composite meshes with a colored background, i guess as mesh inherits from sprite, i can change the shader of my meshes. am i right?
    also i don't know how i could change the background to linear color space, as that's not an element of the sprite hierarchy.
    (worst case i can make a mesh/pixel that has the background color but then i need to resize is any time the window is resized, also when i have an additional second screen then i need to resize it for that too, so it's a bit inconvenient).

    thanks for the tips so far.
Sign In or Register to comment.