(Lets get screen shaders working!) If you pass Layer Master to a shader, what variable does it become in the shader?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

(Lets get screen shaders working!) If you pass Layer Master to a shader, what variable does it become in the shader?

#1 Post by henvu50 »

I want to apply a shader to the master layer; background images and characters. Basically, a simple screen shader.

Here is my code so far, but I have no idea what variable RENPY.LAYER.MASTER becomes?

Code: Select all

Image IMAGE8398 = 'some_image.png'
label test()
   show layer master:
       shader("screen_shader_01")
       Model().child(IMAGE8398)
       
init python:
    renpy.register_shader("screen_shader_01", variables="""
        uniform sampler2D tex0; # IMAGE8398
        RENPY.LAYER.MASTER
        uniform float u_lod_bias;
        attribute vec2 a_tex_coord;
        varying vec2 v_tex_coord;
    """, vertex_300="""
        v_tex_coord = a_tex_coord;
    """, fragment_300=""" 
        vec4 some_texture = texture2D(tex0, v_tex_coord.st, u_lod_bias);
        RENPY.LAYER.MASTER
        gl_FragColor = RENPY.LAYER.MASTER * some_texture 
    """)
Which of these variables represents the RENPY.LAYER.MASTER, so I can perform calculations on it, as if it's a texture or something?

Code: Select all

vec2 u_model_size
float u_lod_bias
mat4 u_transform
float u_time
vec4 u_random
vec4 u_viewport
sampler2D tex0, sampler2D tex1, sampler2D tex2
vec2 res0, vec2 res1, vec2 res2
vec4 a_position 
vec2 a_tex_coord

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], piinkpuddiin