Renderman (Partie 3) |
||
Les shaders : Définition Utilisation de "shaders" pour réaliser chacune de ces taches:
Shader : procédure programmée (en Renderman Shading Language) qui contient individuellement un de ces processus. Elle assure le calcul de valeurs nécessaires lors d'une phase de rendu. Renderman fournit un certain nombre de shaders standards. Il est possible d'en écrire d'autres. Les shaders : Utilisation L'utilisation d'un shader apparaît dans un programme Renderman comme un appel à une fonction particulière du type: Ri..Handle RiShadeFonction...(char *name, paramlist); Le premier paramètre est le nom du shader. La parameterlist permet la transmission des paramètres du shader. Ri..Handle permet de récupérer un handle sur le shader instancié. Les shaders de source lumineuse Calcul de l'intensité lumineuse et de la couleur de la lumière envoyée par une source lumineuse vers un point. RtLightHandle RiLightSource(char *name,parameterlist); ajoute une source lumineuse dans une scène par instanciation du shader appelé name. Shaders de source lumineuse prédéfinis
RiLightSource("ambientelight",
"intensity",RtFloat *intens, "lightcolor",RtColor color, "from",RtPoint de, "to",RtPoint vers, RI_NULL)
"intensity",RtFloat *intens, "lightcolor",RtColor color, "from",RtPoint position, RI_NULL)
"intensity",RtFloat *intens, "lightcolor",RtColor color, "from",RtPoint position, "to",RtPoint vers, "coneangle",RtFloat *conea, "conedeltaangle",RtFloat *cda, "beamdistribution",RtFloat *d, RI_NULL) Exemples
void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RiSurface("matte",RI_NULL); Go(); RiWorldEnd(); RiEnd(); }
void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RiSurface("matte",RI_NULL); Go(); RiWorldEnd(); RiEnd(); }
void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RtPoint source = { 1.0F,1.7F,3.0F } ; RtFloat intensite = 4.0F ; RiLightSource("pointlight", "intensity",&intensite, "from",source, RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RiSurface("matte",RI_NULL); Go(); RiWorldEnd(); RiEnd(); }
void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RtPoint source = { 0.0F,0.0F,-8.0F } ; RtPoint dest = { 0.0F,0.5F,13.0F } ; RtFloat intensite = 100.0F ; RtFloat ca = 0.11F ; RtFloat cda = 0.05F ; RiLightSource("spotlight", "intensity",&intensite, "from",source, "to",dest, "coneangle",&ca, "conedeltaangle",&cda, RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RiSurface("matte",RI_NULL); Go(); RiWorldEnd(); RiEnd(); } Shaders de surfaces lumineuses Les shaders de lumière prédéfinis ne permettent de créer que des lumières ponctuelles, ce qui n'est pas représentatif d'une majorité des lumières naturelles. Renderman permet de décrire des surfaces lumineuses. RiLightHandle RiAreaLightSource(char *name,paramlist) De RiAreaLightSource jusqu'à la prochaine restauration de l'environnement, toute surface déclarée est ajoutée à la surface lumineuse. Les shaders de surfaces Appelés quand un point d'une surface est visible pour déterminer la couleur de la lumière réfléchie par ce point dans une direction particulière. Un shader de surface peut également rendre compte de l'opacité d'une surface et peut donc autoriser la visualisation des objets situés derrière elle. RtVoid RiSurface(char *name,parameterlist); Paramètres pris en compte :
Réflexions modélisées :
Shaders prédéfinis
RiSurface("constant", RtColor color1 = {.9F,.9F,.5F}; RtColor color2 = {.2F,.2F,.2F}; RtPoint Square[4] = { {5.0F,5.0F,0.0F},{-5.0F,5.0F,0.0F}, {-5.0F,-5.0F,0.0F},{5.0F,-5.0F,0.0F} }; void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RtFloat ka = 0.1F ; RtFloat kd = 0.9F ; RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color2); RiPolygon((RtInt) 4,RI_P, (RtPointer) Square, RI_NULL); RiSurface("constant", RI_NULL); RiColor(color1); Go(); RiWorldEnd(); RiEnd(); }
RiSurface("matte", RtColor color1 = {.9F,.9F,.5F}; RtColor color2 = {.2F,.2F,.2F}; RtPoint Square[4] = { {5.0F,5.0F,0.0F},{-5.0F,5.0F,0.0F}, {-5.0F,-5.0F,0.0F},{5.0F,-5.0F,0.0F} }; void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RtFloat ka = 0.1F ; RtFloat kd = 0.9F ; RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color2); RiPolygon((RtInt) 4,RI_P, (RtPointer) Square, RI_NULL); RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color1); Go(); RiWorldEnd(); RiEnd(); }
"Ka",RtFloat *ka, "Ks",RtFloat *ks, "roughness",RtFloat *r, RI_NULL) ; RtColor color1 = {.9F,.9F,.5F}; RtColor color2 = {.2F,.2F,.2F}; RtPoint Square[4] = { {5.0F,5.0F,0.0F},{-5.0F,5.0F,0.0F}, {-5.0F,-5.0F,0.0F},{5.0F,-5.0F,0.0F} }; void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RtFloat ka = 0.1F ; RtFloat kd = 0.9F ; RtFloat ks = 0.9F ; RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color2); RiPolygon((RtInt) 4,RI_P, (RtPointer) Square, RI_NULL); RiSurface("metal", "Ka",&ka, "Ks",&ks, RI_NULL); RiColor(color1); Go(); RiWorldEnd(); RiEnd(); } RtColor color1 = {.7F,.7F,1.0F}; RtColor color2 = {.2F,.2F,.2F}; RtPoint Square[4] = { {5.0F,5.0F,0.0F},{-5.0F,5.0F,0.0F}, {-5.0F,-5.0F,0.0F},{5.0F,-5.0F,0.0F} }; void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RtFloat ka = 0.1F ; RtFloat kd = 0.9F ; RtFloat ks = 0.9F ; RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color2); RiPolygon((RtInt) 4,RI_P, (RtPointer) Square, RI_NULL); RiSurface("metal", "Ka",&ka, "Ks",&ks, RI_NULL); RiColor(color1); Go(); RiWorldEnd(); RiEnd(); }
RiSurface("plastic", RtColor color1 = {.9F,.9F,.5F}; RtColor color2 = {.2F,.2F,.2F}; RtPoint Square[4] = { {5.0F,5.0F,0.0F},{-5.0F,5.0F,0.0F}, {-5.0F,-5.0F,0.0F},{5.0F,-5.0F,0.0F} }; void main(void) { RiBegin(RI_NULL); RiFormat(400,400,1.0F); RiDisplay("PinDeck.tif", RI_FILE,RI_RGB, RI_NULL); RiLightSource("ambientlight",RI_NULL); RiLightSource("distantlight",RI_NULL); RtFloat fov = 45.0F ; RiProjection("perspective", RI_FOV,(RtPointer) &fov, RI_NULL); RiTranslate(0.0F,0.0F,6.0F); RiWorldBegin(); RtFloat ka = 0.1F ; RtFloat kd = 0.7F ; RtFloat ks = 0.2F ; RiSurface("matte", "Ka",&ka, "Kd",&kd, RI_NULL); RiColor(color2); RiPolygon((RtInt) 4,RI_P, (RtPointer) Square, RI_NULL); RiSurface("plastic", "Ka",&ka, "Kd",&kd, "Ks",&ks, RI_NULL); RiColor(color1); Go(); RiWorldEnd(); RiEnd(); } |