Not logged in, Join Here! or Log In Below:  
News Articles Search    

Submitted by Cuban, posted on March 02, 2001

Image Description, by Cuban

This is the result of my first foray into D3D Vertex Shaders. It's the regular D3DXTeapot, rendered with three projective textures. One is a rotating fan-like texture, one a static vent-like texture, the other is a moving texture (the DirectX 'X'). The inspiration for making this was the Doom3 video shown at MacWorld the other day. Code-side I spend some time setting up projection matrices for each of the spot lights, set a few vertex shader constants, and then just render the mesh 3 times with alpha blending. Texture coordinates are generated given the object-space coordinates, they're clamped to the texture boundaries, and the texture is also multiplied by N*L (N=Vertex Normal, L=Light Vector) to get a nice falloff on the edges.

The DX8 binary is here:

The code for the vertex shader is included. Pretty standard, and probably grossly inefficient in register usage (hey, it's the first assembly code I've written in years). Makes for a purty app tho.


Image of the Day Gallery


Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
Mike Taylor

March 02, 2001, 05:30 PM

So Cuban, what's up with the cubonics website?

-Mike Taylor


March 02, 2001, 06:20 PM

lol, it still beats consoles in many ways though =)


March 02, 2001, 06:25 PM

so I migrated servers recently, and the account on the new server for cubonics isn't set up right now so I can't edit it. The state of the website was from a backup the admin made like in june of last year, hence the horrendous out-of-date-ness. sigh. hopefully it'll get resolved in a few more days.

zed zeek

March 02, 2001, 07:00 PM

i notice quite a few ppl were having problems with this demo u might wanna have a look here (about halfway down the page) btw it doesnt change your screen resolution ;)

James Fingleton

March 02, 2001, 07:25 PM

For this demo to work, you have to have a card that supports a stencil buffer...For some cards, such as TNT2's, you have to set your desktop bpp to 32 instead of 16 to enable the stencil buffer.

Hope this helps.


March 02, 2001, 08:29 PM

"For this demo to work, you have to have a card that supports a stencil buffer..."

You do? This doesn't use a stencil buffer.


Jonathan Tanner

March 02, 2001, 08:35 PM

Well, I don't really have the time to go into the full details, but the general idea is to take the benefit of both hardware and software rendering and merge them together.

In short, rendering in hardware is always going to outperform software rendering. I hope that much is obvious. However, hardware, by its very nature, is inflexible. This leads to limited feature sets and somewhat stagnate rendering (i.e. everything rendered with a certain card tends to look similar). In software, you can do pretty much whatever you can think of without being restricted by hardware, but the cost of rendering is so high that it's near impossible to do high quality real time rendering in software.

This is where pixel shaders and vertex shaders come in. Once you boil down the hype, what you find is that these shaders are nothing more than highly specialized, programmable hardware. Now, instead of having the graphics card handle your data in whatever manner it sees fit, you can control parts of the rendering pipeline yourself.

The leader in this right now is nVidia, so check out the developer's section at their web site ( They have several whitepapers of interest their. Also, look at the DirectX 8.0 SDK. It was created right alongside nVidia's NV20 architecture (X-Box, GeForce3) so you can see how shaders fit in with the normal rendering pipeline.

Kurt Miller

March 02, 2001, 08:59 PM

Cuban posted a new version with stencil shadows, as mentioned in this post.

The old version worked fine in 16-bit mode on my TNT2. The new version crashes in 16-bit mode (presumably because of the stencil buffer), but works fine in 32-bit mode.


March 02, 2001, 11:58 PM

This ran pretty fast on my GeForce...

Al Reed

March 03, 2001, 01:19 AM

The new one crashes for me too, the old one worked fine.

Win2k, p3-500, ATI Radeon 64.

Probably ATIs stellar drivers at work. None-the-less, damn pretty demo.


March 03, 2001, 03:27 AM

Im running win2k pro and a geforce 256 ddr with a p3 600 and 128mb of ram and it runs just fine. The Esc key works fine also. I get very good framerates. When using shadows is does slow down a bit, but the fps is still very good.



March 03, 2001, 08:08 AM

It looks very horrible nice(what I mean ?)
I'm still not sure that I know who drops a shadow, or it's just zebra-style ...
It would be interesting how do you perform texture mapping/wrapping. Any sources ?

After testing your demo:
I've got the same msg
The instruction at "0x004012b1" referenced memory at "0x000000". The memory could not be "read"
I know that's usual message in win2k which appears when application goes behind it's memory bounds
If u're developing app in win98, this error may not appear.
In fact, this may be cause of using not initialized variable with no assigned initial value. In win98 this value automatically is zero(mbe not in all cases, I can't guarantee), however in win2k that behaviour is different.

James Fingleton

March 03, 2001, 08:21 AM

Surley the 'Stencil Shadows' are using the stencil buffer???


March 03, 2001, 08:41 AM

That's should be a must, especially if it's intended to show in public, and it's absolutely clear that everybody will have different configurations.


March 03, 2001, 12:44 PM

Worked good on my Rage Fury, but since the card is showing it's age runs a little slow, really bogs down when I turn on the stencil shadows. All in all, cool piece of work.

Just so you can add to working systems if you want:
Celeron 366
Win2K Pro
ATI Rage Fury AGP


March 03, 2001, 01:08 PM


Yeah, I know what you mean.
Just hope that I can get my ideas to some real future chip. ;)


Hehe, as you well know I have and the innerloops run average
1/3 faster on Athlon than on P3. (You know allso that I have
P3 ;)
Put that doesn't change the fact that x86 is bad design and
MMX sux and it really hard to use on anything serious graphics.
And the PC is still lacking of a good OS. :)

But I'm going to spend some serious $$$ on G4 or something based
thing and that altivect rules. ;)


March 03, 2001, 02:02 PM

"Surley the 'Stencil Shadows' are using the stencil buffer???"

Ah, you're right... he must have added the stencil shadows after I checked out the demo.


Stu Milsten

March 22, 2001, 03:53 AM

A friend of mine told me to go look at Image of the Day.

So I did.

And you know what? It sucked ass.

So I decided to waste more time and let you sucked ass.


This thread contains 48 messages.
First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.