Created
August 27, 2017 06:23
-
-
Save RameshRavone/481e16c8b2afaf0a650f5fd4bb25821f to your computer and use it in GitHub Desktop.
simple light shader for godot 3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shader_type canvas_item; | |
void fragment () { | |
vec2 resolution = vec2(1024, 600); | |
vec2 texcoord = FRAGCOORD.xy / resolution; | |
vec3 colours = vec3(0,0,1); | |
float backgroundlight = 0.35; | |
vec3 lightcolor = vec3(1,0,0); | |
float brightness; | |
float intensity = abs(cos(TIME)); | |
float size = 150.0; | |
vec2 ligthpos = resolution / 2.0; | |
float dist = distance(FRAGCOORD.xy, ligthpos); | |
float distFromEdge = size - dist; | |
brightness = 1.0 / (dist * ((1.0 / intensity) / size)); | |
brightness -= brightness * (size / dist); | |
if (distFromEdge <= 0.0) { | |
brightness = 0.0; | |
} | |
lightcolor.xyz *= abs(brightness); | |
colours.xyz *= abs(brightness) + backgroundlight; | |
colours.xyz += lightcolor.xyz; | |
COLOR = vec4(colours.xyz, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment