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();
}
}