farbrausch/fr_public — pull request #80 by wzman (2012-10-25 09:30:24+00:00)
Title: wz4: customMaterial, fix to support textures

Hi

Here a fix for CustomMaterial to supports 16 textures on input. I rewrote the CustomMaterial ops so I declare the previous as hidden and obsolete.

Note : CustomMaterial actually doesn't support node matrix transformations (yellow op, transform, multiply, lookat,...) It will need a fix.

And in prevision to animate customMetarial shader variables, it will need an animator node to update values.

Here a simple exemple of vertex and pixel shader code to use textures :

vertex shader
------------------

void main
(
in float3 in_pos : POSITION,
in float2 in_uv0 : TEXCOORD0,
out float2 out_uv0 : TEXCOORD0,
out float4 out_pos : POSITION
)
{
out_uv0 = in_uv0;
out_pos = mul(float4(in_pos,1),mvp);
}

pixel shader
------------------

sampler2D s0 : register(s0); // texture 0
sampler2D s1 : register(s1); // texture 1
sampler2D s2 : register(s2); // texture 2
//... s0 to s15

void main
(
in float2 uv0 : TEXCOORD0,
out float4 r : COLOR0
)
{
r = tex2D(s0, uv0); // use texture 0
}