| Related sites for http://dunnbypaul.net/perlin/ |
| Praedea_Solutions,_Inc_ Develops and licenses universal enterprise software solutions providing real-time data extraction from financial/SEC filings and other documents. | | TRON_Project Growing article, with links to many related topics. Wikipedia. | | Batprint A batch printing tool for Microsoft Excel. | | Visionet_Systems Offers e-Business solutions, Domino, Lotus Notes, net dynamics, Java Workflow, Enterprise Java Beans, and Y2K AS/400 conversion. | | USPS_Section_508_Handbook_in_HTML Explains the requirements of Section 508 and sets forth, in broad outline, the Postal Service's policies on how to comply with them. | | HTML_Help_-_Using_Merge Tutorial on getting merged CHM files working correctly. By The Helpware Group. | | kirchner_SOFT Products include logiCAD software the target-system-neutral graphical programming system for automation devices based on IEC 61131-3. | | SigmaPi_Design Company presents a new approach to digital image processing, shareware image editor and painter. Perform almost any action through brush movement. Offers tutorials, FAQs, forum, gallery, contacts, and | | ColorImpact_-_Interactive_Color_Wheel Interactive tool for designing harmonious color schemes. Aimed at professional multimedia and web designers, the program includes features to integrate with graphic programs and HTML editors. [Windows | | Auto_IP_Scanner Scan your PC for open ports ( Http, Https, Ftp, Dns, MySql, Imap, Smtp, Pop, Dc++, Irc). | | Systems_Encore__-_Financial_Software_Solutions Suppliers of Sage Line 200, Line 100, Premier, IBM/Compaq servers and PCs. We also supply Internet/E-mail solutions based on Backoffice. Based in Northern Ireland | | RFC_2048_-_Multipurpose_Internet_Mail_Extensions_(MIME)_-_Part_4 Specifies various IANA registration procedures for MIME media types, MIME external body access types, and MIME content-transfer-encodings. | | Tour_Factory Virtual Tour service. Realtors can choose from full service or self managed options. | | Mpegable DirectShow filter suite from Dicas to decode MP4 and 3GP files or RTP streams of MPEG-4 content, also available as a standalone player application. | | PeopleSoft-L_Technical_Discussion The PEOPLESOFT-L mail list is for the technical and functional discussion of PeopleSoft applications. | | Linux_Today__Emmett_Plant_-_The_Welcome_Wagon Urges initiative and good manners to promote open source. | | Electronic_Books_for_All Glassbook will offer a standard way to download e-books from bookstores or libraries. [PC World] (May 7, 1999) | | Rocket_Designs Firm based in Sydney, Australia. Offers web site design, maintenance and marketing. | | Nomad_Programming OpenGL Math and Win32 Tutorials, Demos, Links, Projects. (May 20, 2004) | | Dinky_AutoComplete_Tool_(DACT) A small, neat component that provides the AutoComplete feature to any .NET Framework Windows Forms application. It features point-and-click integration and design-time support - no coding necessary. |
|
Hardware Perlin Noise Demonstration
function adsize() {
var sw = window.screen.width;
var sh = window.screen.height;
var cw = document.body.clientWidth;
var ch = document.body.clientHeight;
document.getElementById("sizead").src = "http://dunnbypaul.net/sizelog/?site=perlin&size="+sw+"x"+sh+"+"+cw+"x"+ch;
}
HARDWARE PERLIN NOISE DEMONSTRATION
by Paul R. Dunn
Perlin noise can be used to make some very impressive looking cloud effects,
but at a substantial cost of processing power. Here is some code that I wrote after
experimenting with Perlin noise. I realized that by using the texture blending
characteristics of todays 3D graphics hardware, you could generate similar effects
on the graphics card and move the burden away from the CPU. And what a heavy burden that is!
This function utilizes a pre-made noise texture and renders it in several passes to
a render surface. The render surface ends up with a texture that resembles perlin
noise and it can be animated like Perlin noise (or rendered into a 3rd dimension like
Perlin noise). The algorithm it turns out, is very simple and uses virtually no CPU.
That's because all of the work is being done on the graphics card. Many graphics engines
could benefit from creating foggy or fiery textures this way rather than on the CPU.
A sample of code follows that was written in C++ with the DirectX9 SDK. The entire application
that this function was extracted from can be downloaded in binary (executable) format here
<HWPerlin.exe> (72KB). It will run on windows
systems with DirectX9 and a 3D card installed. Run the app and press the 'N' key to toggle through
the 3 render styles or 'type's. It generates a texture 512x512 pixels and animates it.
Compare that app to this one
<ClassicPerlin.exe> (56KB)
which generates a texture 256x256 pixels (stretched to 512x512) and is not as smoothly animated.
It is more taxing on the CPU.
Compared with algorithms that generate Perlin noise on the CPU, this algorithm can generate higher
resolution textures and animate them faster just because a CPU isn't designed to handle the kind of
high volume parallel processing that a pixel processor offers.
These images taken from the app at 512x512 were reduced to 256x256 for web publication:
Base Noise: this noise pattern was generated once in the app.
Perlin Noise: this pattern was generated by multi texturing the base noise.
Perlin Noise: each layer was offset differently to produce this pattern.
The primary texture blending function:
/**************************************
pOutputTex is an IDirect3DTexture9* that will be filled with the Perlin noise.
It can later be mapped onto a mesh.
pNoiseTex is a texture filled with a standard noise algorithm. In this program,
I generated one pNoiseTex at the beginning of
the application and used it throughout.
GRIDSIZE is the width and height of the output texture pOutputTex
**************************************/
void NoiseClass::Advance(int type)
{
HRESULT hr;
IDirect3DDevice9* pD3DDev = pRasDev->GetDevice();
DWORD FVF_pV = D3DFVF_XYZRHW | D3DFVF_TEX1;
struct _pV
{
FLOAT x,y,z,rhw;
FLOAT tu,tv;
};
float flim = GRIDSIZE;
_pV pV[] = {
{ 0.f, 0.f, 0.f,1.f, 0.f,0.f },
{ 0.f,flim, 0.f,1.f, 0.f,1.f },
{ flim, 0.f, 0.f,1.f, 1.f,0.f },
{ flim,flim, 0.f,1.f, 1.f,1.f },
};
IDirect3DSurface9* pSurface;
hr = pOutputTex->GetSurfaceLevel(0,&pSurface);
printerr("GetSurfaceLevel",hr);
hr = pD3DDev->SetRenderTarget(0,pSurface);
printerr("SetRenderTarget",hr);
pD3DDev->SetFVF( FVF_pV );
pD3DDev->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x00000000,1.f,0);
pD3DDev->BeginScene();
// pNoiseTex is just a basic random noise texture
pD3DDev->SetTexture(0,pNoiseTex);
switch (type)
{
default:
case 0:
// standard
pD3DDev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
pD3DDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
break;
case 1:
// deeper contrast
pD3DDev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_ADDSIGNED );
pD3DDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pD3DDev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE );
break;
case 2:
// darker or less dense
pD3DDev->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SUBTRACT );
pD3DDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
pD3DDev->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TEXTURE | D3DTA_COMPLEMENT );
break;
}
// use alpha channel to cut ampitude in half while frequency doubles
pD3DDev->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
pD3DDev->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
// no more texture stages, 1 is enough!
pD3DDev->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
pD3DDev->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
// standard alpha blending, nothing fancy
pD3DDev->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
pD3DDev->SetRenderState( D3DRS_BLENDOP, D3DBLENDOP_ADD );
pD3DDev->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
pD3DDev->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
// make the texture map properly
pD3DDev->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE);
pD3DDev->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
pD3DDev->SetSamplerState( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP );
pD3DDev->SetSamplerState( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP );
static float time = 50.f; // start with a non-zero value
while (time>1024.f) time-=1024.f; // keep time normalized
// the main blending loop: makes pretty perlin noise out of messy random noise
int count = 0;
float scf = 1.f/GRIDSIZE; // scale factor (or frequency of noise)
float shft;
int txf = 0xff; // texture factor (or amplitude of noise)
while (scf0)
{
count++;
shft = time*powf(scf,1.5f) * (GRIDSIZE/1024.f);
pD3DDev->SetRenderState( D3DRS_TEXTUREFACTOR, (txf |
|