Game Development Community

Brick Shader

by Anthony Rosenbaum · in Torque Game Engine Advanced · 06/26/2004 (7:11 am) · 22 replies

Over the past few days I've been working on a Brick shader. However I have come into some problems. First off my card supports vs1.1 and ps 1.1 shaders. The Brick algorithm I found requires the texCoord to be past to the pixel shader. The brick color is determined from the current TexCoord.

I am not sure if I am missing something or doing it wrong but I keep getting errors pertaining to the passed texcoords. If I pass a copy of the texcoords into a TEXCOORD1 semantic I get this error in the fragment shader

Quote:
warning X4704: literal values outside range -1 to 1 are clamped on all ps_1_x shading models
warning X4704: literal values outside range -1 to 1 are clamped on all ps_1_x shading models
warning X4704: literal values outside range -1 to 1 are clamped on all ps_1_x shading models
error X4507: program too complex: exceeded available constant registers.

If I use the actual texcoord passes in TEXCOORD0 I get this error. also in the fragment shader
Quote:
error X4520: can read from texcoord and use it for texlookup only in ps_1_4 and higher

Other things to note, how do we write const variables in? or alternate uniform or varying variables in my case brick height, mortar size, and color. Right now I am declaring them as another local variables inside the fragment shader which I think is consuming precious fragment operations.

I had used the algorithm in the vertex shader but it didn't want to work there either ( I think because there are only 4 vertex/side, ie not enough data )

Is it even possible to achomplish on this level of shader?

Anthony
Page«First 1 2 Next»
#21
10/20/2004 (3:50 am)
Anthony did you learn shader programming with a book or just by reading on the internet? Got some links for me?
thx
#22
10/20/2004 (7:39 am)
Via books, the CG book is excellent CG is similar to HLSL which torque uses. The brick shader was actually an algorith from the Open GL Shader Language book ( the orange one) which I ported over to HLSL. ie changed some function names. Do a query at amazon for shaders and you will find several book on this topic. Shader themselves are a very simple concept. The trick is preparing the right constants to be used for specific shaders such as my brickColor/ mortarColor constants.
Page«First 1 2 Next»