Jason McKesson avatar Jason McKesson committed e103222

Tut08: Added some of its images.

Comments (0)

Files changed (11)

Add a comment to this file

Documents/Illumination/AngleLightColumn.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="300px" width="300px" >
+	<style type="text/css" ><![CDATA[.__grid1
+{
+	stroke: #CCC;
+	stroke-width: 1px;
+	fill: none;
+}
+
+.__axis_arrow_end1
+{
+	marker-end: url(#__axis_arrow1);
+}
+
+.surface
+{
+	fill: lightblue;
+	stroke: none;
+}
+
+.light-ray
+{
+	marker-end: url(#arrow);
+	stroke: black;
+	stroke-width: 1px;
+}
+
+.intersect
+{
+	stroke-width: 4px;
+	stroke: black;
+}
+
+.light
+{
+	fill: yellow;
+	stroke: none;
+}
+
+.__axis1
+{
+	stroke: black;
+	stroke-width: 2px;
+	fill: none;
+}
+
+.arrowhead
+{
+	stroke: black;
+	stroke-width: 1px;
+	fill: black;
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead" />
+		</marker>
+	</defs>
+	<path d="M 116.4589803375 240 L 183.5410196625 240 L 720.19733426245 -28.328157299975 L 653.11529493745 -28.328157299975 Z" class="light" />
+	<line x2="203.66563145999" y2="213.16718427" y1="-28.328157299975" x1="686.65631459995" class="light-ray" />
+	<rect y="240" x="0" height="90" width="300" class="surface" />
+	<line x2="183.5410196625" y2="240" y1="240" x1="116.4589803375" class="intersect" />
+</svg>
Add a comment to this file

Documents/Illumination/DiffuseReflection.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="300px" width="500px" >
+	<style type="text/css" ><![CDATA[.__grid1
+{
+	stroke: #CCC;
+	stroke-width: 1px;
+	fill: none;
+}
+
+.arrowhead
+{
+	fill: lightblue;
+	stroke: lightblue;
+}
+
+.ray
+{
+	marker-end: url(#arrow);
+	stroke: lightblue;
+	stroke-dasharray: 3,3;
+	stroke-width: 1px;
+}
+
+.light
+{
+	fill: yellow;
+	stroke: none;
+}
+
+.incident-ray
+{
+	marker-end: url(#arrow);
+	stroke: lightblue;
+	stroke-width: 2px;
+}
+
+.__axis_arrow_end1
+{
+	marker-end: url(#__axis_arrow1);
+}
+
+.surface
+{
+	fill: lightblue;
+	stroke: none;
+}
+
+.__axis1
+{
+	stroke: black;
+	stroke-width: 2px;
+	fill: none;
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead" />
+		</marker>
+	</defs>
+	<line x2="250" y2="240" y1="60" x1="40" class="incident-ray" />
+	<line x2="163.06667563398" y2="216.70628594077" y1="240" x1="250" class="ray" />
+	<line x2="172.0577136594" y2="195" y1="240" x1="250" class="ray" />
+	<line x2="186.36038969321" y2="176.36038969321" y1="240" x1="250" class="ray" />
+	<line x2="205" y2="162.0577136594" y1="240" x1="250" class="ray" />
+	<line x2="226.70628594077" y2="153.06667563398" y1="240" x1="250" class="ray" />
+	<line x2="250" y2="150" y1="240" x1="250" class="ray" />
+	<line x2="273.29371405923" y2="153.06667563398" y1="240" x1="250" class="ray" />
+	<line x2="295" y2="162.0577136594" y1="240" x1="250" class="ray" />
+	<line x2="313.63961030679" y2="176.36038969321" y1="240" x1="250" class="ray" />
+	<line x2="327.9422863406" y2="195" y1="240" x1="250" class="ray" />
+	<line x2="336.93332436602" y2="216.70628594077" y1="240" x1="250" class="ray" />
+	<rect y="240" x="0" height="90" width="500" class="surface" />
+	<circle r="20" cy="60" cx="40" class="light" />
+</svg>
Add a comment to this file

Documents/Illumination/DirectLightColumn.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="300px" width="300px" >
+	<style type="text/css" ><![CDATA[.light-ray
+{
+	marker-end: url(#arrow);
+	stroke: black;
+	stroke-width: 1px;
+}
+
+.__axis_arrow_end1
+{
+	marker-end: url(#__axis_arrow1);
+}
+
+.__grid1
+{
+	stroke: #CCC;
+	stroke-width: 1px;
+	fill: none;
+}
+
+.surface
+{
+	fill: lightblue;
+	stroke: none;
+}
+
+.intersect
+{
+	stroke-width: 4px;
+	stroke: black;
+}
+
+.__axis1
+{
+	stroke: black;
+	stroke-width: 2px;
+	fill: none;
+}
+
+.light
+{
+	fill: yellow;
+	stroke: none;
+}
+
+.arrowhead
+{
+	stroke: black;
+	stroke-width: 1px;
+	fill: black;
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead" />
+		</marker>
+	</defs>
+	<path d="M 135 240 L 165 240 L 165 -360 L 135 -360 Z" class="light" />
+	<line x2="150" y2="180" y1="-360" x1="150" class="light-ray" />
+	<rect y="240" x="0" height="90" width="300" class="surface" />
+	<line x2="165" y2="240" y1="240" x1="135" class="intersect" />
+</svg>

Documents/Illumination/GenAngleLightColumn.lua

+require "SvgWriter"
+require "vmath"
+require "Viewport"
+require "SubImage"
+require "GridAxis"
+require "_utils"
+
+local imageSize = vmath.vec2(300, 300);
+
+local subImages = SubImage.SubImage(1, 1, imageSize.x, imageSize.y, 0, 0);
+
+local coordSize = 10;
+local coordWidth = coordSize * (imageSize.x / imageSize.y);
+
+local vp = Viewport.Viewport(imageSize, {0, 3}, {coordWidth, coordSize})
+local trans2 = Viewport.Transform2D()
+vp:SetTransform(trans2);
+
+local styleLib = SvgWriter.StyleLibrary();
+
+local lightSourceColor = "yellow";
+local surfaceColor = "lightblue";
+
+styleLib:AddStyle(nil, "surface", SvgWriter.Style():stroke("none"):fill(surfaceColor));
+styleLib:AddStyle(nil, "light", SvgWriter.Style():stroke("none"):fill(lightSourceColor));
+styleLib:AddStyle(nil, "light-ray",
+	SvgWriter.Style():stroke("black"):stroke_width("1px"):marker_end(SvgWriter.uriLocalElement("arrow")));
+styleLib:AddStyle(nil, "intersect",
+	SvgWriter.Style():stroke("black"):stroke_width("4px"));
+
+styleLib:AddStyle(nil, "arrowhead",
+	SvgWriter.Style():stroke("black"):fill("black"):stroke_width("1px"));
+
+local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);
+
+--Surface.
+local surfaceDim =
+{
+	vmath.vec2(-coordWidth / 2, 0), vmath.vec2(coordWidth / 2, -3),
+};
+
+surfaceDim = vp:Transform(surfaceDim);
+
+--Light column
+local lightDir = vmath.norm(vmath.vec2(-2, -1));
+local offsetDir = vmath.vec2(lightDir.y, -lightDir.x);
+
+local lightDirVerts =
+{
+	(coordSize * 2 * -lightDir),
+	(2 * -lightDir),
+};
+
+local intersectionPts = {};
+local tempPts = {}
+
+tempPts[1] = lightDirVerts[2] + (0.5 * offsetDir)
+tempPts[2] = lightDirVerts[2] + (-0.5 * offsetDir)
+
+for i = 1, #tempPts do
+	local dist = math.abs(tempPts[i].y / lightDir.y);
+	
+	intersectionPts[i] = lightDir * dist + tempPts[i];
+end
+
+local columnVerts =
+{
+	vmath.vec2(intersectionPts[1]),
+	vmath.vec2(intersectionPts[2]),
+	intersectionPts[2] + (-lightDir * coordSize * 2),
+	intersectionPts[1] + (-lightDir * coordSize * 2),
+};
+
+
+--[[
+local columnVerts =
+{
+	vmath.vec2(-0.5, coordSize),
+	vmath.vec2(-0.5, 0),
+	vmath.vec2(0.5, 0),
+	vmath.vec2(0.5, coordSize),
+}
+]]
+
+intersectionPts = vp:Transform(intersectionPts);
+columnVerts = vp:Transform(columnVerts);
+
+local columnPath = SvgWriter.Path();
+columnPath:M(columnVerts[1]);
+for i = 2, #columnVerts do
+	columnPath:L(columnVerts[i]);
+end
+columnPath:Z();
+
+lightDirVerts = vp:Transform(lightDirVerts);
+
+local writer = SvgWriter.SvgWriter(ConstructSVGName(arg[0]), {subImages:Size().x .."px", subImages:Size().y .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		WriteStandardArrowhead(writer, "arrow", {"arrowhead"});
+	writer:EndDefinitions();
+
+--	axisData:AddDefinitions(writer, "g_axes");
+--	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());
+	
+	--Draw light column.
+	writer:Path(columnPath, {"light"});
+	writer:Line(lightDirVerts[1], lightDirVerts[2], {"light-ray"});
+	
+	--Draw surface.
+	writer:Rect2Pt(surfaceDim[1], surfaceDim[2], nil, {"surface"});
+	
+	--Draw intersection.
+	writer:Line(intersectionPts[1], intersectionPts[2], {"intersect"});
+
+writer:Close();

Documents/Illumination/GenDiffuseReflection.lua

+require "SvgWriter"
+require "vmath"
+require "Viewport"
+require "SubImage"
+require "GridAxis"
+require "_utils"
+
+local imageSize = vmath.vec2(500, 300);
+
+local subImages = SubImage.SubImage(1, 1, imageSize.x, imageSize.y, 0, 0);
+
+local coordSize = 10;
+local coordWidth = coordSize * (imageSize.x / imageSize.y);
+
+local vp = Viewport.Viewport({500, 300}, {0, 3}, {coordWidth, coordSize})
+local trans2 = Viewport.Transform2D()
+vp:SetTransform(trans2);
+
+local styleLib = SvgWriter.StyleLibrary();
+
+local lightSourceColor = "yellow";
+local surfaceColor = "lightblue";
+
+styleLib:AddStyle(nil, "surface", SvgWriter.Style():stroke("none"):fill(surfaceColor));
+styleLib:AddStyle(nil, "light", SvgWriter.Style():stroke("none"):fill(lightSourceColor));
+styleLib:AddStyle(nil, "arrowhead",
+	SvgWriter.Style():stroke(surfaceColor):fill(surfaceColor));
+	
+styleLib:AddStyle(nil, "ray",
+	SvgWriter.Style():stroke(surfaceColor):stroke_width("1px"):stroke_dasharray({3, 3}):marker_end(SvgWriter.uriLocalElement("arrow")));
+	
+styleLib:AddStyle(nil, "incident-ray",
+	SvgWriter.Style():stroke(surfaceColor):stroke_width("2px"):marker_end(SvgWriter.uriLocalElement("arrow")));
+	
+local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);
+
+--Surface and light.
+local surfaceDim =
+{
+	vmath.vec2(-coordWidth / 2, 0), vmath.vec2(coordWidth / 2, -3),
+};
+
+local lightSourcePos = vmath.vec2(-7, 6);
+local lightSourceRadius = 20;
+
+surfaceDim = vp:Transform(surfaceDim);
+lightSourcePos = vp:Transform(lightSourcePos);
+
+--Light rays
+local intersectPt = vmath.vec2(0, 0);
+
+intersectPt = vp:Transform(intersectPt);
+
+--Diffuse Rays
+local rayEndPts = {};
+local iNumRays = 11;
+
+local length = 3;
+
+for i = 1, iNumRays do
+	local angle = -math.pi / 2;
+	angle = angle + ((math.pi / (iNumRays + 1)) * i);
+	rayEndPts[#rayEndPts + 1] = length * vmath.vec2(math.sin(angle), math.cos(angle));
+end
+
+rayEndPts = vp:Transform(rayEndPts);
+
+local writer = SvgWriter.SvgWriter(ConstructSVGName(arg[0]), {subImages:Size().x .."px", subImages:Size().y .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		WriteStandardArrowhead(writer, "arrow", {"arrowhead"});
+	writer:EndDefinitions();
+
+--	axisData:AddDefinitions(writer, "g_axes");
+--	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());
+	
+	--Draw lines.
+	writer:Line(lightSourcePos, intersectPt, {"incident-ray"});
+	
+	--Draw diffuse reflections.
+	for i = 1, iNumRays do
+		writer:Line(intersectPt, rayEndPts[i], {"ray"});
+	end
+	
+	--Draw surface and light.
+	writer:Rect2Pt(surfaceDim[1], surfaceDim[2], nil, {"surface"});
+	writer:Circle(lightSourcePos, lightSourceRadius, {"light"});
+
+writer:Close();

Documents/Illumination/GenDirectLightColumn.lua

+require "SvgWriter"
+require "vmath"
+require "Viewport"
+require "SubImage"
+require "GridAxis"
+require "_utils"
+
+local imageSize = vmath.vec2(300, 300);
+
+local subImages = SubImage.SubImage(1, 1, imageSize.x, imageSize.y, 0, 0);
+
+local coordSize = 10;
+local coordWidth = coordSize * (imageSize.x / imageSize.y);
+
+local vp = Viewport.Viewport(imageSize, {0, 3}, {coordWidth, coordSize})
+local trans2 = Viewport.Transform2D()
+vp:SetTransform(trans2);
+
+local styleLib = SvgWriter.StyleLibrary();
+
+local lightSourceColor = "yellow";
+local surfaceColor = "lightblue";
+
+styleLib:AddStyle(nil, "surface", SvgWriter.Style():stroke("none"):fill(surfaceColor));
+styleLib:AddStyle(nil, "light", SvgWriter.Style():stroke("none"):fill(lightSourceColor));
+styleLib:AddStyle(nil, "light-ray",
+	SvgWriter.Style():stroke("black"):stroke_width("1px"):marker_end(SvgWriter.uriLocalElement("arrow")));
+styleLib:AddStyle(nil, "intersect",
+	SvgWriter.Style():stroke("black"):stroke_width("4px"));
+
+styleLib:AddStyle(nil, "arrowhead",
+	SvgWriter.Style():stroke("black"):fill("black"):stroke_width("1px"));
+
+local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);
+
+--Surface.
+local surfaceDim =
+{
+	vmath.vec2(-coordWidth / 2, 0), vmath.vec2(coordWidth / 2, -3),
+};
+
+surfaceDim = vp:Transform(surfaceDim);
+
+--Light column
+local lightDir = vmath.norm(vmath.vec2(0, -1));
+local offsetDir = vmath.vec2(lightDir.y, -lightDir.x);
+
+print(offsetDir)
+
+local lightDirVerts =
+{
+	(coordSize * 2 * -lightDir),
+	(2 * -lightDir),
+};
+
+local intersectionPts = {};
+local tempPts = {}
+
+tempPts[1] = lightDirVerts[2] + (0.5 * offsetDir)
+tempPts[2] = lightDirVerts[2] + (-0.5 * offsetDir)
+
+for i = 1, #tempPts do
+	local dist = math.abs(tempPts[i].y / lightDir.y);
+	
+	intersectionPts[i] = lightDir * dist + tempPts[i];
+end
+
+local columnVerts =
+{
+	vmath.vec2(intersectionPts[1]),
+	vmath.vec2(intersectionPts[2]),
+	intersectionPts[2] + (-lightDir * coordSize * 2),
+	intersectionPts[1] + (-lightDir * coordSize * 2),
+};
+
+
+--[[
+local columnVerts =
+{
+	vmath.vec2(-0.5, coordSize),
+	vmath.vec2(-0.5, 0),
+	vmath.vec2(0.5, 0),
+	vmath.vec2(0.5, coordSize),
+}
+]]
+
+intersectionPts = vp:Transform(intersectionPts);
+columnVerts = vp:Transform(columnVerts);
+
+local columnPath = SvgWriter.Path();
+columnPath:M(columnVerts[1]);
+for i = 2, #columnVerts do
+	columnPath:L(columnVerts[i]);
+end
+columnPath:Z();
+
+lightDirVerts = vp:Transform(lightDirVerts);
+
+local writer = SvgWriter.SvgWriter(ConstructSVGName(arg[0]), {subImages:Size().x .."px", subImages:Size().y .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		WriteStandardArrowhead(writer, "arrow", {"arrowhead"});
+	writer:EndDefinitions();
+
+--	axisData:AddDefinitions(writer, "g_axes");
+--	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());
+	
+	--Draw light column.
+	writer:Path(columnPath, {"light"});
+	writer:Line(lightDirVerts[1], lightDirVerts[2], {"light-ray"});
+	
+	--Draw surface.
+	writer:Rect2Pt(surfaceDim[1], surfaceDim[2], nil, {"surface"});
+	
+	--Draw intersection.
+	writer:Line(intersectionPts[1], intersectionPts[2], {"intersect"});
+
+writer:Close();

Documents/Illumination/GenNearVsFarLight.lua

+require "SvgWriter"
+require "vmath"
+require "Viewport"
+require "SubImage"
+require "GridAxis"
+require "_utils"
+
+local imageSize = vmath.vec2(400, 150);
+
+local subImages = SubImage.SubImage(1, 2, imageSize.x, imageSize.y, 0, 50);
+
+local coordSize = 6;
+local coordWidth = coordSize * (imageSize.x / imageSize.y);
+
+local vp = Viewport.Viewport(imageSize, {-5, 0}, {coordWidth, coordSize})
+local trans2 = Viewport.Transform2D()
+vp:SetTransform(trans2);
+
+local styleLib = SvgWriter.StyleLibrary();
+
+local lightSourceColor = "yellow";
+local surfaceColor = "lightblue";
+local rayColor = "darkblue";
+
+styleLib:AddStyle(nil, "surface", SvgWriter.Style():stroke("none"):fill(surfaceColor));
+styleLib:AddStyle(nil, "light", SvgWriter.Style():stroke("none"):fill(lightSourceColor));
+styleLib:AddStyle(nil, "arrowhead",
+	SvgWriter.Style():stroke(rayColor):fill(rayColor));
+	
+styleLib:AddStyle(nil, "ray",
+	SvgWriter.Style():stroke(rayColor):stroke_width("1px"):stroke_dasharray({3, 3}):marker_end(SvgWriter.uriLocalElement("arrow")));
+	
+local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);
+
+--Surface and light.
+local surfaceDim =
+{
+	vmath.vec2(0, coordSize / 2), vmath.vec2(3, -coordSize / 2),
+};
+
+local lightSourcePos = 
+{
+	vmath.vec2(-11, 0),
+	vmath.vec2(-2, 0);
+}
+
+local lightSourceRadius = 10;
+
+
+--Diffuse Rays
+local function CalcRays(lightPos, iNumRays, rayLen)
+	rayLen = rayLen or 3;
+
+	local rayLines = {};
+	for i = 1, iNumRays do
+		local startLoc = (-coordSize / 2) + ((coordSize / (iNumRays + 1)) * i);
+		startLoc = vmath.vec2(0, startLoc);
+		rayLines[#rayLines + 1] = startLoc;
+		
+		local dir = vmath.norm(lightPos - startLoc);
+		rayLines[#rayLines + 1] = startLoc + (dir * rayLen);
+	end
+	
+	return rayLines;
+end
+
+local rays =
+{
+	CalcRays(lightSourcePos[1], 7),
+	CalcRays(lightSourcePos[2], 7, 1.5),
+}
+
+local iNumRays = 7;
+
+surfaceDim = vp:Transform(surfaceDim);
+lightSourcePos = vp:Transform(lightSourcePos);
+rays[1] = subImages:Transform({1, 1}, vp:Transform(rays[1]));
+rays[2] = subImages:Transform({1, 2}, vp:Transform(rays[2]));
+
+local writer = SvgWriter.SvgWriter(ConstructSVGName(arg[0]), {subImages:Size().x .."px", subImages:Size().y .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		WriteStandardArrowhead(writer, "arrow", {"arrowhead"});
+		
+		writer:BeginGroup(nil, "g_surface");
+			--Draw surface and light.
+			writer:Rect2Pt(surfaceDim[1], surfaceDim[2], nil, {"surface"});
+		writer:EndGroup();
+
+	writer:EndDefinitions();
+
+--	axisData:AddDefinitions(writer, "g_axes");
+--	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());
+--	writer:Use("g_axes", subImages:Offset(1, 2), subImages:SubSize());
+	
+	writer:Use("g_surface", subImages:Offset(1, 1), subImages:SubSize());
+
+	lightSourcePos[1] = subImages:Transform({1, 1}, lightSourcePos[1]);
+	lightSourcePos[2] = subImages:Transform({1, 2}, lightSourcePos[2]);
+	writer:Circle(lightSourcePos[1], lightSourceRadius, {"light"});
+
+	writer:Use("g_surface", subImages:Offset(1, 2), subImages:SubSize());
+	writer:Circle(lightSourcePos[2], lightSourceRadius, {"light"});
+	
+	for i=1, #rays[1], 2 do
+		writer:Line(rays[1][i], rays[1][i + 1], {"ray"});
+	end
+	for i=1, #rays[2], 2 do
+		writer:Line(rays[2][i], rays[2][i + 1], {"ray"});
+	end
+	
+
+writer:Close();

Documents/Illumination/GenSurfaceColorAbsorption.lua

+require "SvgWriter"
+require "vmath"
+require "Viewport"
+require "SubImage"
+require "GridAxis"
+require "_utils"
+
+local imageSize = vmath.vec2(500, 300);
+
+local subImages = SubImage.SubImage(1, 1, imageSize.x, imageSize.y, 0, 0);
+
+local coordSize = 10;
+local coordWidth = coordSize * (imageSize.x / imageSize.y);
+
+local vp = Viewport.Viewport({500, 300}, {0, 3}, {coordWidth, coordSize})
+local trans2 = Viewport.Transform2D()
+vp:SetTransform(trans2);
+
+local styleLib = SvgWriter.StyleLibrary();
+
+local rayColors =
+{
+	"blue", "lightblue", "orange", "red", "blue", "lightblue", "violet", "gainsboro",
+	"seashell", "lightblue", "fuchsia", "darksalmon", "lightblue", "gold", "lightblue",
+};
+
+local lightSourceColor = "yellow";
+local surfaceColor = "lightblue";
+
+styleLib:AddStyle(nil, "surface", SvgWriter.Style():stroke("none"):fill(surfaceColor));
+styleLib:AddStyle(nil, "light", SvgWriter.Style():stroke("none"):fill(lightSourceColor));
+
+for i,color in ipairs(rayColors) do
+	styleLib:AddStyle(nil, "ray-" .. color, SvgWriter.Style():stroke(color):stroke_width("1px"));
+end
+	
+local axisData = GridAxis.GridAxis2D(vp, nil, styleLib, true, nil);
+
+--Surface and light.
+local surfaceDim =
+{
+	vmath.vec2(-coordWidth / 2, 0), vmath.vec2(coordWidth / 2, -3),
+};
+
+local lightSourcePos = vmath.vec2(-7, 6);
+local lightSourceRadius = 20;
+
+surfaceDim = vp:Transform(surfaceDim);
+lightSourcePos = vp:Transform(lightSourcePos);
+
+--Light rays
+local posRayStart = -4.0;
+
+local rayLines = {}
+for i,pos in ipairs(rayColors) do
+	rayLines[#rayLines + 1] = vmath.vec2(-4.0 + ((i - 1) * 0.5), 0);
+end
+
+rayLines = vp:Transform(rayLines);
+
+local writer = SvgWriter.SvgWriter(ConstructSVGName(arg[0]), {subImages:Size().x .."px", subImages:Size().y .. "px"});
+	writer:StyleLibrary(styleLib);
+	writer:BeginDefinitions();
+		WriteStandardArrowhead(writer, "arrow", {"arrowhead"});
+		WriteStandardArrowhead(writer, "arrow-sum", {"arrowhead-sum"});
+	writer:EndDefinitions();
+
+--	axisData:AddDefinitions(writer, "g_axes");
+--	writer:Use("g_axes", subImages:Offset(1, 1), subImages:SubSize());
+	
+	--Draw lines.
+	for i=1, #rayLines do
+		writer:Line(lightSourcePos, rayLines[i], {"ray-" .. rayColors[i]});
+	end
+	
+	--Draw reflections.
+	for i=1, #rayLines do
+		if(rayColors[i] == surfaceColor) then
+			local incident = vmath.norm(rayLines[i] - lightSourcePos);
+			local reflect = vmath.vec2(incident.x, -incident.y);
+			
+			local yLen = surfaceDim[1].y - lightSourcePos.y;
+			local len = yLen / incident.y;
+			local finalPos = (len * reflect) + rayLines[i];
+			
+			writer:Line(finalPos, rayLines[i], {"ray-" .. rayColors[i]});
+		end
+	end
+	
+	--Draw surface and light.
+	writer:Rect2Pt(surfaceDim[1], surfaceDim[2], nil, {"surface"});
+	writer:Circle(lightSourcePos, lightSourceRadius, {"light"});
+
+writer:Close();
Add a comment to this file

Documents/Illumination/NearVsFarLight.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="350px" width="400px" >
+	<style type="text/css" ><![CDATA[.light
+{
+	fill: yellow;
+	stroke: none;
+}
+
+.__grid1
+{
+	stroke: #CCC;
+	stroke-width: 1px;
+	fill: none;
+}
+
+.__axis_arrow_end1
+{
+	marker-end: url(#__axis_arrow1);
+}
+
+.arrowhead
+{
+	fill: darkblue;
+	stroke: darkblue;
+}
+
+.__axis1
+{
+	stroke: black;
+	stroke-width: 2px;
+	fill: none;
+}
+
+.surface
+{
+	fill: lightblue;
+	stroke: none;
+}
+
+.ray
+{
+	marker-end: url(#arrow);
+	stroke: darkblue;
+	stroke-dasharray: 3,3;
+	stroke-width: 1px;
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead" />
+		</marker>
+		<g id="g_surface" >
+			<rect y="0" x="325" height="150" width="75" class="surface" />
+		</g>
+	</defs>
+	<use xlink:href="#g_surface" y="0" x="0" height="150" width="400" />
+	<circle r="10" cy="75" cx="50" class="light" />
+	<use xlink:href="#g_surface" y="200" x="0" height="150" width="400" />
+	<circle r="10" cy="275" cx="275" class="light" />
+	<line x2="251.52138007881" y2="116.22028228885" y1="131.25" x1="325" class="ray" />
+	<line x2="250.68773739668" y2="102.366509645" y1="112.5" x1="325" class="ray" />
+	<line x2="250.17372304888" y2="88.648208389697" y1="93.75" x1="325" class="ray" />
+	<line x2="250" y2="75" y1="75" x1="325" class="ray" />
+	<line x2="250.17372304888" y2="61.351791610303" y1="56.25" x1="325" class="ray" />
+	<line x2="250.68773739668" y2="47.633490354999" y1="37.5" x1="325" class="ray" />
+	<line x2="251.52138007881" y2="33.779717711153" y1="18.75" x1="325" class="ray" />
+	<line x2="300.08635604388" y2="303.22215054936" y1="331.25" x1="325" class="ray" />
+	<line x2="295" y2="290" y1="312.5" x1="325" class="ray" />
+	<line x2="289.88765584116" y2="280.58287094044" y1="293.75" x1="325" class="ray" />
+	<line x2="287.5" y2="275" y1="275" x1="325" class="ray" />
+	<line x2="289.88765584116" y2="269.41712905956" y1="256.25" x1="325" class="ray" />
+	<line x2="295" y2="260" y1="237.5" x1="325" class="ray" />
+	<line x2="300.08635604388" y2="246.77784945064" y1="218.75" x1="325" class="ray" />
+</svg>
Add a comment to this file

Documents/Illumination/SurfaceColorAbsorption.svg

Added
New image
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" height="300px" width="500px" >
+	<style type="text/css" ><![CDATA[.ray-red
+{
+	stroke-width: 1px;
+	stroke: red;
+}
+
+.ray-seashell
+{
+	stroke-width: 1px;
+	stroke: seashell;
+}
+
+.surface
+{
+	fill: lightblue;
+	stroke: none;
+}
+
+.ray-orange
+{
+	stroke-width: 1px;
+	stroke: orange;
+}
+
+.ray-lightblue
+{
+	stroke-width: 1px;
+	stroke: lightblue;
+}
+
+.ray-blue
+{
+	stroke-width: 1px;
+	stroke: blue;
+}
+
+.ray-gainsboro
+{
+	stroke-width: 1px;
+	stroke: gainsboro;
+}
+
+.ray-blue
+{
+	stroke-width: 1px;
+	stroke: blue;
+}
+
+.ray-fuchsia
+{
+	stroke-width: 1px;
+	stroke: fuchsia;
+}
+
+.ray-darksalmon
+{
+	stroke-width: 1px;
+	stroke: darksalmon;
+}
+
+.__grid1
+{
+	stroke: #CCC;
+	stroke-width: 1px;
+	fill: none;
+}
+
+.__axis_arrow_end1
+{
+	marker-end: url(#__axis_arrow1);
+}
+
+.__axis1
+{
+	stroke: black;
+	stroke-width: 2px;
+	fill: none;
+}
+
+.ray-lightblue
+{
+	stroke-width: 1px;
+	stroke: lightblue;
+}
+
+.ray-lightblue
+{
+	stroke-width: 1px;
+	stroke: lightblue;
+}
+
+.ray-lightblue
+{
+	stroke-width: 1px;
+	stroke: lightblue;
+}
+
+.ray-lightblue
+{
+	stroke-width: 1px;
+	stroke: lightblue;
+}
+
+.ray-violet
+{
+	stroke-width: 1px;
+	stroke: violet;
+}
+
+.ray-gold
+{
+	stroke-width: 1px;
+	stroke: gold;
+}
+
+.light
+{
+	fill: yellow;
+	stroke: none;
+}]]></style>
+	<defs >
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead" />
+		</marker>
+		<marker markerWidth="10" markerHeight="8" refX="10" refY="4" markerUnits="userSpaceOnUse" orient="auto" id="arrow-sum" >
+			<path d="M 10 4 L 0 0 L 0 8 Z" class="arrowhead-sum" />
+		</marker>
+	</defs>
+	<line x2="130" y2="240" y1="60" x1="40" class="ray-blue" />
+	<line x2="145" y2="240" y1="60" x1="40" class="ray-lightblue" />
+	<line x2="160" y2="240" y1="60" x1="40" class="ray-orange" />
+	<line x2="175" y2="240" y1="60" x1="40" class="ray-red" />
+	<line x2="190" y2="240" y1="60" x1="40" class="ray-blue" />
+	<line x2="205" y2="240" y1="60" x1="40" class="ray-lightblue" />
+	<line x2="220" y2="240" y1="60" x1="40" class="ray-violet" />
+	<line x2="235" y2="240" y1="60" x1="40" class="ray-gainsboro" />
+	<line x2="250" y2="240" y1="60" x1="40" class="ray-seashell" />
+	<line x2="265" y2="240" y1="60" x1="40" class="ray-lightblue" />
+	<line x2="280" y2="240" y1="60" x1="40" class="ray-fuchsia" />
+	<line x2="295" y2="240" y1="60" x1="40" class="ray-darksalmon" />
+	<line x2="310" y2="240" y1="60" x1="40" class="ray-lightblue" />
+	<line x2="325" y2="240" y1="60" x1="40" class="ray-gold" />
+	<line x2="340" y2="240" y1="60" x1="40" class="ray-lightblue" />
+	<line x2="145" y2="240" y1="60" x1="250" class="ray-lightblue" />
+	<line x2="205" y2="240" y1="60" x1="370" class="ray-lightblue" />
+	<line x2="265" y2="240" y1="60" x1="490" class="ray-lightblue" />
+	<line x2="310" y2="240" y1="60" x1="580" class="ray-lightblue" />
+	<line x2="340" y2="240" y1="60" x1="640" class="ray-lightblue" />
+	<rect y="240" x="0" height="90" width="500" class="surface" />
+	<circle r="20" cy="60" cx="40" class="light" />
+</svg>

Documents/Illumination/Tutorial 08.xml

             of the light and only reflects the blue parts. If one were to shine a red light on the
             surface, the surface would appear very dark, as the surface absorbs non-blue light, and
             the red light doesn't have much non-blue light in it.</para>
-        <!--TODO: Show a picture of a surface being hit with various colored rays, but only the ones the same
-color as the surface are reflected.-->
+        <figure>
+            <title>Surface Light Absorption</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="SurfaceColorAbsorption.svg" format="SVG"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
         <para>Therefore, the apparent color of a surface is a combination of the absorbing
             characteristics of the surface (which wavelengths are absorbed or reflected) and the
             wavelengths of light shone upon that surface.</para>
             of these, the reflected light, the source light, and the surface absorption, can be
             described as RGB colors, on the range [0, 1].</para>
         <para>The intensity of light shone upon a surface depends on (at least) two things. First,
-            it depends on the intensity of light that the light source in question emits. And
+            it depends on the intensity of light that reaches the surface from a light source. And
             second, it depends on the angle between the surface and the light.</para>
         <para>Consider a perfectly flat surface. If you shine a column of light with a known
             intensity directly onto that surface, the intensity of that light at each point under
             the surface will be a known value, based on the intensity of the light divided by the
             area projected on the surface.</para>
-        <!--TODO: Show a column of light shining directly onto the surface.-->
+        <figure>
+            <title>Perpendicular Light</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="DirectLightColumn.svg" format="SVG"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
         <para>If the light is shone instead at an angle, the area on the surface is much wider. This
             spreads the same light intensity over a larger area of the surface; as a result, each
             point under the light <quote>sees</quote> the light less intensely.</para>
-        <!--TODO: Show a column of light shining at an angle to the surface.-->
+        <figure>
+            <title>Light at an Angle</title>
+            <mediaobject>
+                <imageobject>
+                    <imagedata fileref="AngleLightColumn.svg" format="SVG"/>
+                </imageobject>
+            </mediaobject>
+        </figure>
         <para>Therefore, the intensity of the light cast upon a surface is a function of the
             original light's intensity and the angle between the surface and the light source. This
             angle is called the <glossterm>angle of incidence</glossterm> of the light.</para>
             <para><glossterm>Diffuse lighting</glossterm> refers to a particular kind of
                 light/surface interaction, where the light from the light source reflects from the
                 surface at many angles, instead of as a perfect mirror.</para>
-            <!--TODO: Show an image of a light ray hitting a surface and bouncing off at many angles.-->
+            <figure>
+                <title>Diffuse Reflectance</title>
+                <mediaobject>
+                    <imageobject>
+                        <imagedata fileref="DiffuseReflection.svg" format="SVG"/>
+                    </imageobject>
+                </mediaobject>
+            </figure>
             <para>An ideal diffuse material will reflect light evenly in all directions, as shown in
                 the picture above. No actual surfaces are ideal diffuse materials, but this is a
                 good starting point and looks pretty decent.</para>
                 towards the light can change dramatically over the surface of that object. As the
                 light source is moved farther and farther away, the direction towards the light
                 varies less and less over the surface of the object.</para>
-            <!--TODO: Show a picture of a light source close to an object, and the direction twoards the light.
-Then show a more distant light source, and the directions towards the light.-->
+            <figure>
+                <title>Near and Far Lights</title>
+                <mediaobject>
+                    <imageobject>
+                        <imagedata fileref="NearVsFarLight.svg" format="SVG"/>
+                    </imageobject>
+                </mediaobject>
+            </figure>
             <para>If the light source is sufficiently distant, relative to the size of the scene
-                being rendered, then the direction towards the light is the same for every object
-                you render. Since the direction is the same for all objects, the direction can
-                simply be a single direction given to all of the objects. There is no need to
-                compute the direction based on the position of the point being illuminated.</para>
+                being rendered, then the direction towards the light is the same for every point on
+                every object you render. Since the direction is the same everywhere, the light can
+                be represented as just a single direction given to all of the objects. There is no
+                need to compute the direction based on the position of the point being
+                illuminated.</para>
             <para>This situation is called a <glossterm>directional light source.</glossterm> Light
                 from such a source effectively comes from a particular direction as a wall of
                 intensity, evenly distributed over the scene.</para>
-            <!--TODO: Show a diagram of directional light source lighting a scene in 2D.-->
             <para>Direction light sources are a good model for lights like the sun relative to a
                 small region of the Earth. It would not be a good model for the sun relative to the
                 rest of the solar system. So scale is important.</para>
         </section>
         <section>
             <title>Normals and Space</title>
-            <para>Normals have many properties that positions do. Normals are 3D coordinates, so
-                like positions, they exist in a certain coordinate system. It is usually a good idea
-                to have the normals for your vertices be in the same coordinate system as the
-                positions in those vertices. So that means mesh space.</para>
+            <para>Normals have many properties that positions do. Normals are vector directions, so
+                like position vectors, they exist in a certain coordinate system. It is usually a
+                good idea to have the normals for your vertices be in the same coordinate system as
+                the positions in those vertices. So that means mesh space.</para>
             <para>This also means that normals must be transformed from mesh space to another space.
                 That other space needs to be the same space that the lighting direction is in;
                 otherwise, the two vectors cannot be compared. One might think that world space is a
                 will use camera space. The reason for this is partially illustrative: in later
                 tutorials, we are going to do lighting in some rather unusual spaces. By using
                 camera space, it gets us in the habit of transforming both our light direction and
-                the surface normal.</para>
+                the surface normals into different spaces.</para>
             <para>We will talk more in later sections about exactly how we transform the normal. For
                 now, we will just transform it with the regular transformation matrix.</para>
         </section>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.