整理代码

This commit is contained in:
MrZ626
2020-12-01 10:51:06 +08:00
parent f02c0b7d8b
commit 30f4f7ba57
3 changed files with 21 additions and 23 deletions

View File

@@ -1,9 +1,9 @@
#define PI 3.14
extern float yresolution;
vec4 effect(vec4 color,Image texture,vec2 texture_coords,vec2 screen_coords){
//Iterate through the occluder map's y-axis.
// Iterate through the occluder map's y-axis.
for(float y=0.;y<yresolution;y++){
//cartesian to polar
// Cartesian to polar
// y/yresolution=distance to light source(0~1)
vec2 norm=vec2(texture_coords.s,y/yresolution)*2.-1.;
float theta=PI*1.5+norm.x*PI;
@@ -12,10 +12,9 @@ vec4 effect(vec4 color,Image texture,vec2 texture_coords,vec2 screen_coords){
//sample from solid
if(
Texel(texture,(
vec2(-r*sin(theta),-r*cos(theta))*0.5+0.5//coord of solid sampling
))
.a>0.1
)return vec4(vec3(y/yresolution),1.);//collision check, alpha>0.1 means transparent
vec2(-r*sin(theta),-r*cos(theta))*0.5+0.5// Coord of solid sampling
)).a>0.1
)return vec4(vec3(y/yresolution),1.);// Collision check, alpha>0.1 means transparent
}
return vec4(1.,1.,1.,1.);//return max distance 1
return vec4(1.);// Return max distance 1
}