I try to write a shader to make a border for rectangle,but something wrong。

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Li yuanlin
Regular
Posts: 88
Joined: Sat Aug 04, 2018 8:42 pm
Location: Hong Kong
Contact:

I try to write a shader to make a border for rectangle,but something wrong。

#1 Post by Li yuanlin »

Code: Select all

init python:#####rectangle borders
    renpy.register_shader("myshader.rectborders", variables="""
        uniform float u_border_width;
        uniform float u_aspect;
        varying vec2 v_tex_coord;
        attribute vec2 a_tex_coord;
        uniform vec4 u_renpy_solid_color_rect;
        uniform vec4 u_renpy_solid_color_border;
    """,vertex_300="""
        v_tex_coord = a_tex_coord;
    """,fragment_300="""

        if (v_tex_coord.x < 1.0 - u_border_width && v_tex_coord.x > u_border_width &&
        v_tex_coord.y < 1.0 - u_border_width / u_aspect && v_tex_coord.y > u_border_width/ u_aspect) {
            gl_FragColor =  u_renpy_solid_color_rect;
        }
        else {
            gl_FragColor = u_renpy_solid_color_border;
        }
    """)
Can someone pick up the error?
Last edited by Li yuanlin on Mon May 30, 2022 3:38 am, edited 1 time in total.
stay hungry,stay foolish.

User avatar
m_from_space
Miko-Class Veteran
Posts: 956
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: I try to write a shader to make a border for rectangle,but something wrong。

#2 Post by m_from_space »

The first error is that you don't wrap your code around the code tag when posting here. o_o (It's just really annoying to read that way.)

User avatar
Li yuanlin
Regular
Posts: 88
Joined: Sat Aug 04, 2018 8:42 pm
Location: Hong Kong
Contact:

Re: I try to write a shader to make a border for rectangle,but something wrong。

#3 Post by Li yuanlin »

Can someone help me?
stay hungry,stay foolish.

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: I try to write a shader to make a border for rectangle,but something wrong。

#4 Post by zmook »

Li yuanlin wrote: Thu Jun 02, 2022 7:27 am Can someone help me?
We'll try, but my impression is that it is pretty rare to actually use shaders in a Renpy project, so most of us have very little experience with them.

First, please describe your error. Copy your error messages. Say what you expected it to do. We don't have much to go on if you only say "something went wrong."
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

Post Reply

Who is online

Users browsing this forum: Bing [Bot]