forked from SilverStudioGames/WTS
Colour Temperature Shader
This commit is contained in:
parent
82c54c0b57
commit
76048a5278
@ -15,3 +15,30 @@ init python:
|
||||
gl_FragColor = col;
|
||||
}
|
||||
""")
|
||||
|
||||
renpy.register_shader("color_temperature_shader", variables="""
|
||||
uniform float u_factor;
|
||||
uniform float u_strength;
|
||||
""", fragment_functions="""
|
||||
vec3 CBT(float ctemp) {
|
||||
mat3 m = (ctemp <= 6500.0) ? mat3(vec3(0.0, -2902.1955373783176, -8257.7997278925690),
|
||||
vec3(0.0, 1669.5803561666639, 2575.2827530017594),
|
||||
vec3(1.0, 1.3302673723350029, 1.8993753891711275)) :
|
||||
mat3(vec3(1745.0425298314172, 1216.6168361476490, -8257.7997278925690),
|
||||
vec3(-2666.3474220535695, -2173.1012343082230, 2575.2827530017594),
|
||||
vec3(0.55995389139931482, 0.70381203140554553, 1.8993753891711275));
|
||||
return mix(clamp(vec3(m[0] / (vec3(clamp(ctemp, 1000.0, 40000.0)) + m[1]) + m[2]), vec3(0.0), vec3(1.0)), vec3(1.0), smoothstep(1000.0, 0.0, ctemp));
|
||||
}
|
||||
""", fragment_300="""
|
||||
const float PI2 = 6.2831853071;
|
||||
|
||||
float ctemp = mix(1000.0, 40000.0, u_factor);
|
||||
gl_FragColor = vec4(mix(gl_FragColor.xyz, gl_FragColor.xyz * CBT(ctemp), u_strength), 1.0);
|
||||
""")
|
||||
|
||||
transform color_temperature(factor=1.0, strength=1.0):
|
||||
mesh True
|
||||
shader "color_temperature_shader"
|
||||
|
||||
u_factor factor
|
||||
u_strength strength
|
||||
|
Loading…
Reference in New Issue
Block a user