// 影作成シェーダ // ver 1.2 2020/09/06 // by yarunashi@dooon // xs_begin // author : 'yarunashi@dooon' // arg : { id = '0' name = 'pitch' value = '50' range = '-90 90' step = '1' decimal = '0' } // arg : { id = '1' name = 'yaw' value = '50' range = '0 360' step = '1' decimal = '0' } // arg : { id = '2' name = 'onlyshadow' value = '0' range = '0 1' step = '1' decimal = '0' } // xs_end float pitch = radians(i_args[0]); float yaw = radians(i_args[1]); float onlyshadow = i_args[2]; float map(vec3 v){ if (onlyshadow == 0.0 && voxel(v) > 0.0) return voxel(v); if (v.z >= 1.0) return 0.0; float z = sin(pitch); float tmp = cos(pitch); float y = tmp * -cos(yaw); float x = tmp * sin(yaw); vec3 dt = normalize(vec3(x, y, z)); vec3 lay = vec3(v.x, v.y, 0.0); while(true) { if (voxel(lay) > 0.0f) return i_color_index; lay = lay + dt; if (lay.z < 0.0f || lay.z > i_volume_size.z) break; if (lay.y < 0.0f || lay.y > i_volume_size.y) break; if (lay.x < 0.0f || lay.x > i_volume_size.x) break; } return 0.0; }