#!/bin/csh

#######################################################################################################################################
#                                                                                                                                     #
#         M I S E   E N   M O N T A G N E   T E X T U R E E   E T   V U E   D E   C O T E                                             #
#         A V E C   E F F E T   D E   P R O F O N D E U R   D E   C H A M P                                                           #
#         D ' U N E   I M A G E   E N   V R A I E S   C O U L E U R S   P A R F A I T E S  :                                          #
#                                                                                                                                     #
#                                                                                                                                     #
#         Utilisation :                                                                                                               #
#                                                                                                                                     #
#                   $xci/montagne.71$Z  <surface> <Texture> <paletteT> <depth-cueing> <plan-net> <imageR> [<divers-derniere-minute>]  #
#                                                                                                                                     #
#                                                                         E  [0,1]  E {01, 02,...}                    |               #
#                                                                                                                     |               #
#                                                                            |             |                         \|/              #
#                                                                           \|/            |                          .               #
#                                                                            .             |               on pourra placer ici les   #
#                                                                                          |                parametres de derniere    #
#                                                                   (0. = effet maximum)   |               minute, et par exemple :   #
#                                                                      (1.0 = absent)      |                                          #
#                                                                                          |                "Ty=... sx=... sy=..."    #
#                                                                                         \|/                                         #
#                                                                                          .                                          #
#                                                                                                                                     #
#                                                                                 definit la palette                                  #
#                                                                            de type  '$xiP/depthfiel.??'                             #
#                                                                                     a  utiliser                                     #
#                                                                               pour passer du Z-Buffer                               #
#                                                                               au noyau de convolution                               #
#                                                                                                                                     #
#                                                                                                                                     #
#         Author of '$xci/montagne.71$Z' :                                                                                            #
#                                                                                                                                     #
#                     Jean-Francois Colonna (LACTAMME, AAAAMMJJhhmmss).                                                               #
#                                                                                                                                     #
#######################################################################################################################################

set  surface=$1
set  Texture=$2
set  paletteT=$3
set  depth_cueing=$4
set  plan_net=$5
set  imageR=$6
set  divers="$7"
                                        # ATTENTION : voir le commentaire relatif a '$lumiere'...                                     #

set  translation="Ty=0.50"
                                        # Pour translater verticalement l'image.                                                      #

set  lumiere="sx=8.0 sy=8.0"
                                        # Positionnement de la source lumineuse. ATTENTION : l'utilisation de '$lumiere" devra        #
                                        # imperativement se faire avant '$divers' afin de permettre de transferer par cette           #
                                        # derniere option un eventuel deplacement de la source lumineuse, auquel cas il sera en       #
                                        # general necessaire de "quoter" l'argument '$7' afin qu'il ne passe qu'un ; par exemple :    #
                                        #                                                                                             #
                                        #                   $xci/montagne.71$Z  <surface> (...) <imageR> "Ty=... sx=... sy=..."       #
                                        #                                                                                             #

set  depth="depth=FAUX"
                                        # Pour ne pas avoir de depth-cueing.                                                          #
set  depth="depth=VRAI min=$depth_cueing"
                                        # Pour avoir du depth-cueing (0.0 representant le maximum d'effet, et 1.0 son absence).       #

set  avion="avion=FAUX alias=VRAI"
                                        # Pour faire une vue de cote.                                                                 #

set  convolution="renormaliser=FAUX Facteur=2.0"
                                        # Parametres de la convolution variable.                                                      #

set  texture=`get_feuille$Z $Texture`
                                        # Recuperation du nom de la texture dans son directory.                                       #
$xci/vraies_C$X     A=$Texture p=$paletteT RR=$xT/$texture$ROUGE RV=$xT/$texture$VERTE RB=$xT/$texture$BLEUE $formatI
                                        # Recuperation des trois composantes 'RVB' de la texture.                                     #

FileTmpB  imageS $M
                                        # Nom temporaire pour la montagne sans effet de lointain.                                     #
FileTmpB  imageZ
                                        # Nom temporaire pour le 'Z-Buffer'.                                                          #

$xci/montagne.01$X  A=$surface T=$xT/$texture$ROUGE                                                                                     \
                    R=$imageS$ROUGE Z-Buffer=VRAI Z=$imageZ$ROUGE $depth ombres=VRAI $avion $lumiere $translation $divers $formatI
$xci/montagne.01$X  A=$surface T=$xT/$texture$VERTE                                                                                     \
                    R=$imageS$VERTE Z-Buffer=VRAI Z=$imageZ$VERTE $depth ombres=VRAI $avion $lumiere $translation $divers $formatI
$xci/montagne.01$X  A=$surface T=$xT/$texture$BLEUE                                                                                     \
                    R=$imageS$BLEUE Z-Buffer=VRAI Z=$imageZ$BLEUE $depth ombres=VRAI $avion $lumiere $translation $divers $formatI
                                        # Mise en montagne de l'image argument ($surface) avec recuperation                           #
                                        # du 'Z-Buffer'.                                                                              #
$xci/complement$X   A=$imageZ$ROUGE R=$imageZ$ROUGE $formatI
$xci/complement$X   A=$imageZ$VERTE R=$imageZ$VERTE $formatI
$xci/complement$X   A=$imageZ$BLEUE R=$imageZ$BLEUE $formatI
                                        # Complementation du 'Z-Buffer'.                                                              #
$xci/substitue$X    A=$imageZ$ROUGE p=$xiP/depthfiel.$plan_net substitution=L_SUBSTITUTION_ROUGE R=$imageZ$ROUGE $formatI
$xci/substitue$X    A=$imageZ$VERTE p=$xiP/depthfiel.$plan_net substitution=L_SUBSTITUTION_ROUGE R=$imageZ$VERTE $formatI
$xci/substitue$X    A=$imageZ$BLEUE p=$xiP/depthfiel.$plan_net substitution=L_SUBSTITUTION_ROUGE R=$imageZ$BLEUE $formatI
                                        # Mise a l'echelle du 'Z-Buffer', et ce afin que les premiers plans restent tres nets, et     #
                                        # que le fond de la scene deviennent tres flous...                                            #
$xci/convol.02$X    A=$imageS$ROUGE N=$imageZ$ROUGE $convolution R=$imageR$ROUGE $formatI
$xci/convol.02$X    A=$imageS$VERTE N=$imageZ$VERTE $convolution R=$imageR$VERTE $formatI
$xci/convol.02$X    A=$imageS$BLEUE N=$imageZ$BLEUE $convolution R=$imageR$BLEUE $formatI
                                        # Et reconstitution finale en fausses couleurs parfaites de l'effet de profondeur de champ.   #

FileTmpE       imageS

FileTmpE       imageZ

$DELETE_VALIDE $xT/$texture$ROUGE
$DELETE_VALIDE $xT/$texture$VERTE
$DELETE_VALIDE $xT/$texture$BLEUE
                                        # Enfin, on nettoie...                                                                        #



Copyright © Jean-François Colonna, 2019-2021.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / Ecole Polytechnique, 2019-2021.