|By Mike Jacobs||
|March 9, 2005 12:00 AM EST||
Reach behind your television and yank the cable out of the wall. Do you hear that noise? Not the kids screaming about their movie. Look at the screen. What you see is white noise: random bits of white, black and gray changing constantly. What does this have to do with movie magic or Java3D? What if a spell could conjure roaring fires, fluffy clouds, rippling water, naturally grained wood, smooth marble and even realistic terrains? That spell is available to us thanks to the inventive mind of Dr. Ken Perlin.
Who Was That Math Man?
Ken Perlin is a professor in the department of computer science at New York University. In 1997 he won an Academy Award for Technical Achievement from the Academy of Motion Picture Arts and Sciences for his procedural texturing techniques, which are widely used in feature films and television. He also had a big part in the computer animation in the movie "TRON." The techniques pioneered by Dr. Perlin allow programs to generate a wide range of realistic special effects efficiently. The foundation for these effects is a mathematical function called Perlin noise.
What Was That Noise?
Procedural texturing is the art of using an algorithm to generate a texture. Procedural techniques are not limited to texturing and can be applied to geometry, motion, color or any other thing you can imagine. Procedural techniques abstract the details of a scene or sequence into an algorithm. Parameters on the algorithm allow a variety of results to be achieved with the same algorithm. An example of procedural geometry was in my last article ("When Mars Is Too Big to Download," JDJ, September 2004) where we used parameters to vary the detail and roughness of the generated terrain. The advantage of using procedural techniques is that the details are generated, saving the cost of explicitly storing and retrieving them.
To make realistic special effects, we need a way to generate natural looking randomness. You might think that random numbers would be sufficient to accomplish this, but you would only be partially right. (See Figure 1.) Random numbers are typically generated without regard to past values. This lack of correlation can lead to abrupt changes between adjacent values and an unnatural special effect. What we need is a repeatable, smooth, non-cyclic random function whose results vary with the parameters we provide. Perlin noise was designed to do just that.
While the implementation details of Perlin noise are beyond the scope of this article, we do need a conceptual model to use it. The noise function accepts a number of double parameters and returns a double value between +1 and -1. One-dimensional noise is the result of generating random numbers at regular intervals and smoothly interpolating noise values in between using a high-order polynomial. This can be represented by a smooth curve as shown in Figure 1.
Two-dimensional noise does the interpolation in two dimensions forming a wavy noise surface. The three-dimensional noise can't be depicted graphically, but its foundation is a lattice. The three parameters represent the three dimensions of the lattice from which the noise value is calculated. This lattice consists of 256 by 256 by 256 points representing random numbers between which values are smoothly interpolated to calculate the noise. The noise value at the integer lattice locations is zero, while the values between the locations follows the same high-order polynomial mentioned above. A Java reference implementation called ImprovedNoise is available from Dr. Perlin's home page and a modified version is included with the source code for this article.
This probably sounds pretty mysterious, so let's put this magic to work with a few examples.
Casting Our First Spell: Blur
In my last article, we generated terrains with colors assigned based solely on elevation. Looking closely at some of the resulting terrains, you may have noticed that the colors created a layered effect. For this article, the FractalWorld3 example uses your choice of random numbers or Perlin noise to blur the colors to eliminate the layered affect. Have a look at Figure 2 to see this example in action.
In this example, the noise function is used to blur the boundaries between colors to make the transitions less apparent. The effect is implemented by nudging the color index with the noise function as shown in part in Listing 1.
The color index is determined normally and then a delta value is calculated with the noise function. The sum of the index and the delta value is rounded and clamped to create the new color index. This method uses the row, column and elevation as arguments to the noise function. All three are scaled down to focus the noise based on trial and error. You can think of the divisors as a zoom function into the noise. Because the noise is defined in a limited-size lattice, the zoom factor focuses the range: higher zoom results in less noise range. Finding the right recipe for an effect is mostly an art but luckily others have shared their recipes.
Texturing with Noise
A popular use for noise is to generate the colors on a texture. We can apply the texture to a shape, giving the appearance of natural materials like wood or marble. Have a look at Figure 3 for an example of an image produced by the PerlinNoiseSphere.
Java3D supports texturing of a shape by setting the texture image on the appearance object. The PerlinNoiseSphere example uses a Java3D Sphere primitive as the shape and Perlin noise to generate the texture. The Sphere primitive is used in this example so some texturing details can be automatically done for us. Setting up the texture on the appearance is shown in part in Listing 2. The getImage() method is where the magic happens. The recipe is used to determine the noise values and the PerlinNoiseSphere example interprets the values as colors. Before I disclose the secret to this trick, I should mention that there's no relationship between how the recipe creates the texture and how nature creates the material. These recipes have been arrived at through trial and error and bit of luck. The results look amazingly close to the real thing, which teaches us that: In 3D graphics, there's nothing like a great fake.
The recipe for the wood texture in Listing 3 is decidedly simple.
The grain value is determined by the noise method using the image row and column as parameters. The color for the image pixel is based on the red, green and blue values calculated with the grain. Creating static texture images with noise is interesting, but the power of noise is even greater when combined with animation.
A Java3D behavior links keyboard, mouse or temporal events with changes to the scene or view. For example, the keyboard or mouse can be used to update the view allowing us to move the virtual camera through the scene. Java3D includes this support with the KeyNavigatorBehavior, MouseRotate, MouseTranslate and MouseZoom behaviors. Time can be used to animate the movement or morph the shape attributes in our scene and Java3D includes subclasses of Interpolator for this as well. While there are a number of behaviors available in Java3D, it's likely you'll eventually need to create your own behavior and Java3D is designed for that.
When a behavior is created, the constructor typically defines the triggering or wake-up condition such as a keyboard or mouse event, a number of frames or the passage of time. Behaviors are added to the scene like any other Java3D object.
When your scene is initially rendered, Java3D calls the initialize() method where your implementation should set the trigger. When Java3D detects the triggering event, it calls the processStimulus() method on your behavior. Your implementation of this method does its thing and then must reset the trigger. The documentation for the Behavior class is excellent, so refer to it for more details.
The ElapsedTimeBehavior example is the basis for the animation examples in this article. When triggered, this behavior calls the tick() method on the configured listener after the specified number of milliseconds has passed. Milliseconds are used as the trigger rather than the number of frames so it runs consistently across different computers. Let's use this behavior to recreate the animation of a movie special effect in Java3D.
|Charles W. Neville 04/01/05 06:13:34 PM EST|
|Mike Jacobs 03/09/05 08:28:35 PM EST|
Stop by at http://mnjacobs.javadevelopersjournal.com/ to help influence future Java3D articles and see what's in the works for next time (assuming JDJ will have me).
The Internet of Everything (IoE) brings together people, process, data and things to make networked connections more relevant and valuable than ever before – transforming information into knowledge and knowledge into wisdom. IoE creates new capabilities, richer experiences, and unprecedented opportunities to improve business and government operations, decision making and mission support capabilities.
Jul. 29, 2015 03:15 PM EDT Reads: 230
The Internet of Things is not only adding billions of sensors and billions of terabytes to the Internet. It is also forcing a fundamental change in the way we envision Information Technology. For the first time, more data is being created by devices at the edge of the Internet rather than from centralized systems. What does this mean for today's IT professional? In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists addressed this very serious issue of profound change in the industry.
Jul. 29, 2015 03:00 PM EDT Reads: 1,251
Discussions about cloud computing are evolving into discussions about enterprise IT in general. As enterprises increasingly migrate toward their own unique clouds, new issues such as the use of containers and microservices emerge to keep things interesting. In this Power Panel at 16th Cloud Expo, moderated by Conference Chair Roger Strukhoff, panelists addressed the state of cloud computing today, and what enterprise IT professionals need to know about how the latest topics and trends affect their organization.
Jul. 29, 2015 02:00 PM EDT Reads: 1,165
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Jul. 29, 2015 01:45 PM EDT Reads: 418
For IoT to grow as quickly as analyst firms’ project, a lot is going to fall on developers to quickly bring applications to market. But the lack of a standard development platform threatens to slow growth and make application development more time consuming and costly, much like we’ve seen in the mobile space. In his session at @ThingsExpo, Mike Weiner, Product Manager of the Omega DevCloud with KORE Telematics Inc., discussed the evolving requirements for developers as IoT matures and conducted a live demonstration of how quickly application development can happen when the need to comply wit...
Jul. 29, 2015 07:30 AM EDT Reads: 275
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at @ThingsExpo, James Kirkland, Red Hat's Chief Architect for the Internet of Things and Intelligent Systems, described how to revolutionize your archit...
Jul. 28, 2015 06:30 PM EDT Reads: 1,375
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society-changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his session at @ThingsExpo, Jason Mondanaro, Director, Product Management at Metanga, discussed how you can plan to cooperate, partner, and form lasting all-star teams to change the world and it starts with business models and monetization strategies.
Jul. 28, 2015 04:30 PM EDT Reads: 1,754
Converging digital disruptions is creating a major sea change - Cisco calls this the Internet of Everything (IoE). IoE is the network connection of People, Process, Data and Things, fueled by Cloud, Mobile, Social, Analytics and Security, and it represents a $19Trillion value-at-stake over the next 10 years. In her keynote at @ThingsExpo, Manjula Talreja, VP of Cisco Consulting Services, discussed IoE and the enormous opportunities it provides to public and private firms alike. She will share what businesses must do to thrive in the IoE economy, citing examples from several industry sectors.
Jul. 28, 2015 11:00 AM EDT Reads: 2,032
Growth hacking is common for startups to make unheard-of progress in building their business. Career Hacks can help Geek Girls and those who support them (yes, that's you too, Dad!) to excel in this typically male-dominated world. Get ready to learn the facts: Is there a bias against women in the tech / developer communities? Why are women 50% of the workforce, but hold only 24% of the STEM or IT positions? Some beginnings of what to do about it! In her Opening Keynote at 16th Cloud Expo, Sandy Carter, IBM General Manager Cloud Ecosystem and Developers, and a Social Business Evangelist, d...
Jul. 27, 2015 09:00 PM EDT Reads: 2,039
There will be 150 billion connected devices by 2020. New digital businesses have already disrupted value chains across every industry. APIs are at the center of the digital business. You need to understand what assets you have that can be exposed digitally, what their digital value chain is, and how to create an effective business model around that value chain to compete in this economy. No enterprise can be complacent and not engage in the digital economy. Learn how to be the disruptor and not the disruptee.
Jul. 27, 2015 10:00 AM EDT Reads: 2,020
Akana has released Envision, an enhanced API analytics platform that helps enterprises mine critical insights across their digital eco-systems, understand their customers and partners and offer value-added personalized services. “In today’s digital economy, data-driven insights are proving to be a key differentiator for businesses. Understanding the data that is being tunneled through their APIs and how it can be used to optimize their business and operations is of paramount importance,” said Alistair Farquharson, CTO of Akana.
Jul. 27, 2015 09:00 AM EDT Reads: 311
Business as usual for IT is evolving into a "Make or Buy" decision on a service-by-service conversation with input from the LOBs. How does your organization move forward with cloud? In his general session at 16th Cloud Expo, Paul Maravei, Regional Sales Manager, Hybrid Cloud and Managed Services at Cisco, discusses how Cisco and its partners offer a market-leading portfolio and ecosystem of cloud infrastructure and application services that allow you to uniquely and securely combine cloud business applications and services across multiple cloud delivery models.
Jul. 27, 2015 08:00 AM EDT Reads: 1,894
The enterprise market will drive IoT device adoption over the next five years. In his session at @ThingsExpo, John Greenough, an analyst at BI Intelligence, division of Business Insider, analyzed how companies will adopt IoT products and the associated cost of adopting those products. John Greenough is the lead analyst covering the Internet of Things for BI Intelligence- Business Insider’s paid research service. Numerous IoT companies have cited his analysis of the IoT. Prior to joining BI Intelligence, he worked analyzing bank technology for Corporate Insight and The Clearing House Payment...
Jul. 26, 2015 09:00 PM EDT Reads: 1,559
In his keynote at 16th Cloud Expo, Rodney Rogers, CEO of Virtustream, discussed the evolution of the company from inception to its recent acquisition by EMC – including personal insights, lessons learned (and some WTF moments) along the way. Learn how Virtustream’s unique approach of combining the economics and elasticity of the consumer cloud model with proper performance, application automation and security into a platform became a breakout success with enterprise customers and a natural fit for the EMC Federation.
Jul. 26, 2015 08:00 AM EDT Reads: 2,141
"Optimal Design is a technology integration and product development firm that specializes in connecting devices to the cloud," stated Joe Wascow, Co-Founder & CMO of Optimal Design, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 02:00 PM EDT Reads: 380
SYS-CON Events announced today that CommVault has been named “Bronze Sponsor” of SYS-CON's 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. A singular vision – a belief in a better way to address current and future data management needs – guides CommVault in the development of Singular Information Management® solutions for high-performance data protection, universal availability and simplified management of data on complex storage networks. CommVault's exclusive single-platform architecture gives companies unp...
Jul. 25, 2015 01:00 PM EDT Reads: 1,945
Electric Cloud and Arynga have announced a product integration partnership that will bring Continuous Delivery solutions to the automotive Internet-of-Things (IoT) market. The joint solution will help automotive manufacturers, OEMs and system integrators adopt DevOps automation and Continuous Delivery practices that reduce software build and release cycle times within the complex and specific parameters of embedded and IoT software systems.
Jul. 25, 2015 12:15 PM EDT Reads: 445
"ciqada is a combined platform of hardware modules and server products that lets people take their existing devices or new devices and lets them be accessible over the Internet for their users," noted Geoff Engelstein of ciqada, a division of Mars International, in this SYS-CON.tv interview at @ThingsExpo, held June 9-11, 2015, at the Javits Center in New York City.
Jul. 25, 2015 12:00 PM EDT Reads: 1,522
Internet of Things is moving from being a hype to a reality. Experts estimate that internet connected cars will grow to 152 million, while over 100 million internet connected wireless light bulbs and lamps will be operational by 2020. These and many other intriguing statistics highlight the importance of Internet powered devices and how market penetration is going to multiply many times over in the next few years.
Jul. 25, 2015 09:00 AM EDT Reads: 1,481
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet conditions, Dyn ensures traffic gets delivered faster, safer, and more reliably than ever.
Jul. 24, 2015 11:00 PM EDT Reads: 2,049