Shader compilation errors

Hi all,

I’m having some problems with the vvvvery cool PhongMultiPoint by joreg. Whenever I change the LightCount to higher than 6, I keeps telling me that I have a compilation error. I’ve googled, but couldn’t find any useful help.

The erros are below:

(88) error X5300: Invalid register number: 10. Max allowed for v# is 9.
(46) error X4502: invalid output semantic ‘TEXCOORD2’ this shows 3 times for each light higher than 6
(141): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed

I know that shaders have limitations and all, but what I want here is to make a room with many independent lights. I’m currently using 5 grids (couldn’t use a box cause the rendering of the light positions was strange).

Another question: how do I know which shader version my video card supports?

Thanks a lot!

Alright, I have found the shader version test patch. I see that the topic is now sticky, also. Nice.

Well, looks like my card supports every version up to 3.0. So, I tried using more than 6 lights with vs_3_0 and it’s still not working. Guess this problem is unsolvable…

unsolvable…iioooaaa…at least by only increasing the lightcount. you could probably simplify the lights algorithm to get more lights working. this would require some understanding of the code though…

Yea, I’m aware. I’ve tried to tweak the code, but it didn’t work out. I’m too newbie for this. :P

Thanks, anyway, joreg. :D

I know it’s convoluted, but maybe you could have seperate renders running, each containing 6 light sources. You would then add their outputs together at the end. You’d need to spend some time tweaking to get the exposure right but in effect, this should be all that having more light sources would do anyway.

So either

  1. bake your render outputs to DX9textures and apply the textures to quads superimposed with blend mode set to “add”
  2. Make a shader which reads in all your textures and outputs an added image
  3. Set the clear mode to 0 on your renderer and render the seperate scenes sequentially (using blend mode=add) into the same renderer and then bang the clear pin when all lights have been rendered. This would flicker a lot and have a pretty slow framerate.

I’d go for option 1, and if performance appears to be an issue, try method 2.

Which gfx card you using?

hey all,

i am new with HLSL. i tried to simple rewrite one NPR Metallic shader from Wolfgang F. Engels “Shader x2 Introductions & Tutorials” in vvvv using the Template. It says NPR Metallic ships with RenderMonkey so i was not sure if this is working. Just tried, got the following error, could not solve that:

(41): error X3017: cannot implicitly convert from ‘float3’ to ‘float4’

question: is it possible to use such HLSL direct in vvvv and, if somebody got the muse to have a look at se code, am i completely wrong with that?

amicalement,
armin

// --------------------------------------------------------------------------------------------------
// PARAMETERS:
// --------------------------------------------------------------------------------------------------

//transforms
float4x4 view_proj_matrix;

float4 view_position;
float4 light0;
float4 light1;
float4 light2;

float4 Material;

sampler Outline;

// --------------------------------------------------------------------------------------------------
// VERTEXSHADERS
// --------------------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 View : TEXCOORD0;
float4 Normal: TEXCOORD1;
float4 Light1: TEXCOORD2;
float4 Light2: TEXCOORD3;
float4 Light3: TEXCOORD4;
};

VS_OUTPUT main ( float4 inPos : POSITION,
float3 inNorm : NORMAL )
{
VS_OUTPUT Out = (VS_OUTPUT) 0;

// Output transformed vertex position:
Out.Pos = mul(view_proj_matrix, inPos);

Out.Normal = inNorm;

// Compute the view vector:
Out.View = normalize(view_position - inPos);

//Compute vectors to three lights from the current vertex position:
Out.Light1 = normalize(light0 - inPos); // Light 1
Out.Light2 = normalize(light1 - inPos); // Light 2
Out.Light3 = normalize(light2 - inPos); // Light 3

return Out;
}

// --------------------------------------------------------------------------------------------------
// PIXELSHADERS:
// --------------------------------------------------------------------------------------------------

float4 main( float3 View: TEXCOORD0,
float3 Normal: TEXCOORD1,
float3 Light1: TEXCOORD2,
float3 Light2: TEXCOORD3,
float3 Light3: TEXCOORD4 ) : COLOR

{
// Normalize input normal vector:
float3 norm = normalize (Normal);

         float4 outline = tex1D(Outline, 1 - dot (norm, normalize(View)));
         
         float lighting = (dot (normalize (Light1), norm) * 0.5 + 0.5) +
                          (dot (normalize (Light2), norm) * 0.5 + 0.5) +
                          (dot (normalize (Light3), norm) * 0.5 + 0.5);
                          
                          return outline * Material * lighting;

}

// --------------------------------------------------------------------------------------------------
// TECHNIQUES:
// --------------------------------------------------------------------------------------------------

technique TSimpleShader
{
pass P0
{
//Wrap0 = U; // useful when mesh is round like a sphere
VertexShader = compile vs_1_1 VS();
PixelShader = compile ps_2_0 PS();
}
}

hola amin,

attached you see a simple patch and the ~working shader. not sure if that is the desired look though.

i really wonder if this is a working rendermonkey shader. several things look odd to me, i’d say this is not a very didactically written shader. anyway. things that had to be changed:

  • float4x4 view_proj_matrix; and float4 view_position; got they respective semantics: WORLDVIEWPROJECTION, CAMERAPOSITION
  • this line: Out.Pos = mul(view_proj_matrix, inPos); needs swapped arguments like: Out.Pos = mul(inPos, view_proj_matrix); (this is maybe due to different handedness of dx and opengl coordinate systems?)
  • the error you encountered: in the VS_OUTPUT struct the Normal that goes to TexCoord1 needs to be a float3 (was float4)
  • added a texture to the Outline Sampler so you can attach a FileTexture node
  • changed names of vertex- and pixelshader functions to VS() and PS() as they are addressed in the technique.
  • changed the light parameters to float3 (was float4) as a light position only has 3 (xyz) not 4 components.

voila.

amins.zip (2.6 kB)

hello joreg,
thanks for that, it’s working. your corrections explain a lot to me. i can say nothing about the look because there was just code without visual examples.
best, armin.