Fuzzy text shader! (Renpy)


Maybe I should be writing something related to the release of the game but anyways

With renpy 8.3 (or so) we got text shaders!!

I'm far from being an expert on shaders but I find this very cool, because I really like to use text effects and I had some interesting effects playing with shaders for the images already.

noise shader + offset

So, the code (I leaved it in it's own .rpy file but I think you can leave it in the script before the start label, also pretty sure that I can clean it up more but... it works!):

init python:
    renpy.register_textshader("noise", variables="""
        varying vec2 v_tex_coord;
        uniform float u_noise;
        uniform sampler2D tex0;
        uniform vec4 u_random;
    """, vertex_300="""
    """, fragment_300="""
        float noisefrag = fract(sin(dot(v_tex_coord + u_random.r, vec2(452, u_random.r))) * 7726);
        vec4 chaos = texture2D(tex0, v_tex_coord + noisefrag * 1);
        chaos = texture2D(tex0, v_tex_coord + noisefrag * u_noise);
        gl_FragColor = chaos;
    """,
        u_noise=0.005)

Now, how to use it? you can use it as a tag or while defining a character, you can learn more about them in the renpy documentation But in simple terms, as a tag:

"{shader=noise}text default configuration{/shader} normal text"
"{shader=noise:0.001}text with less intensity of the effect{/shader} normal text"
"{shader=noise:0.1}text with more intensity of the effect{/shader} normal text"

(Note that how intense it comes across my vary by the font used!)

Now, when defining a character, so it always has the effect:

define c = Character("character", what_textshader="noise")
define c2 = Character("character with more noise", what_textshader="noise:1")

Get Melancholic Star

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.