Jump to content

[HELP] Rounded Image


Doffy

Recommended Posts

I created this shader to create a HUE color circle a few years ago:

static const float PI = 3.14159265f;
uniform float brightness = 1;

// Docu: http://chilliant.blogspot.de/2010/11/rgbhsv-in-hlsl.html
float3 HUEtoRGB(in float H)
{
	float R = abs(H * 6 - 3) - 1;
	float G = 2 - abs(H * 6 - 2);
	float B = 2 - abs(H * 6 - 4);
	return saturate(float3(R,G,B));
}

float4 circleMain( float2 coord : TEXCOORD0 ) : COLOR0
{
	float2 off = float2(0.5, 0.5) - coord;
	
	// Draw a circle
	clip(0.25 - (off.x * off.x + off.y * off.y));
	
	float angle = atan2(off.y, off.x) / PI / 2;

	return float4(brightness - HUEtoRGB(angle < 0 ? angle + 1 : angle) * length(off) * 2 * brightness, 1);
}

technique colorCircle
{
	pass main
	{
		PixelShader = compile ps_2_0 circleMain();
	}
}

You can use the dxDrawImage function in combination with a modified HLSL pixel-shader like above and the dxSetShaderValue function to draw a circle-cropped image. The advantage above masking is that the mask has infinite resolution instead of a fixed PNG file. But you need more knowledge about math for this method.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...