HLSL Vertex Textures in V5
Posted: 27 Jun 2016, 12:58
Hi,
I was wondering how to use vertex textures in HLSL shaders in V5... In V4 you were able to define the texture stage as Vertex1 or Vertex2.
Was this changed to the displacement map stage (would make most sense)? I tried with this code snippet, but it looks like the texture isn't sampled at all (no displacement):
float4x4 WorldViewProjection : WORLDVIEWPROJECTION;
sampler Vertex1 : register(s0);
float lod=0;
// Vertex shader program input
struct VS_INPUT
{
float4 Position : POSITION;
float4 Texcoord : TEXCOORD0;
};
// Vertex shader program output
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Texcoord : TEXCOORD0;
};
// Vertex Shader Program
VS_OUTPUT VS( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Texcoord = Input.Texcoord;
float4 displace = tex2Dlod(Vertex1,float4(Input.Texcoord.xy,0,lod));
Output.Position = mul(Input.Position + displace, WorldViewProjection);
return Output;
}
Also the option to explicitly define the texture stage has gone as well with the new material system. Or is there any way to define or overwrite one specific stage?
Thanks for any hints, Flo
I was wondering how to use vertex textures in HLSL shaders in V5... In V4 you were able to define the texture stage as Vertex1 or Vertex2.
Was this changed to the displacement map stage (would make most sense)? I tried with this code snippet, but it looks like the texture isn't sampled at all (no displacement):
float4x4 WorldViewProjection : WORLDVIEWPROJECTION;
sampler Vertex1 : register(s0);
float lod=0;
// Vertex shader program input
struct VS_INPUT
{
float4 Position : POSITION;
float4 Texcoord : TEXCOORD0;
};
// Vertex shader program output
struct VS_OUTPUT
{
float4 Position : POSITION;
float4 Texcoord : TEXCOORD0;
};
// Vertex Shader Program
VS_OUTPUT VS( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Texcoord = Input.Texcoord;
float4 displace = tex2Dlod(Vertex1,float4(Input.Texcoord.xy,0,lod));
Output.Position = mul(Input.Position + displace, WorldViewProjection);
return Output;
}
Also the option to explicitly define the texture stage has gone as well with the new material system. Or is there any way to define or overwrite one specific stage?
Thanks for any hints, Flo