POV-Ray : Newsgroups : povray.binaries.scene-files : Simple Slideshow : Re: Simple Slideshow Server Time
25 Apr 2024 15:32:27 EDT (-0400)
  Re: Simple Slideshow  
From: Dave Blandston
Date: 27 Nov 2018 17:05:01
Message: <web.5bfdbede1e20253b79416a1f0@news.povray.org>
Well, the fading could have been done in a better way. I doubt anyone will ever
use this but just in case here's a better version:

-------------------

//-f

#version 3.7;

global_settings {assumed_gamma 2.2}

#include "colors.inc"

#local CameraZ = 1;

camera {
   location <0, 0, -CameraZ>
   right (16/9) * x //Use 16:9 aspect ratio
   direction <0, 0, 1>
   look_at <0, 0, 0>
} //camera

background {DarkOliveGreen}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* *
                                    * */
/* *
                                    * */
/* * SLIDESHOW SETTINGS
                                    * */
/* *
                                    * */
/* *
                                    * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */

#local NSlides = 3;
//Number of slides (should all be the same dimensions, named "Slide_00.png"
"Slide_01.png" etc.

#local NSeconds = 5;
//Total time in seconds the slideshow will last. Render NSeconds * (number of
frames per second) frames.

#local SlideFadeRate = .5;
//Amount of time in seconds for a new slide to fade in or out.
//Note that each slide transition will take 2 * SladeFadeRate seconds (one slide
will fade out, then the
//next slide will fade in.)

#local FadeColor = Red * .45;
//Color to fade to and from.

#local SinusoidalTransition = yes;
//Set to "yes" for a sinusoidal transition rate, "no" for a linear transition
rate.

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* *
                                    * */
/* *
                                    * */
/* * SLIDE SHOW
                                    * */
/* *
                                    * */
/* *
                                    * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * */

#local CurrentClock = clock * NSeconds;

#local TransitionTime_Total = SlideFadeRate * 2 * (NSlides - 1);
#local NonTransitionTime_Total = NSeconds - TransitionTime_Total;

#if (TransitionTime_Total > NSeconds)
   #error "Transition time exceeds total slideshow time. Increase the length of
the slideshow (NSeconds) or decrease the transition time (SlideFadeRate.)"
#end //#if

#local TransitionTime_FadeIn = array [NSlides]
#local TransitionTime_None = array [NSlides]
#local TransitionTime_FadeOut = array [NSlides]

#for (I, 0, NSlides - 1)
   #local TransitionTime_None [I] = I * NonTransitionTime_Total / NSlides + I *
SlideFadeRate * 2;
#end //#for

#for (I, 0, NSlides - 1)
   #local TransitionTime_FadeOut [I] = TransitionTime_None [I] +
NonTransitionTime_Total / NSlides;
#end //#for

#for (I, 0, NSlides - 1)
   #local TransitionTime_FadeIn [I] = TransitionTime_None [I] - SlideFadeRate;
#end //#for

#for (I, 0, NSlides - 1)
   #if (CurrentClock >= TransitionTime_FadeIn [I])
      #local CurrentSlideNumber = I;
      #local FadeRatio = (CurrentClock - TransitionTime_FadeIn [I]) /
SlideFadeRate;
   #end //#if
   #if (CurrentClock >= TransitionTime_None [I])
      #local FadeRatio = 1;
   #end //#if
   #if (CurrentClock >= TransitionTime_FadeOut [I])
      #local FadeRatio = (TransitionTime_FadeOut [I] + SlideFadeRate -
CurrentClock) / SlideFadeRate;
   #end //#if
#end //#for

#local SlideFileName = concat ("Slide_", str (CurrentSlideNumber, -2, 0),
".png")
#local SlideImagePigment = pigment {image_map {png SlideFileName gamma 2.2
map_type 0 interpolate 2 once}}
#local SlideColor = texture {SlideImagePigment finish {emission 1}}
#local SlideImageResolution = max_extent (SlideImagePigment);
#local SlideScale = CameraZ / max (SlideImageResolution.x,
SlideImageResolution.y);

#if (SinusoidalTransition)
   #local Angle = FadeRatio * 180 + 180;
   #local FadeRatio = (cos (radians (Angle)) + 1) / 2;
#end //#if

#local TransitionColor = texture {pigment {color FadeColor} finish {emission 1}}

#local XColor = texture {
   average
   texture_map {
      [FadeRatio SlideColor]
      [1 - FadeRatio TransitionColor]
   } //texture_map
} //texture

#local Slide = object {
   #local W = SlideImageResolution.x;
   #local H = SlideImageResolution.y;
   plane {
      z, 0
      clipped_by {box {<0, 0, -.1> <1, 1, .1>}}
      texture {XColor}
   } //plane
   scale <W, H, 1>
   translate <-W / 2, -H / 2, 0>
   scale <SlideScale, SlideScale, 1>
} //object

object {Slide}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.