Parallax
The parallax effect used the following transform:
Code: Select all
transform parallax:
perspective True
subpixel True
function moving_camera
Code: Select all
camera at parallax
Perspective True turns on Ren'Py's 3D Stage, which means I can specify how close to the "camera" the background and sprite are relative to each other. Subpixel True makes the master layer drawn with subpixel accuracy, so small nudges of the cursor don't make the images jump pixel by pixel. Then there's the last line, the moving_camera function, which is what actually, well, moves the camera.
Code: Select all
def moving_camera(trans, st, at):
if persistent.parallax:
x, y = renpy.display.draw.get_mouse_pos()
trans.xoffset = (x - config.screen_width / 2) * .05
trans.yoffset = (y - config.screen_height / 2) * .05
else:
trans.xoffset = 0
trans.yoffset = 0
return 0
The last ingredient was taking advantage of that 3D Stage feature to set the background at a different distance from the camera. I took a 1975x1111 background and displayed it at the transform:
Code: Select all
transform bg:
truecenter()
zzoom true
zpos -1000
Blur
There were actually two blurs I used. One was the Ren'Py blur which can be used in transforms to give a kind of motion blur effect. I used this to blur Brooke's sprite when it first appeared, like so:
Code: Select all
show brooke at default:
linear .25 blur 5
linear .25 blur 0
Code: Select all
renpy.register_shader('drunk', variables="""
uniform sampler2D tex0;
uniform vec2 u_model_size;
varying vec2 v_uv;
uniform float u_blur_radius;
uniform float u_dark_radius;
""", vertex_300="""
v_uv = a_position.xy / u_model_size;
""", fragment_300="""
vec4 col = texture2D(tex0, v_uv);
col += texture2D(tex0, v_uv + vec2(.0, -u_blur_radius) / u_model_size);
col += texture2D(tex0, v_uv + vec2(.0, u_blur_radius) / u_model_size);
col += texture2D(tex0, v_uv + vec2(-u_blur_radius, .0) / u_model_size);
col += texture2D(tex0, v_uv + vec2(u_blur_radius, .0) / u_model_size);
col /= 5.0;
gl_FragColor = vec4(mix(col.rgb, vec3(0,0,0), max(distance(v_uv, vec2(.5,.5)) / sqrt(.5) - u_dark_radius, .0)), col.a);
""")
Code: Select all
transform drunk:
parallel:
parallax()
parallel:
shader 'drunk'
u_blur_radius .0 u_dark_radius 1.0
easein .5 u_blur_radius persistent.blur u_dark_radius .5
.1
easeout .5 u_blur_radius .0 u_dark_radius 1.0
Hope this explanation helps y'all make some cool VNs!