Direct3D11 common shader changes.

This commit is contained in:
rextimmy 2016-03-20 21:50:21 +10:00
parent 1ff6f221fb
commit 3a9b50f702
283 changed files with 3547 additions and 1834 deletions

View file

@ -21,25 +21,28 @@
//-----------------------------------------------------------------------------
#include "terrain.hlsl"
#include "../shaderModel.hlsl"
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 layerCoord : TEXCOORD0;
float2 texCoord : TEXCOORD1;
};
float4 main( ConnectData IN,
uniform sampler2D layerTex : register(S0),
uniform sampler2D textureMap : register(S1),
uniform float texId,
uniform float layerSize ) : COLOR
TORQUE_UNIFORM_SAMPLER2D(layerTex, 0);
TORQUE_UNIFORM_SAMPLER2D(textureMap, 1);
uniform float texId;
uniform float layerSize;
float4 main( ConnectData IN ) : TORQUE_TARGET0
{
float4 layerSample = round( tex2D( layerTex, IN.layerCoord ) * 255.0f );
float4 layerSample = round( TORQUE_TEX2D( layerTex, IN.layerCoord ) * 255.0f );
float blend = calcBlend( texId, IN.layerCoord, layerSize, layerSample );
clip( blend - 0.0001 );
return float4( tex2D( textureMap, IN.texCoord ).rgb, blend );
return float4( TORQUE_TEX2D(textureMap, IN.texCoord).rgb, blend);
}

View file

@ -23,6 +23,8 @@
/// The vertex shader used in the generation and caching of the
/// base terrain texture.
#include "../shaderModel.hlsl"
struct VertData
{
float3 position : POSITION;
@ -31,17 +33,18 @@ struct VertData
struct ConnectData
{
float4 hpos : POSITION;
float4 hpos : TORQUE_POSITION;
float2 layerCoord : TEXCOORD0;
float2 texCoord : TEXCOORD1;
};
ConnectData main( VertData IN,
uniform float2 texScale : register(C0) )
uniform float2 texScale;
ConnectData main( VertData IN )
{
ConnectData OUT;
OUT.hpos = float4( IN.position.xyz, 1 );
OUT.hpos = float4( IN.position, 1 );
OUT.layerCoord = IN.texCoord;
OUT.texCoord = IN.texCoord * texScale;

View file

@ -35,6 +35,7 @@ float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSa
// Check if any of the layer samples
// match the current texture id.
float4 factors = 0;
[unroll]
for(int i = 0; i < 4; i++)
if(layerSample[i] == texId)
factors[i] = 1;