• Create Account

### #Actualsuliman

Posted 02 October 2012 - 09:47 AM

The structure is simply
struct PS_OUTPUT
{
float4 diffuse : COLOR0;
};


I can change the diffuse before returning it and this has its desired effect. I just need to know how to know the distance to the camera so i can interpolate the existing color with my fog color.

I know this might come off as lazy but ive skimmed through some hlsl tutorials and they are all very extensive and i just need this to move on with all the other things in the project that has now come to an halt (learning shaders properly must be a later task for me right now).

Erik

The fulll shader code is posted below for reference
float4x4 matViewProjection : ViewProjection;
sampler AlphaMap = sampler_state
{
};
sampler TextureOne = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureTwo = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureThree = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

struct VS_INPUT
{
float4 Position : POSITION0;
float2 alphamap : TEXCOORD0;
float2 tex : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 alphamap : TEXCOORD0;
float2 tex : TEXCOORD1;
};
struct PS_OUTPUT
{
float4 diffuse : COLOR0;
};
VS_OUTPUT vs_main( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Position = mul( Input.Position, matViewProjection );
Output.alphamap = Input.alphamap;
Output.tex = Input.tex;
return( Output );
}
PS_OUTPUT ps_main(in VS_OUTPUT input)
{
float texScale = 1.0;
PS_OUTPUT output = (PS_OUTPUT)0;
vector a = tex2D(AlphaMap, input.alphamap);
vector i = tex2D(TextureOne, mul(input.tex, texScale));
vector j = tex2D(TextureTwo, mul(input.tex, texScale));
vector k = tex2D(TextureThree, mul(input.tex, texScale));

float4 oneminusx = 1.0 - a.x;
float4 oneminusy = 1.0 - a.y;
float4 oneminusz = 1.0 - a.z;
vector l = a.x * i + oneminusx * i;
vector m = a.y * j + oneminusy * l;
vector n = a.z * k + oneminusz * m;
output.diffuse = n;

return output;
}
technique Default_DirectX_Effect
{
pass Pass_0
{
}
}


### #2suliman

Posted 02 October 2012 - 09:46 AM

The structure is simply
struct PS_OUTPUT
{
float4 diffuse : COLOR0;
};


I can change the diffuse before returning it and this has its desired effect. I just need to know how to know the distance to the camera so i can interpolate the existing color with my fog color.

I know this might come off as lazy but ive skimmed through some hlsl tutorials and they are all very extensive and i just need this to move on with all the other things in the project that has now come to an halt (learning shaders properly must be a later task for me right now).

Erik

The fulll shader code is posted below for reference
float4x4 matViewProjection : ViewProjection;
sampler AlphaMap = sampler_state
{
};
sampler TextureOne = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureTwo = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureThree = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};

// my new ones
sampler TextureFour = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureFive = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureSix = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler TextureSeven = sampler_state
{
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
struct VS_INPUT
{
float4 Position : POSITION0;
float2 alphamap : TEXCOORD0;
float2 tex : TEXCOORD1;
};
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 alphamap : TEXCOORD0;
float2 tex : TEXCOORD1;
};
struct PS_OUTPUT
{
float4 diffuse : COLOR0;
};
VS_OUTPUT vs_main( VS_INPUT Input )
{
VS_OUTPUT Output;
Output.Position = mul( Input.Position, matViewProjection );
Output.alphamap = Input.alphamap;
Output.tex = Input.tex;
return( Output );
}
PS_OUTPUT ps_main(in VS_OUTPUT input)
{
float texScale = 1.0;
PS_OUTPUT output = (PS_OUTPUT)0;
vector a = tex2D(AlphaMap, input.alphamap);
vector i = tex2D(TextureOne, mul(input.tex, texScale));
vector j = tex2D(TextureTwo, mul(input.tex, texScale));
vector k = tex2D(TextureThree, mul(input.tex, texScale));

float4 oneminusx = 1.0 - a.x;
float4 oneminusy = 1.0 - a.y;
float4 oneminusz = 1.0 - a.z;
vector l = a.x * i + oneminusx * i;
vector m = a.y * j + oneminusy * l;
vector n = a.z * k + oneminusz * m;
output.diffuse = n;

return output;
}
technique Default_DirectX_Effect
{
pass Pass_0
{
}
}


### #1suliman

Posted 02 October 2012 - 09:45 AM

The structure is simply
struct PS_OUTPUT
{
float4 diffuse : COLOR0;
};


I can change the diffuse before returning it and this has its desired effect. I just need to know how to know the distance to the camera so i can interpolate the existing color with my fog color.

I know this might come off as lazy but ive skimmed through some hlsl tutorials and they are all very extensive and i just need this to move on with all the other things in the project that has now come to an halt (learning shaders properly must be a later task for me right now).