Hit a brick wall with HLSL..

All:

Well, I'll finish reading the book but I'll limit my playing around with HLSL as I'm not able to even get my first real shader to compile. I'm running out of instructions and this is going to be a pain in the you-know-what getting it to work. I suppose I could break it down into multiple passes, but I haven't learned how to do that yet.:(

Perhaps I'll wait till they get the hardware to the point where the number of instructions won't matter.

-M
 
You can try and compile for vs_2_sw or ps_2_sw to see how much over the limit you are, or to run your shaders on ref device.
 
Yea, I compiled under ps_2_0 and I'm at 84 instructions where the limit is 64 instructions. I haven't even put in specular highlighting in the lighting model yet!

-M
 
Mr. Blue said:
A procedural-based spline reflection lighting model shader. It's the one in the Texturing&Modeling book.
The one by Ebert, Musgrave, Peachy, Perlin, and Worley? If so, which page? (Mind you I might only have the first edition!)
 
Simon F said:
Mr. Blue said:
A procedural-based spline reflection lighting model shader. It's the one in the Texturing&Modeling book.
The one by Ebert, Musgrave, Peachy, Perlin, and Worley? If so, which page? (Mind you I might only have the first edition!)

Yes, I have the 3rd edition. Page 34-37 describes this algorithm.

-M
 
Mr. Blue said:
Simon F said:
Mr. Blue said:
A procedural-based spline reflection lighting model shader. It's the one in the Texturing&Modeling book.
The one by Ebert, Musgrave, Peachy, Perlin, and Worley? If so, which page? (Mind you I might only have the first edition!)

Yes, I have the 3rd edition. Page 34-37 describes this algorithm.
-M
Oh well, never mind. I can't be bothered upgrading the book :)
 
Simon F said:
Mr. Blue said:
Simon F said:
Mr. Blue said:
A procedural-based spline reflection lighting model shader. It's the one in the Texturing&Modeling book.
The one by Ebert, Musgrave, Peachy, Perlin, and Worley? If so, which page? (Mind you I might only have the first edition!)

Yes, I have the 3rd edition. Page 34-37 describes this algorithm.
-M
Oh well, never mind. I can't be bothered upgrading the book :)

Simon, it was in the previous 2 version as well. Sortof in the beginning.

-M
 
Mr. Blue said:
Yea, I compiled under ps_2_0 and I'm at 84 instructions where the limit is 64 instructions. I haven't even put in specular highlighting in the lighting model yet!
I started to play with the shader for just a bit yesterday. I'm sure it will fit - comfortably. Unfortunately, I'll not be able to finish it today, but will get back to it early next week.

BTW, it's a simple shader, but interesting on several levels.

-mr. bill
 
I don't have the answer for Render-Monkey, but with the simple editor that nVidia's using for its labs I've already passed the 512 instructions mark... All that's needed is to use the 3_0 profile, that works perfectly on my mere FX5600. I don't know if or how well it works with ATI cards however.

Probably RenderMonkey have an equivalent profile?

Just my 2 cents...
 
OK, just an outline of my 1.0000001 pass shader.

I found if I tried to unpack the knot vectors into red, green, and blue knots and then multiply by the basis matrix per pixel (per fragment in OpenGL terminology) I wasted a whole bunch of moves.

Also, it seemed a waste to select the four nearest knots per pixel(fragment).

Instead, I stored the knot vectors in 3 textures - red, green, blue, (or as an optimization, a single texture.)


I'll outline the knot vectors in three textures first.


The first texel of the red texture will have the RED component of the 1st, 2nd, 3rd and 4th knots. The second texel will have the RED component of the 2nd, 3rd, 4th, and 5th knots. And so on.

Same thing for the green texture and blue texture.

Optimization - instead of 3 1D textures, pack the knots into 1 2D texture.
(Grumble grumble, pack them into power of 2 textures as well.)

Instead of a simple scale and bias of 0.5 * altiitude + 0.5, I set the scale and bias to address the appropriate texel. In this way, I always automatically fetch the four nearest knots.

To find where I am in the span it's just a simple frac of scaled and biased altitude * the width of the texture.

Now, in a single POINT SAMPLE fetch of a texel we can get the RED component of the four knots. Two more POINT SAMPLE fetches get the green and blue components.


Other thing to think about, INSTEAD of transforming per pixel(fragment) the reflection vector back to world space and taking the z component, transform the world up vector to eye space (once per frame or, if you are feeling wasteful, once per vertex) and dot it with the reflection vector. Same result, but much more effficiently.


Why is it a 1.0000001 pass shader? I used a simple image editing ap to store my knots knot1.rgb, knot2.rgb, knot3.rgb, knot4.rgb. I wrote a simple shader to source that texture and render to texture as knot1234.r, knot2345.r, knot3456.r and so on. That shader only needs to run when the knot texture is updated.

-mr. bill
 
Back
Top