Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmontify

Posted 21 November 2012 - 04:38 AM

Hello
here is my new Shader:

float4x4 World; 
float4x4 View; 
float4x4 Projection; 
float axis;

float4 color; 
float seaLevel; 
float height; 
texture myTexture; 

sampler2D mySampler = sampler_state 
{ 
Texture = <myTexture>; 
MinFilter = Point; 
MagFilter = Point; 
MipFilter = Point; 
AddressU = Clamp; 
AddressV = Clamp; 
}; 

struct VertexShaderInput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;
}; 

struct VertexShaderOutput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;
}; 

//#############  VERTEX SHADER  #############
VertexShaderOutput VertexShaderFunction(VertexShaderInput input) 
{ 
	VertexShaderOutput output; 
	float4 worldPosition = mul(input.Position, World); 
	float axis;
	float2 planetUV; 
	

	//---------------AXIS--------------
   if(axis == 0) //left 
   { 
      planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 1) //right 
   {
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - ((worldPosition.zy + 1) * 0.5); 
   }
   else if(axis == 2) //top 
   {
	   planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = (worldPosition.xz + 1) * 0.5; 
   }
   else if(axis == 3) //bottom 
   { 
      planetUV = (worldPosition.xz + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 4) //front 
   { 
      planetUV = (worldPosition.xy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 5) //back 
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - (worldPosition.xy + 1) * 0.5; 
   //---------------AXIS END--------------


	float3 heightCol = tex2Dlod( mySampler, float4(input.uv.xy, 0, 0) );

	worldPosition= mul(float4(input.Position.x, 0, input.Position.z, 1) *seaLevel, World); 
	worldPosition.y = heightCol * planetUV.y;
	worldPosition = float4(normalize(worldPosition.xyz) * seaLevel, 1); 
	
	float4 viewPosition = mul(worldPosition, View); 

	output.Position = mul(viewPosition, Projection); 
	output.uv = input.uv;

	return output; 
} 



//#############  PIXEL SHADER  #############
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 
{ 
	return color; 
} 

technique Technique1 
{ 
pass Pass1 
{ 


VertexShader = compile vs_3_0 VertexShaderFunction(); 
PixelShader = compile ps_3_0 PixelShaderFunction(); 
} 
}

But here is my new Error:
The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing

Anyone can tell me what i'm doing wrong?

#3montify

Posted 21 November 2012 - 04:27 AM

Hello
here is my new Shader:

float4x4 World; 
float4x4 View; 
float4x4 Projection; 
float axis;

float4 color; 
float seaLevel; 
float height; 
texture myTexture; 

sampler2D mySampler = sampler_state 
{ 
Texture = <myTexture>; 
MinFilter = Point; 
MagFilter = Point; 
MipFilter = Point; 
AddressU = Clamp; 
AddressV = Clamp; 
}; 

struct VertexShaderInput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;
}; 

struct VertexShaderOutput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;

}; 

//#############  VERTEX SHADER  #############
VertexShaderOutput VertexShaderFunction(VertexShaderInput input) 
{ 
	VertexShaderOutput output; 
	float axis;
	float2 planetUV; 
	float4 worldPosition = mul(input.Position, World); 

	//---------------AXIS--------------
   if(axis == 0) //left 
   { 
      planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 1) //right 
   {
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - ((worldPosition.zy + 1) * 0.5); 
   }
   else if(axis == 2) //top 
   {
	   planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = (worldPosition.xz + 1) * 0.5; 
   }
   else if(axis == 3) //bottom 
   { 
      planetUV = (worldPosition.xz + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 4) //front 
   { 
      planetUV = (worldPosition.xy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 5) //back 
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - (worldPosition.xy + 1) * 0.5; 
   //---------------AXIS END--------------


	float3 heightCol = tex2Dlod( mySampler, float4(input.uv.xy, 0, 0) );
	worldPosition= mul(float4(input.Position.x, 0, input.Position.z, 1) *seaLevel, World); 
	worldPosition.z = heightCol * planetUV.y;
	worldPosition = float4(normalize(worldPosition.xyz) * seaLevel, 1); 
	
	
	float4 viewPosition = mul(worldPosition, View); 

	output.Position = mul(viewPosition, Projection); 
	output.uv = input.uv;

	return output; 
} 







//#############  PIXEL SHADER  #############
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 
{ 
	return color; 
} 

technique Technique1 
{ 
pass Pass1 
{ 


VertexShader = compile vs_3_0 VertexShaderFunction(); 
PixelShader = compile ps_3_0 PixelShaderFunction(); 
} 
}

But here is my new Error:
The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing

Anyone can tell me what i'm doing wrong?

#2montify

Posted 21 November 2012 - 04:26 AM

Hello
here is my new Shader:

float4x4 World; 
float4x4 View; 
float4x4 Projection; 
float axis;

float4 color; 
float seaLevel; 
float height; 
texture myTexture; 

sampler2D mySampler = sampler_state 
{ 
Texture = <myTexture>; 
MinFilter = Point; 
MagFilter = Point; 
MipFilter = Point; 
AddressU = Clamp; 
AddressV = Clamp; 
}; 

struct VertexShaderInput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;
}; 

struct VertexShaderOutput 
{ 
float4 Position : POSITION0; 
float4 uv : TEXCOORD0;

}; 

//#############  VERTEX SHADER  #############
VertexShaderOutput VertexShaderFunction(VertexShaderInput input) 
{ 
	VertexShaderOutput output; 
	float axis;
	float2 planetUV; 
	float4 worldPosition = mul(input.Position, World); 

	//---------------AXIS--------------
   if(axis == 0) //left 
   { 
      planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 1) //right 
   {
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - ((worldPosition.zy + 1) * 0.5); 
   }
   else if(axis == 2) //top 
   {
	   planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = (worldPosition.xz + 1) * 0.5; 
   }
   else if(axis == 3) //bottom 
   { 
      planetUV = (worldPosition.xz + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 4) //front 
   { 
      planetUV = (worldPosition.xy + 1) * 0.5; 
      planetUV.y = 1 - planetUV.y; 
   } 
   else if(axis == 5) //back 
	  planetUV = (worldPosition.zy + 1) * 0.5; 
      planetUV = 1 - (worldPosition.xy + 1) * 0.5; 
   //---------------AXIS END--------------


	float3 heightCol = tex2Dlod( mySampler, float4(input.uv.xy, 0, 0) );
	worldPosition= mul(float4(input.Position.x, 0, input.Position.z, 1) *seaLevel, World); 
	worldPosition.z = heightCol * planetUV.y;
	worldPosition = float4(normalize(worldPosition.xyz) * seaLevel, 1); 
	
	
	float4 viewPosition = mul(worldPosition, View); 

	output.Position = mul(viewPosition, Projection); 
	output.uv = input.uv;

	return output; 
} 







//#############  PIXEL SHADER  #############
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 
{ 
	return color; 
} 

technique Technique1 
{ 
pass Pass1 
{ 


VertexShader = compile vs_3_0 VertexShaderFunction(); 
PixelShader = compile ps_3_0 PixelShaderFunction(); 
} 
}

But here is my new Error:
The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing

Anyone can tell me what i'm doing wrong?

#1montify

Posted 21 November 2012 - 04:10 AM

Hello
here is my new Shader:

float4x4 World;
float4x4 View;
float4x4 Projection;
float axis;
float4 color;
float seaLevel;
float height;
texture myTexture;
sampler2D mySampler = sampler_state
{
Texture = <myTexture>;
MinFilter = Point;
MagFilter = Point;
MipFilter = Point;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 uv : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
};
//#############  VERTEX SHADER  #############
VertexShaderOutput VertexShaderFunction(VertexShaderInput input, float2 texCords : TEXCOORD0)
{
VertexShaderOutput output;
float axis;
float2 planetUV;
float4 worldPosition = mul(input.Position, World);
//---------------AXIS--------------
   if(axis == 0) //left
   {
	  planetUV = (worldPosition.zy + 1) * 0.5;
	  planetUV.y = 1 - planetUV.y;
   }
   else if(axis == 1) //right
   {
   planetUV = (worldPosition.zy + 1) * 0.5;
	  planetUV = 1 - ((worldPosition.zy + 1) * 0.5);
   }
   else if(axis == 2) //top
   {
    planetUV = (worldPosition.zy + 1) * 0.5;
	  planetUV = (worldPosition.xz + 1) * 0.5;
   }
   else if(axis == 3) //bottom
   {
	  planetUV = (worldPosition.xz + 1) * 0.5;
	  planetUV.y = 1 - planetUV.y;
   }
   else if(axis == 4) //front
   {
	  planetUV = (worldPosition.xy + 1) * 0.5;
	  planetUV.y = 1 - planetUV.y;
   }
   else if(axis == 5) //back
   planetUV = (worldPosition.zy + 1) * 0.5;
	  planetUV = 1 - (worldPosition.xy + 1) * 0.5;
   //---------------AXIS END--------------

float3 heightCol = tex2Dlod( mySampler, float4(texCords.xy, 0, 0) );
worldPosition= mul(float4(input.Position.x, 0, input.Position.z, 1) *seaLevel, World);
worldPosition.z += heightCol * planetUV.y;

worldPosition = float4(normalize(worldPosition.xyz) * seaLevel, 1);


 
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
return output;
}


//#############  PIXEL SHADER  #############
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
return color;
}
technique Technique1
{
pass Pass1
{

VertexShader = compile vs_3_0 VertexShaderFunction();
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}

But here is my new Error:
The current vertex declaration does not include all the elements required by the current vertex shader. TextureCoordinate0 is missing

Anyone can tell me what i'm doing wrong?

PARTNERS