From 263016f6f3543f94dc8aabfd68afb71d2bce5f4e Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 25 May 2012 15:01:33 -0400 Subject: [PATCH] Fix types in the images collection to work with TR's handling of NaN. --- collects/images/private/deep-flomap-render.rkt | 10 +++++----- collects/images/private/flomap-resize.rkt | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/collects/images/private/deep-flomap-render.rkt b/collects/images/private/deep-flomap-render.rkt index c48e5f6a8b..a4f3c7132b 100644 --- a/collects/images/private/deep-flomap-render.rkt +++ b/collects/images/private/deep-flomap-render.rkt @@ -482,23 +482,23 @@ (trace-directional-light alpha-fm rgb-fm z-fm normal-fm x-min x-max y-min y-max)) ;; two Gaussian blurs by half of σ^2 is equivalent to one Gaussian blur by σ^2 - (define σ^2 (sqr (* (min w h) (shadow-blur)))) + (define σ^2 (exact->inexact (sqr (* (min w h) (shadow-blur))))) ;; blur the shadow to simulate internal scatter (define shadow-fm (cond [bg-fm - (let* ([fm (flomap-blur raw-shadow-fm (sqrt (* 1/3 σ^2)))] + (let* ([fm (flomap-blur raw-shadow-fm (flsqrt (* 1/3 σ^2)))] [fm (fm* fm bg-fm)] - [fm (flomap-blur fm (sqrt (* 1/3 σ^2)))]) + [fm (flomap-blur fm (flsqrt (* 1/3 σ^2)))]) fm)] [else - (flomap-blur raw-shadow-fm (sqrt (* 2/3 σ^2)))])) + (flomap-blur raw-shadow-fm (flsqrt (* 2/3 σ^2)))])) ;; pass 2: trace from the viewer (define-values (reflected-fm raw-transmitted-fm) (trace-directional-view alpha-fm rgb-fm z-fm normal-fm shadow-fm x-min x-max y-min y-max)) ;; simulate scatter some more - (define transmitted-fm (flomap-blur raw-transmitted-fm (sqrt (* 1/3 σ^2)))) + (define transmitted-fm (flomap-blur raw-transmitted-fm (flsqrt (* 1/3 σ^2)))) ;; add all the light together, convert to premultiplied-alpha flomap (let* ([fm (fm+ (fm+ diffracted-fm transmitted-fm) reflected-fm)] [fm (flomap-append-components alpha-fm fm)] diff --git a/collects/images/private/flomap-resize.rkt b/collects/images/private/flomap-resize.rkt index 1779c9cadb..a664fed5c4 100644 --- a/collects/images/private/flomap-resize.rkt +++ b/collects/images/private/flomap-resize.rkt @@ -160,13 +160,13 @@ ;; calculates the standard deviation of downscaling blur, assuming linear interpolation will be ;; carried out on the blurred image -(: stddev-for-scale (Nonnegative-Flonum -> Nonnegative-Flonum)) +(: stddev-for-scale (Flonum -> Flonum)) (define (stddev-for-scale scale) (define var (- (/ box-filter-variance (sqr scale)) triangle-filter-variance)) (abs (flsqrt (max 0.0 var)))) -(: flomap-scale*-x (flomap Nonnegative-Flonum Exact-Nonnegative-Integer -> flomap)) +(: flomap-scale*-x (flomap Flonum Exact-Nonnegative-Integer -> flomap)) (define (flomap-scale*-x fm scale width) (cond [(scale . = . 1.0) fm] [(scale . > . 1.0) (flomap-scale*-x/linear fm scale width)] @@ -174,7 +174,7 @@ (flomap-gaussian-blur-x fm (stddev-for-scale scale))) (flomap-scale*-x/linear low-res-fm scale width)])) -(: flomap-scale*-y (flomap Nonnegative-Flonum Exact-Nonnegative-Integer -> flomap)) +(: flomap-scale*-y (flomap Flonum Exact-Nonnegative-Integer -> flomap)) (define (flomap-scale*-y fm scale height) (cond [(scale . = . 1.0) fm] [(scale . > . 1.0) (flomap-scale*-y/linear fm scale height)] @@ -182,7 +182,7 @@ (flomap-gaussian-blur-y fm (stddev-for-scale scale))) (flomap-scale*-y/linear low-res-fm scale height)])) -(: flomap-scale*-x/linear (flomap Nonnegative-Flonum Exact-Nonnegative-Integer -> flomap)) +(: flomap-scale*-x/linear (flomap Flonum Exact-Nonnegative-Integer -> flomap)) (define (flomap-scale*-x/linear fm s new-w) (match-define (flomap vs c w h) fm) (define w-1 (fx- w 1)) @@ -200,7 +200,7 @@ [else (flvector-ref vs (unsafe-fx+ i0 c))])) (fl-convex-combination v0 v1 (- scaled-x floor-scaled-x))])))) -(: flomap-scale*-y/linear (flomap Nonnegative-Flonum Exact-Nonnegative-Integer -> flomap)) +(: flomap-scale*-y/linear (flomap Flonum Exact-Nonnegative-Integer -> flomap)) (define (flomap-scale*-y/linear fm s new-h) (match-define (flomap vs c w h) fm) (define h-1 (fx- h 1))