|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 Outlyer, a monitoring service for DevOps and operations teams, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Outlyer is a monitoring service for DevOps and Operations teams running Cloud, SaaS, Microservices and IoT deployments. Designed for today's dynamic environments that need beyond cloud-scale monitoring, we make monitoring effortless so you...
Feb. 19, 2017 11:30 AM EST Reads: 819
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend @CloudExpo | @ThingsExpo, June 6-8, 2017, at the Javits Center in New York City, NY and October 31 - November 2, 2017, Santa Clara Convention Center, CA. Learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Feb. 19, 2017 11:15 AM EST Reads: 1,572
Have you ever noticed how some IT people seem to lead successful, rewarding, and satisfying lives and careers, while others struggle? IT author and speaker Don Crawley uncovered the five principles that successful IT people use to build satisfying lives and careers and he shares them in this fast-paced, thought-provoking webinar. You'll learn the importance of striking a balance with technical skills and people skills, challenge your pre-existing ideas about IT customer service, and gain new in...
Feb. 19, 2017 11:15 AM EST Reads: 1,632
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buyers...
Feb. 19, 2017 11:00 AM EST Reads: 1,532
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, Cloud Expo and @ThingsExpo are two of the most important technology events of the year. Since its launch over eight years ago, Cloud Expo and @ThingsExpo have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, I provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading the...
Feb. 19, 2017 10:45 AM EST Reads: 7,621
While not quite mainstream yet, WebRTC is starting to gain ground with Carriers, Enterprises and Independent Software Vendors (ISV’s) alike. WebRTC makes it easy for developers to add audio and video communications into their applications by using Web browsers as their platform. But like any market, every customer engagement has unique requirements, as well as constraints. And of course, one size does not fit all. In her session at WebRTC Summit, Dr. Natasha Tamaskar, Vice President, Head of C...
Feb. 19, 2017 10:30 AM EST Reads: 6,511
In the enterprise today, connected IoT devices are everywhere – both inside and outside corporate environments. The need to identify, manage, control and secure a quickly growing web of connections and outside devices is making the already challenging task of security even more important, and onerous. In his session at @ThingsExpo, Rich Boyer, CISO and Chief Architect for Security at NTT i3, will discuss new ways of thinking and the approaches needed to address the emerging challenges of securit...
Feb. 19, 2017 09:45 AM EST Reads: 1,141
TechTarget storage websites are the best online information resource for news, tips and expert advice for the storage, backup and disaster recovery markets. By creating abundant, high-quality editorial content across more than 140 highly targeted technology-specific websites, TechTarget attracts and nurtures communities of technology buyers researching their companies' information technology needs. By understanding these buyers' content consumption behaviors, TechTarget creates the purchase inte...
Feb. 19, 2017 09:45 AM EST Reads: 730
As cloud adoption continues to transform business, today's global enterprises are challenged with managing a growing amount of information living outside of the data center. The rapid adoption of IoT and increasingly mobile workforce are exacerbating the problem. Ensuring secure data sharing and efficient backup poses capacity and bandwidth considerations as well as policy and regulatory compliance issues.
Feb. 19, 2017 09:15 AM EST Reads: 1,563
Almost two-thirds of companies either have or soon will have IoT as the backbone of their business. Though, IoT is far more complex than most firms expected with a majority of IoT projects having failed. How can you not get trapped in the pitfalls? In his session at @ThingsExpo, Tony Shan, Chief IoTologist at Wipro, will introduce a holistic method of IoTification, which is the process of IoTifying the existing technology portfolios and business models to adopt and leverage IoT. He will delve in...
Feb. 19, 2017 09:15 AM EST Reads: 1,015
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of SYS-CON's 20th International Cloud Expo, which will take place on June 6–8, 2017, at the Javits Center in New York City, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great dea...
Feb. 19, 2017 07:45 AM EST Reads: 1,672
SYS-CON Events announced today that LeaseWeb USA, a cloud Infrastructure-as-a-Service (IaaS) provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. LeaseWeb is one of the world's largest hosting brands. The company helps customers define, develop and deploy IT infrastructure tailored to their exact business needs, by combining various kinds cloud solutions.
Feb. 19, 2017 07:30 AM EST Reads: 1,401
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
Feb. 19, 2017 05:45 AM EST Reads: 4,723
WebRTC defines no default signaling protocol, causing fragmentation between WebRTC silos. SIP and XMPP provide possibilities, but come with considerable complexity and are not designed for use in a web environment. In his session at @ThingsExpo, Matthew Hodgson, technical co-founder of the Matrix.org, discussed how Matrix is a new non-profit Open Source Project that defines both a new HTTP-based standard for VoIP & IM signaling and provides reference implementations.
Feb. 19, 2017 05:00 AM EST Reads: 4,666
The Internet of Things is clearly many things: data collection and analytics, wearables, Smart Grids and Smart Cities, the Industrial Internet, and more. Cool platforms like Arduino, Raspberry Pi, Intel's Galileo and Edison, and a diverse world of sensors are making the IoT a great toy box for developers in all these areas. In this Power Panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists discussed what things are the most important, which will have the most profound e...
Feb. 19, 2017 04:00 AM EST Reads: 10,974
We all know that data growth is exploding and storage budgets are shrinking. Instead of showing you charts on about how much data there is, in his General Session at 17th Cloud Expo, Scott Cleland, Senior Director of Product Marketing at HGST, showed how to capture all of your data in one place. After you have your data under control, you can then analyze it in one place, saving time and resources.
Feb. 19, 2017 03:00 AM EST Reads: 3,819
910Telecom exhibited at the 19th International Cloud Expo, which took place at the Santa Clara Convention Center in Santa Clara, CA, in November 2016. Housed in the classic Denver Gas & Electric Building, 910 15th St., 910Telecom is a carrier-neutral telecom hotel located in the heart of Denver. Adjacent to CenturyLink, AT&T, and Denver Main, 910Telecom offers connectivity to all major carriers, Internet service providers, Internet backbones and exchanges.
Feb. 19, 2017 02:30 AM EST Reads: 1,289
SYS-CON Events announced today that Linux Academy, the foremost online Linux and cloud training platform and community, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Linux Academy was founded on the belief that providing high-quality, in-depth training should be available at an affordable price. Industry leaders in quality training, provided services, and student certification passes, its goal is to c...
Feb. 19, 2017 02:30 AM EST Reads: 759
Web Real-Time Communication APIs have quickly revolutionized what browsers are capable of. In addition to video and audio streams, we can now bi-directionally send arbitrary data over WebRTC's PeerConnection Data Channels. With the advent of Progressive Web Apps and new hardware APIs such as WebBluetooh and WebUSB, we can finally enable users to stitch together the Internet of Things directly from their browsers while communicating privately and securely in a decentralized way.
Feb. 19, 2017 01:15 AM EST Reads: 3,920
The IoT industry is now at a crossroads, between the fast-paced innovation of technologies and the pending mass adoption by global enterprises. The complexity of combining rapidly evolving technologies and the need to establish practices for market acceleration pose a strong challenge to global enterprises as well as IoT vendors. In his session at @ThingsExpo, Clark Smith, senior product manager for Numerex, discussed how Numerex, as an experienced, established IoT provider, has embraced a new m...
Feb. 19, 2017 12:45 AM EST Reads: 2,871