RenderMan - Writing RenderMan Shaders (2)-. Transforming Tiles Transforming texture coordinates has an "inverse" effect on the appearance of the pattern.

Slides:



Advertisements
Similar presentations
Polar Coordinates We Live on a Sphere.
Advertisements

Trigonometric Functions
OAA Math Terms. y-axis the vertical number line in a coordinate plane.
Working with Shapes in Two Dimensions
Starter Convert the following: 4000 m = __________km
Introduction to shapes
Renald Aquilina 4.3 Maths Project Area and Surface Area.
CHAPTER 4 CIRCULAR FUNCTIONS.
7.1 Area Between 2 Curves Objective: To calculate the area between 2 curves. Type 1: The top to bottom curve does not change. a b f(x) g(x) *Vertical.
Welcome Back!!!.
Objective: Convert between degrees and radians. Draw angles in standard form. Warm up Fill in the blanks. An angle is formed by two_____________ that have.
11.5 Rotations. Rotations Rotate a Figure 90 about the origin.
 What we're going to do is break up a circle into little pieces, and then reassemble it into a shape that we know the area formula for...  Maybe you're.
8 Complex Numbers, Polar Equations, and Parametric Equations
TEKS 8.6 (A,B) & 8.7 (A,D) This slide is meant to be a title page for the whole presentation and not an actual slide. 8.6 (A) Generate similar shapes using.
CS 376 Introduction to Computer Graphics 02 / 07 / 2007 Instructor: Michael Eckmann.
Math 112 Elementary Functions Section 4 Polar Coordinates and Graphs Chapter 7 – Applications of Trigonometry.
Seven measuring the world (geo/metry). Measuring space This course is fundamentally about spaces of various kinds Physical space Image space Auditory.
TEKS 8.6 (A,B) & 8.7 (A,D) This slide is meant to be a title page for the whole presentation and not an actual slide. 8.6 (A) Generate similar shapes using.
Transformations Dilations Translations Reflections Rotations.
CS 450: Computer Graphics 2D TRANSFORMATIONS
13.2 Angles and Angle Measure
Perimeter Rectangles, Squares, and Triangles Perimeter Measures the distance around the edge of any flat object. To find the perimeter of any figure,
Polar Coordinates a different system of plotting points and coordinates than rectangular (x, y) it is based on the ordered pair (r, θ), where r is the.
MCHS ACT Review Plane Geometry. Created by Pam Callahan Spring 2013 Edition.
2.4: Rotations.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
POLAR COORDINATES (Ch )
REVIEW Polar Coordinates and Equations.
Chapter 2: Fundamentals I. After completing this Chapter, you will be able to do the following: Construct Geometric Figures Use Coordinate Systems Additional.
Grade 12 Trigonometry Trig Definitions. Radian Measure Recall, in the trigonometry powerpoint, I said that Rad is Bad. We will finally learn what a Radian.
It’s a Designer Original Josef Guarin Block 3 Geometry H.
Chapter 6 Additional Topics in Trigonometry Copyright © 2014, 2010, 2007 Pearson Education, Inc Polar Coordinates.
REVIEW Polar Coordinates and Equations. You are familiar with plotting with a rectangular coordinate system. We are going to look at a new coordinate.
Geometric Transformations
Acute angle An angle with a measure less than 90 degrees.
Chapter 12.  For each example, how would I get the first image to look like the second?
Transformations on the Coordinate Plane: Translations and Rotations.
Rotations on the Coordinate Plane. Horizontal- left and right.
2D Geometric Transformation Translation A translation is applied to an object by repositioning it along a straight-line path from one coordinate location.
Starter Convert the following: 4000 m = __________km
Lesson 2.7 Objective: To complete dilations on a coordinate plane.
Honors Geometry.  We learned how to set up a polygon / vertex matrix  We learned how to add matrices  We learned how to multiply matrices.
Coordinates and Design. What You Will Learn: To use ordered pairs to plot points on a Cartesian plane To draw designs on a Cartesian plane To identify.
Perform Congruence Transformations. Transformations: when you move or change a geometric figure in some way to produce a new figure. Image is what the.
Notes 10.7 – Polar Coordinates Rectangular Grid (Cartesian Coordinates) Polar Grid (Polar Coordinates) Origin Pole Positive X-axis Polar axis There is.
In the last several lessons, you have described translations using coordinates. You have also developed strategies for determining where an object started.
7 th Extended Third Quarter Review Standards: 7.5, 7.8, 8.6, 8.7, 8.8, 8.9, 8.10, 8.11.
Geometric Terms By Marilyn and Alyssa:). Angles Right Angle: An angle that is 90 degrees Acute Angle: An angle less than 90 degrees Obtuse Angle: An angle.
Before we begin our investigation of a radian let us first establish a definition of an angle and review some important concepts from geometry. What is.
1.5 Matricies.
Polar Coordinate System
Chapter 14, Translate & Rotate
11.4 Rotations 1/12/17.
Stand Quietly.
Farming: An example of a system
Trigonometry Second Edition Chapter 5
A movement of a figure in a plane.
1.
A movement of a figure in a plane.
Transformations and Symmetry
Rotations on the Coordinate Plane
Section 9.1 Polar Coordinates
Videos & Songs! - Colin Dodds song - transformation style.
POLAR COORDINATES Dr. Shildneck.
Transformations Translation Reflection The FRAME Routine
Homework Due Tomorrow.
Translate 5 squares left and 4 squares up.
Graphing Polar Coordinates
Year 7 Unit 1 Knowledge Organiser PLACE VALUE, DECIMALS & USING SCALES
Presentation transcript:

RenderMan - Writing RenderMan Shaders (2)-

Transforming Tiles Transforming texture coordinates has an "inverse" effect on the appearance of the pattern –if you scale the texture coordinates by a factor of 2, the frequency of the pattern will double and the pattern will appear twice as small –positive translations will move the pattern up and to the left (the opposite direction) –positive clockwise rotations will rotate the pattern counter-clockwise

Transforming Tiles Rotating Tiles –rotate2d(float x, y, angle, ox, oy, rx, ry) –Rotates a 2D point ( x, y ) clockwise by a specified angle (in radians) about an origin ( ox, oy ) and stores the resulting point in ( rx, ry ). –To rotate the cross shader, we replace the lines ss = repeat(s, freq); tt = repeat(t, freq); with rotate2d(s, t, radians(45), 0.5, 0.5, ss, tt); ss = repeat(ss, freq); tt = repeat(tt, freq);

/* rotcross.sl */ surface rotcross() { color surface_color, layer_color, surface_opac, layer_opac; float fuzz = 0.05; float ss, tt; float freq = 4; /* background layer */ surface_color = Cs; surface_opac = Os; /* rotate 45 degrees and repeat pattern 'freq' times horizontally & vertically */ rotate2d(s, t, radians(45), 0.5, 0.5, ss, tt); ss = repeat(ss, freq); tt = repeat(tt, freq); /* vertical bar layer */ layer_color = color (0.1, 0.5, 0.1); layer_opac = pulse(0.35, 0.65, fuzz, ss); surface_color = blend(surface_color, layer_color, layer_opac); /* horizontal bar layer */ layer_color = color (0.1, 0.1, 0.3); layer_opac = pulse(0.35, 0.65, fuzz, tt); surface_color = blend(surface_color, layer_color, layer_opac); /* output */ Oi = surface_opac; Ci = surface_opac * surface_color; }

Transforming Tiles Shifting Rows or Columns of Tiles –Alternating rows (or columns) of tiles can be staggered by using repeat, whichtile, and odd and/or even to determine if the current tile is in an odd or even row; and then shifting or not shifting texture or coordinates appropriately. –to shift even rows of a pattern by a 1/2 tile, you would add 0.5 to ss after it has been repeated. You still need to remember to mod ss with 1 so that it stays in the range 0 to 1. row = whichtile(t, freq); if (even(row)) ss = mod(ss + 0.5, 1);

/* shiftedblocks.sl */ surface shiftedblocks() { color surface_color, layer_color; color layer_opac; float ss, tt; float row; float fuzz = 0.05; float freq = 4; surface_color = Cs; /* shift even rows 1/2 tile */ ss = repeat(s, freq); tt = repeat(t, freq); row = whichtile(t, freq); if (even(row)) ss = mod(ss + 0.5, 1); /* squares */ layer_color = color (0.3, 0.0, 0.3); layer_opac = intersection(pulse(0.35, 0.65, fuzz, ss), pulse(0.35, 0.65, fuzz, tt)); surface_color = blend(surface_color, layer_color, layer_opac); /* output */ Ci = surface_color; }

Transforming Tiles Polar Coordinates –Polar coordinates are useful for generating radially shaped patterns (flowers, stars, etc.). The convenience function topolar2d converts a 2-D point in Cartesian coordinates to polar coordinates. –topolar2d(float x, y, r, theta) Transforms a 2-D point ( x,y ) in Cartesian coordinates to polar coordinates expressed in terms of r (distance from the origin) and theta (the angle expressed in radians). theta will be in the range [-PI, PI].

Shape Generation Simple, geometric shapes can be made in the RenderMan Shading Language using smoothstep or pulse often with one of two shading language distance functions: –float distance(point p1, p2) –float ptlined(point a, b, p)

Shape Generation Rectangles –Rectangular shapes can be made by intersecting (multiplying) a vertical pulse and a horizontal pulse. –you can use intersection instead of the multiplication operator.

/* rect.sl */ surface rect() { color surface_color, layer_color; color layer_opac; float fuzz = 0.025; color red = color (1,0,0); float left, right, top, bottom; surface_color = Cs; layer_color = red; left = 0.05; right = 0.75; /* rectangle sides */ top = 0.1; bottom = 0.7; layer_opac = pulse(left, right, fuzz, s) * pulse(top, bottom, fuzz, t); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; }

Shape Generation Disks and Rings –disks and rings can be generated using distance and either smoothstep (for a disk) or pulse (for a ring). –this pulse is generated by 1 - smoothstep(radius - fuzz, radius, d)

surface ring() { color surface_color, layer_color; color layer_opac; float fuzz = 0.025; color blue = color (0,0,1); point center; float radius, half_width; float d; surface_color = Cs; layer_color = blue; center = (0.5, 0.5, 0); /* position of ring */ radius = 0.35; /* radius of ring */ half_width = 0.05; /* 1/2 width of ring */ d = distance(center, (s, t, 0)); layer_opac = pulse(radius - half_width, radius + half_width, fuzz, d); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; } surface disk() { color surface_color, layer_color; color layer_opac; float fuzz = 0.025; color blue = color (0,0,1); point center; float radius; float d; surface_color = Cs; layer_color = blue; center = (0.5, 0.5, 0); /* location of center of disk */ radius = 0.35; /* radius of disk */ d = distance(center, (s, t, 0)); layer_opac = 1 - smoothstep(radius - fuzz, radius, d); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; }

Shape Generation Lines

surface line() { color surface_color, layer_color; color layer_opac; float fuzz = 0.025; color green = color (0,0.5,0); point p1, p2; float half_width; float d; surface_color = Cs; layer_color = green; p1 = (0.25, 0.15, 0);/* endpoint #1 */ p2 = (0.85, 0.7, 0);/* endpoint #2 */ half_width = 0.05;/* 1/2 line width */ d = ptlined(p1, p2, (s, t, 0)); layer_opac = 1 - smoothstep(half_width - fuzz, half_width, d); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; }

surface moon() { color surface_color, layer_color; color layer_opac; float fuzz = 0.01; float circle1, circle2, radius, d; point center; surface_color = color (0.05, 0.05, 0.15); fuzz = 0.01; /* moon radius */ radius = 0.45; /* moon color */ layer_color = color(1, 1, 0.9); /* first circle */ center = (.5,.5, 0); d = distance(center, (s, t, 0)); circle1 = 1 - smoothstep(radius - fuzz, radius, d); /* second circle */ center = (.65,.5, 0); d = distance(center, (s, t, 0)); circle2 = 1 - smoothstep(radius - fuzz, radius, d); /* use difference of two circles to create moon */ layer_opac = difference(circle1, circle2); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; }

Shape Generation Boolean Operations –various boolean operations based on disk and square shapes. disk = D square = S union(D,S) intersection(D,S) difference(D,S) difference(S,D) complement (difference(D,S)) union(difference(S,D), difference(D,S))

surface diskring() { color surface_color = 0, layer_color, color layer_opac; float fuzz = 0.01; point center; float ss, tt; float radius, d, half_width; float disk, ring; /* disk */ ss = repeat(s, 2); tt = repeat(t, 2); center = (0.5, 0.5, 0); radius = 0.35; d = distance(center, (ss, tt, 0)); disk = 1 - smoothstep(radius - fuzz, radius, d); /* ring */ ss = repeat(s, 5); tt = repeat(t, 5); center = (0.5, 0.5, 0); radius = 0.35; half_width = 0.05; d = distance(center, (ss, tt, 0)); ring = pulse(radius - half_width, radius + half_width, fuzz, d); /* bool disk & ring */ layer_color = color (1, 0.2, 0.2); layer_opac = union(difference(disk, ring), difference(ring, disk)); surface_color = blend(surface_color, layer_color, layer_opac); Ci = surface_color; }

Homework Shader flag.rib, flag.sl, flag.tif