@@ -201,12 +201,12 @@ vec4 col_scene(vec4 p) {
201
201
202
202
// A faster formula to find the gradient/normal direction of the DE(the w component is the average DE)
203
203
// credit to http://www.iquilezles.org/www/articles/normalsSDF/normalsSDF.htm
204
- vec3 calcGrad (vec4 p, float dx) {
204
+ vec3 calcNormal (vec4 p, float dx) {
205
205
const vec3 k = vec3 (1 ,- 1 ,0 );
206
- return (k.xyy* DE(p + k.xyyz* dx) +
207
- k.yyx* DE(p + k.yyxz* dx) +
208
- k.yxy* DE(p + k.yxyz* dx) +
209
- k.xxx* DE(p + k.xxxz* dx)) / vec3 ( 4 * dx, 4 * dx, 4 * dx );
206
+ return normalize (k.xyy* DE(p + k.xyyz* dx) +
207
+ k.yyx* DE(p + k.yyxz* dx) +
208
+ k.yxy* DE(p + k.yxyz* dx) +
209
+ k.xxx* DE(p + k.xxxz* dx));
210
210
}
211
211
212
212
// find the average color of the fractal in a radius dx in plane s1-s2
@@ -261,7 +261,7 @@ vec4 scene(inout vec4 p, inout vec4 ray, float vignette) {
261
261
float min_dist = max (FOVperPixel* td, MIN_DIST);
262
262
if (d < min_dist) {
263
263
// Get the surface normal
264
- vec3 n = normalize (calcGrad(p, min_dist* 0.5 ) );
264
+ vec3 n = calcNormal(p, min_dist* 0.5 );
265
265
266
266
// find closest surface point, without this we get weird coloring artifacts
267
267
p.xyz -= n* d;
0 commit comments