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
use std::env; | |
use std::str; | |
use std::fs; | |
use std::fs::File; | |
use std::io::{ self, BufRead, BufReader }; | |
use std::io::Seek; | |
use std::io::Read; | |
use std::io::Write; | |
use std::path::Path; | |
use std::io::SeekFrom; |
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
// uv is input texture coord, srcRes is original texture resolution, returns filtered texture coords | |
vec2 filterCoord(vec2 uv, vec2 srcRes) { | |
vec2 invSrc = 1.0 / srcRes; | |
// calculate destination resolution | |
vec2 duv1 = vec2(dFdx(uv.x), dFdy(uv.y)); | |
vec2 duv2 = vec2(dFdy(uv.x), dFdx(uv.y)); | |
vec2 duv = max(abs(duv1), abs(duv2)); // pick the larger derivatives (accounting for sideways sampling) |