|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).
SYS-CON Events announced today that ContentMX, the marketing technology and services company with a singular mission to increase engagement and drive more conversations for enterprise, channel and SMB technology marketers, has been named “Sponsor & Exhibitor Lounge Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York City, New York. “CloudExpo is a great opportunity to start a conversation with new prospects, but what happens after the...
May. 29, 2016 04:45 PM EDT Reads: 1,307
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, will discuss the importance of WebRTC and how it enables companies to fo...
May. 29, 2016 04:15 PM EDT Reads: 2,573
SYS-CON Events announced today Object Management Group® has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
May. 29, 2016 04:00 PM EDT Reads: 2,632
The IoT is changing the way enterprises conduct business. In his session at @ThingsExpo, Eric Hoffman, Vice President at EastBanc Technologies, discuss how businesses can gain an edge over competitors by empowering consumers to take control through IoT. We'll cite examples such as a Washington, D.C.-based sports club that leveraged IoT and the cloud to develop a comprehensive booking system. He'll also highlight how IoT can revitalize and restore outdated business models, making them profitable...
May. 29, 2016 02:00 PM EDT Reads: 2,961
The IoTs will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, will demonstrate how to move beyond today's coding paradigm and share the must-have mindsets for removing complexity from the development proc...
May. 29, 2016 01:00 PM EDT Reads: 1,980
Customer experience has become a competitive differentiator for companies, and it’s imperative that brands seamlessly connect the customer journey across all platforms. With the continued explosion of IoT, join us for a look at how to build a winning digital foundation in the connected era – today and in the future. In his session at @ThingsExpo, Chris Nguyen, Group Product Marketing Manager at Adobe, will discuss how to successfully leverage mobile, rapidly deploy content, capture real-time d...
May. 29, 2016 12:45 PM EDT Reads: 1,681
What a difference a year makes. Organizations aren’t just talking about IoT possibilities, it is now baked into their core business strategy. With IoT, billions of devices generating data from different companies on different networks around the globe need to interact. From efficiency to better customer insights to completely new business models, IoT will turn traditional business models upside down. In the new customer-centric age, the key to success is delivering critical services and apps wit...
May. 29, 2016 10:30 AM EDT Reads: 1,285
Join us at Cloud Expo | @ThingsExpo 2016 – June 7-9 at the Javits Center in New York City and November 1-3 at the Santa Clara Convention Center in Santa Clara, CA – and deliver your unique message in a way that is striking and unforgettable by taking advantage of SYS-CON's unmatched high-impact, result-driven event / media packages.
May. 29, 2016 10:00 AM EDT Reads: 2,537
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, will provide an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life ...
May. 29, 2016 09:45 AM EDT Reads: 2,040
SYS-CON Events announced today that BMC Software has been named "Siver Sponsor" of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2015 at the Javits Center in New York, New York. BMC is a global leader in innovative software solutions that help businesses transform into digital enterprises for the ultimate competitive advantage. BMC Digital Enterprise Management is a set of innovative IT solutions designed to make digital business fast, seamless, and optimized from mainframe to mo...
May. 29, 2016 09:30 AM EDT Reads: 2,310
SYS-CON Events announced today that MobiDev will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business managers to a full-scale mobile software company with over 200 develope...
May. 29, 2016 08:15 AM EDT Reads: 2,761
SoftLayer operates a global cloud infrastructure platform built for Internet scale. With a global footprint of data centers and network points of presence, SoftLayer provides infrastructure as a service to leading-edge customers ranging from Web startups to global enterprises. SoftLayer's modular architecture, full-featured API, and sophisticated automation provide unparalleled performance and control. Its flexible unified platform seamlessly spans physical and virtual devices linked via a world...
May. 29, 2016 07:00 AM EDT Reads: 2,309
SYS-CON Events announced today that Alert Logic, Inc., the leading provider of Security-as-a-Service solutions for the cloud, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Alert Logic, Inc., provides Security-as-a-Service for on-premises, cloud, and hybrid infrastructures, delivering deep security insight and continuous protection for customers at a lower cost than traditional security solutions. Ful...
May. 29, 2016 06:45 AM EDT Reads: 2,961
Companies can harness IoT and predictive analytics to sustain business continuity; predict and manage site performance during emergencies; minimize expensive reactive maintenance; and forecast equipment and maintenance budgets and expenditures. Providing cost-effective, uninterrupted service is challenging, particularly for organizations with geographically dispersed operations.
May. 29, 2016 06:00 AM EDT Reads: 2,178
As cloud and storage projections continue to rise, the number of organizations moving to the cloud is escalating and it is clear cloud storage is here to stay. However, is it secure? Data is the lifeblood for government entities, countries, cloud service providers and enterprises alike and losing or exposing that data can have disastrous results. There are new concepts for data storage on the horizon that will deliver secure solutions for storing and moving sensitive data around the world. ...
May. 29, 2016 06:00 AM EDT Reads: 1,361
SYS-CON Events announced today TechTarget has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget is the Web’s leading destination for serious technology buyers researching and making enterprise technology decisions. Its extensive global networ...
May. 29, 2016 05:15 AM EDT Reads: 3,278
SYS-CON Events announced today that Commvault, a global leader in enterprise data protection and information management, has been named “Bronze Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Commvault is a leading provider of data protection and information management...
May. 29, 2016 04:30 AM EDT Reads: 3,259
SYS-CON Events announced today that MangoApps will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. MangoApps provides modern company intranets and team collaboration software, allowing workers to stay connected and productive from anywhere in the world and from any device. For more information, please visit https://www.mangoapps.com/.
May. 29, 2016 03:30 AM EDT Reads: 1,005
The essence of data analysis involves setting up data pipelines that consist of several operations that are chained together – starting from data collection, data quality checks, data integration, data analysis and data visualization (including the setting up of interaction paths in that visualization). In our opinion, the challenges stem from the technology diversity at each stage of the data pipeline as well as the lack of process around the analysis.
May. 29, 2016 02:45 AM EDT Reads: 1,507
Designing IoT applications is complex, but deploying them in a scalable fashion is even more complex. A scalable, API first IaaS cloud is a good start, but in order to understand the various components specific to deploying IoT applications, one needs to understand the architecture of these applications and figure out how to scale these components independently. In his session at @ThingsExpo, Nara Rajagopalan is CEO of Accelerite, will discuss the fundamental architecture of IoT applications, ...
May. 29, 2016 02:00 AM EDT Reads: 1,355