Jump to content

Looking for shader


ds1-e

Recommended Posts

  • Scripting Moderators

I have found this, it's called grayscale, probably this is what i'm looking for, but i don't know how can i use it.

And probably there's no possibility to change intensity of it by script.

texture GrayscaleTexture;	

sampler screenSampler = sampler_state
{
	Texture = <GrayscaleTexture>;
};

float4 main(float2 uv : TEXCOORD0) : COLOR0 
{ 
    float4 Color; 
    Color = tex2D( screenSampler , uv); 
	Color.rgb = round((Color.r+Color.g+Color.b)*10.0f)/30.0f;
	Color.r=Color.rgb;
	Color.g=Color.rgb;
	Color.b=Color.rgb;
    return Color; 
};

technique Grayscale
{
	pass P1
	{
		PixelShader = compile ps_2_0 main();
	}
}

 

Link to comment

change color in 

 

	Color.rgb = round((Color.r+Color.g+Color.b)*10.0f)/30.0f; // gray
	Color.r=Color.rgb; // here
	Color.g=Color.rgb; // here
	Color.b=Color.rgb; // here

	// example
	
	Color.r *= 1.10; // here
	Color.g *= 1.10; // here
	Color.b *= 1.10; // here
	

 

  • Like 1
Link to comment
  • Scripting Moderators
4 hours ago, XaskeL said:

change color in 

 


	Color.rgb = round((Color.r+Color.g+Color.b)*10.0f)/30.0f; // gray
	Color.r=Color.rgb; // here
	Color.g=Color.rgb; // here
	Color.b=Color.rgb; // here

	// example
	
	Color.r *= 1.10; // here
	Color.g *= 1.10; // here
	Color.b *= 1.10; // here
	

 

 

Hey, i'm gonna try do it soon, if i could figure out how to use this shader :D

Link to comment
18 hours ago, majqq said:

 

Эй, я постараюсь сделать это в ближайшее время, если бы я мог понять, как использовать этот шейдер : D

test it

client.lua:

SHADER_CODE = [[
	texture GrayscaleTexture;	

	sampler screenSampler = sampler_state
	{
		Texture = <GrayscaleTexture>;
	};

	float4 main(float2 uv : TEXCOORD0) : COLOR0 
	{ 
		float4 Color; 
		Color = tex2D( screenSampler , uv); 
		Color.rgb = round((Color.r+Color.g+Color.b)*10.0f)/30.0f;
		Color.r=Color.rgb;
		Color.g=Color.rgb;
		Color.b=Color.rgb;
		return Color; 
	};

	technique Grayscale
	{
		pass P1
		{
			PixelShader = compile ps_2_0 main();
		}
	}
]]

local scx,scy = guiGetScreenSize()
local screenSource = dxCreateScreenSource(scx,scy)

local shader = dxCreateShader(SHADER_CODE)

addEventHandler('onClientHUDRender', root,
    function()
		dxUpdateScreenSource(screenSource, true)
		dxSetShaderValue(shader, 'GrayscaleTexture', screenSource)
	end
);

addEventHandler('onClientRender', root,
	function()
		dxDrawImage(0,0,scx,scy,screenSource)
	end
);

 

Edited by XaskeL
  • Like 1
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...