Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


#ActualYura

Posted 29 December 2012 - 07:22 AM

Sory for troubling guys, but as you can see, I'm very new in shaders. I wrote a program on direct3d9 which is drawing some surface from triangle list primitives. I have made rotation functions, which allows me to rotate this surface. All of it is made without using any shaders and it works. It works nice, fast, but with one defect. This surface is half transparent. I've tried to blend alfa component, tried to set color in RGB mode but all without success. They are still half transparent. So, now I'm trying to fix it with help of shaders and to add new features - draw this primitives with different colors on front and back sides.

I've made some changes to my shader, now it works, but color is still half transparent. Somebody knows how to fix it?

#3Yura

Posted 29 December 2012 - 06:24 AM

Sory for troubling guys, but as you can see, I'm very new in shaders. I wrote a program on direct3d9 which is drawing some surface from triangle list primitives. I have made rotation functions, which allows me to rotate this surface. All of it is made without using any shaders and it works. It works nice, fast, but with one defect. This surface is half transparent. I've tried to blend alfa component, tried to set color in RGB mode but all without success. They are still half transparent. So, now I'm trying to fix it with help of shaders and to add new features - draw this primitives with different colors on front and back sides. I'm trying to write this shader, using ready-made samples and guides, but without success. So, maybe someone did something like this or know how to write this damn shader?

I've made some changes to my shader, now it works, but I can't rotate camera and colors still the same (front, back)
struct VertexShaderInput
{
    float4 Position : POSITION0;
	float4 Color : COLOR0;
};

struct PixelShaderInput
{
    float4 Color : COLOR0;
	float4 BackColor : COLOR0;
    float face : VFACE;
};

struct VertexShaderOutput 
{
    float4 Position : POSITION0;
	float4 Color : COLOR0;
};

float4x4 worldViewProj;


VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
	VertexShaderOutput output;
	
	output.Position = input.Position;
	output.Color = input.Color;
	
    return output;
}

float4 PixelShaderFunction(PixelShaderInput input) : COLOR0
{
	
	if(input.face>0)
	{
	return input.Color;
	}
	else
	{
	return input.BackColor;
	}
	
}

technique Technique1
{
    pass Pass1
    {
		VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}

#2Yura

Posted 29 December 2012 - 03:36 AM

Sory for troubling guys, but as you can see, I'm very new in shaders. I wrote a program on direct3d9 which is drawing some surface from triangle list primitives. I have made rotation functions, which allows me to rotate this surface. All of it is made without using any shaders and it works. It works nice, fast, but with one defect. This surface is half transparent. I've tried to blend alfa component, tried to set color in RGB mode but all without success. They are still half transparent. So, now I'm trying to fix it with help of shaders and to add new features - draw this primitives with different colors on front and back sides. I'm trying to write this shader, using ready-made samples and guides, but without success. So, maybe someone did something like this or know how to write this damn shader?

 

I've made some changes to my shader, but it still doesn't work (same - white screen): 

 

struct VertexShaderInput
{
    float4 Position : POSITION0;
	float4 Color : COLOR0;
};

struct PixelShaderInput
{
    float4 Color : COLOR0;
	float4 BackColor : COLOR0;
    float face : VFACE;
};

struct VertexShaderOutput 
{
    float4 Position : POSITION0;
	float4 Color : COLOR0;
};

struct PixelShaderOutput 
{
	float4 Color : COLOR0;
};



VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
	VertexShaderOutput output;
	
	output.Position = mul(input.Position, input.Color);
	output.Color = input.Color;
	
    return output;
}

PixelShaderOutput PixelShaderFunction(PixelShaderInput input) : COLOR0
{
    PixelShaderOutput output;
	
	if(input.face>0)
	{
    output.Color = input.Color;
	}
	else
	{
	output.Color = input.BackColor;
	}
	
    return output;
}

technique Technique1
{
    pass Pass1
    {
		VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}

 

 


#1Yura

Posted 29 December 2012 - 02:30 AM

Sory for troubling guys, but as you can see, I'm very new in shaders. I wrote a program on direct3d9 which is drawing some surface from triangle list primitives. I have made rotation functions, which allows me to rotate this surface. All of it is made without using any shaders and it works. It works nice, fast, but with one defect. This surface is half transparent. I've tried to blend alfa component, tried to set color in RGB mode but all without success. They are still half transparent. So, now I'm trying to fix it with help of shaders and to add new features - draw this primitives with different colors on front and back sides. I'm trying to write this shader, using ready-made samples and guides, but without success. So, maybe someone did something like this or know how to write this damn shader?


PARTNERS