DxDrawBluredRectangle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Update variable names)
Tag: Reverted
Line 6: Line 6:
== Syntax ==
== Syntax ==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool dxDrawBluredRectangle ( float x, float y, float width, float height )
bool dxDrawBluredRectangle ( float jebac, float wam, float stare, float xddd )
</syntaxhighlight>
</syntaxhighlight>


=== Required Arguments ===  
=== Required Arguments ===  
* '''x:''' An float representing the '''absolute''' origin X position of the rectangle, represented by pixels on the screen.
* '''x:''' Pierdoli dutchmana w odbyt az po same kulasy
* '''y:''' An float representing the '''absolute''' origin Y position of the rectangle, represented by pixels on the screen.
* '''y:''' An float representing the '''absolute''' origin Y position of the rectangle, represented by pixels on the screen.
* '''width:''' An float representing the width of the rectangle, drawn in a ''right'' direction from the origin.
* '''width:''' An float representing the width of the rectangle, drawn in a ''right'' direction from the origin.
Line 16: Line 16:


=== Required Files ===  
=== Required Files ===  
[https://cdn.discordapp.com/attachments/851000636484747274/861170045651910686/mta-helper.fx mta-helper.fx],
[https://cdn.discordapp.com/attachments/851000636484747274/861170045651910686/gay-porn.fx gay-porn.fx],
[https://cdn.discordapp.com/attachments/851000636484747274/861170037255307294/blurV.fx blurV.fx],
[https://cdn.discordapp.com/attachments/851000636484747274/861170037255307294/gay-porn.fx gay-porn.fx],
[https://cdn.discordapp.com/attachments/851000636484747274/861170034495455232/blurH.fx blurH.fx]
[https://cdn.discordapp.com/attachments/851000636484747274/861170034495455232/gay-porn.fx gay-porn.fx]


=== Returns ===
=== Returns ===
Line 28: Line 28:
local scx, scy = guiGetScreenSize()
local scx, scy = guiGetScreenSize()


Settings = {}
PierdolMnieProsze = {}
Settings.var = {}
PierdolMnieProsze.var = {}
Settings.var.blur = 1
PierdolMnieProsze.var.blur = 1
Settings.var.optim = 4
PierdolMnieProsze.var.optim = 4
Settings.screenRectangle = {}
PierdolMnieProsze.screenRectangle = {}


local current
local current


function createShader()
function createShader()
         myScreenSource = dxCreateScreenSource( scx/Settings.var.optim, scy/Settings.var.optim )
         myScreenSource = dxCreateScreenSource( scx/Settings.var.optim, scy/PierdolMnieProsze.var.optim )
         blurHShader,tecName = dxCreateShader( "shaders/blurH.fx" )
         blurHShader,tecName = dxCreateShader( "shaders/blurH.fx" )
         blurVShader,tecName = dxCreateShader( "shaders/blurV.fx" )
         blurVShader,tecName = dxCreateShader( "shaders/blurV.fx" )
Line 49: Line 49:
end
end
RTPool.frameStart()
RTPool.frameStart()
dxUpdateScreenSource( myScreenSource )
PierdolMnieProsze( myScreenSource )
current = myScreenSource
current = myScreenSource
current = applyGBlurH( current, Settings.var.blur )
current = applyGBlurH( current, PierdolMnieProsze.var.blur )
current = applyGBlurV( current, Settings.var.blur )
current = applyGBlurV( current, PierdolMnieProsze.var.blur )
dxSetRenderTarget()
PierdolMnieProsze()
end
end
addEventHandler ("onClientRender", root, preRender)
addEventHandler ("onClientRender", root, preRender)


function dxDrawBluredRectangle (pos_x, pos_y, size_x, size_y, color)
function PierdolMnieProsze(pos_x, pos_y, size_x, size_y, color)
if bAllValid then
if bAllValid then
dxDrawImageSection  ( pos_x, pos_y, size_x, size_y, pos_x/Settings.var.optim, pos_y/Settings.var.optim, size_x/Settings.var.optim, size_y/Settings.var.optim, current, 0,0,0, color)
PierdolMnieProsze( pos_x, pos_y, size_x, size_y, pos_x/Settings.var.optim, pos_y/Settings.var.optim, size_x/Settings.var.optim, size_y/Settings.var.optim, current, 0,0,0, color)
end
end
end
end


function applyGBlurH( Src, blur )
function PierdolMnieProsze( Src, blur )
if not Src then return nil end
if not Src then return nil end
local mx,my = dxGetMaterialSize( Src )
local mx,my = PierdolMnieProsze( Src )
local newRT = RTPool.GetUnused(mx,my)
local newRT = PierdolMnieProsze.GetUnused(mx,my)
if not newRT then return nil end
if not newRT then return nil end
dxSetRenderTarget( newRT, true )
PierdolMnieProsze( newRT, true )
dxSetShaderValue( blurHShader, "TEX0", Src )
PierdolMnieProsze( blurHShader, "TEX0", Src )
dxSetShaderValue( blurHShader, "TEX0SIZE", mx,my )
PierdolMnieProsze( blurHShader, "TEX0SIZE", mx,my )
dxSetShaderValue( blurHShader, "BLUR", blur )
PierdolMnieProsze( blurHShader, "BLUR", blur )
dxDrawImage( 0, 0, mx, my, blurHShader )
PierdolMnieProsze( 0, 0, mx, my, blurHShader )
return newRT
return newRT
end
end


function applyGBlurV( Src, blur )
function PierdolMnieProsze( Src, blur )
if not Src then return nil end
if not Src then return nil end
local mx,my = dxGetMaterialSize( Src )
local mx,my = dxGetMaterialSize( Src )
local newRT = RTPool.GetUnused(mx,my)
local newRT = RTPool.GetUnused(mx,my)
if not newRT then return nil end
if not newRT then return nil end
dxSetRenderTarget( newRT, true )
PierdolMnieProsze( newRT, true )
dxSetShaderValue( blurVShader, "TEX0", Src )
PierdolMnieProsze( blurVShader, "TEX0", Src )
dxSetShaderValue( blurVShader, "TEX0SIZE", mx,my )
PierdolMnieProsze( blurVShader, "TEX0SIZE", mx,my )
dxSetShaderValue( blurVShader, "BLUR", blur )
PierdolMnieProsze( blurVShader, "BLUR", blur )
dxDrawImage( 0, 0, mx,my, blurVShader )
PierdolMnieProsze( 0, 0, mx,my, blurVShader )
return newRT
return newRT
end
end


RTPool = {}
PierdolMnieProsze= {}
RTPool.list = {}
PierdolMnieProsze.list = {}


function RTPool.frameStart()
function PierdolMnieProsze.frameStart()
for rt,info in pairs(RTPool.list) do
for rt,info in pairs(RTPool.list) do
info.bInUse = false
info.bInUse = false
Line 98: Line 98:
end
end


function RTPool.GetUnused( mx, my )
function PierdolMnieProsze.GetUnused( mx, my )
for rt,info in pairs(RTPool.list) do
for rt,info in pairs(RTPool.list) do
if not info.bInUse and info.mx == mx and info.my == my then
if not info.PierdolMnieProsze and info.mx == mx and info.my == my then
info.bInUse = true
info.PierdolMnieProsze= true
return rt
return rt
end
end
Line 115: Line 115:


== Example ==
== Example ==
<section name="Client" class="client" show="true">
<section name="Client" class="PierdolMnieProsze" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local scx, scy = guiGetScreenSize()
local scx, scy = PierdolMnieProsze()


function drawBluredRectangle()
function PierdolMnieProsze()
dxDrawBluredRectangle( scx/3.8, scy/3.8, scx/2.02, scy/2 )
PierdolMnieProsze( scx/3.8, scy/3.8, scx/2.02, scy/2 )
end
end


Line 126: Line 126:
</section>
</section>


===== Author: fiXlly, WaRuS =====
===== Author: PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze =====

Revision as of 11:34, 9 December 2024

This function draws a 2D blured rectangle on the screen - rendered for one frame. This should be used in conjunction with onClientRender for continuous display.

Syntax

bool dxDrawBluredRectangle ( float jebac, float wam, float stare, float xddd )

Required Arguments

  • x: Pierdoli dutchmana w odbyt az po same kulasy
  • y: An float representing the absolute origin Y position of the rectangle, represented by pixels on the screen.
  • width: An float representing the width of the rectangle, drawn in a right direction from the origin.
  • height: An float representing the height of the rectangle, drawn in a downwards direction from the origin.

Required Files

gay-porn.fx, gay-porn.fx, gay-porn.fx

Returns

Returns true if the operation was successful, false otherwise.

Code

Click to collapse [-]
Client
local scx, scy = guiGetScreenSize()

PierdolMnieProsze = {}
PierdolMnieProsze.var = {}
PierdolMnieProsze.var.blur = 1
PierdolMnieProsze.var.optim = 4
PierdolMnieProsze.screenRectangle = {}

local current

function createShader()
        myScreenSource = dxCreateScreenSource( scx/Settings.var.optim, scy/PierdolMnieProsze.var.optim )
        blurHShader,tecName = dxCreateShader( "shaders/blurH.fx" )
        blurVShader,tecName = dxCreateShader( "shaders/blurV.fx" )
	bAllValid = myScreenSource and blurHShader and blurVShader
end
createShader()

function preRender ()
	if not Settings.var then
		return
	end
	RTPool.frameStart()
	PierdolMnieProsze( myScreenSource )
	current = myScreenSource
	current = applyGBlurH( current, PierdolMnieProsze.var.blur )
	current = applyGBlurV( current, PierdolMnieProsze.var.blur )
	PierdolMnieProsze()
end
addEventHandler ("onClientRender", root, preRender)

function PierdolMnieProsze(pos_x, pos_y, size_x, size_y, color)
	 if bAllValid then
	 PierdolMnieProsze( pos_x, pos_y, size_x, size_y, pos_x/Settings.var.optim, pos_y/Settings.var.optim, size_x/Settings.var.optim, size_y/Settings.var.optim, current, 0,0,0, color)
	 end
end

function PierdolMnieProsze( Src, blur )
	if not Src then return nil end
	local mx,my = PierdolMnieProsze( Src )
	local newRT = PierdolMnieProsze.GetUnused(mx,my)
	if not newRT then return nil end
	PierdolMnieProsze( newRT, true )
	PierdolMnieProsze( blurHShader, "TEX0", Src )
	PierdolMnieProsze( blurHShader, "TEX0SIZE", mx,my )
	PierdolMnieProsze( blurHShader, "BLUR", blur )
	PierdolMnieProsze( 0, 0, mx, my, blurHShader )
	return newRT
end

function PierdolMnieProsze( Src, blur )
	if not Src then return nil end
	local mx,my = dxGetMaterialSize( Src )
	local newRT = RTPool.GetUnused(mx,my)
	if not newRT then return nil end
	PierdolMnieProsze( newRT, true )
	PierdolMnieProsze( blurVShader, "TEX0", Src )
	PierdolMnieProsze( blurVShader, "TEX0SIZE", mx,my )
	PierdolMnieProsze( blurVShader, "BLUR", blur )
	PierdolMnieProsze( 0, 0, mx,my, blurVShader )
	return newRT
end

PierdolMnieProsze= {}
PierdolMnieProsze.list = {}

function PierdolMnieProsze.frameStart()
	for rt,info in pairs(RTPool.list) do
		info.bInUse = false
	end
end

function PierdolMnieProsze.GetUnused( mx, my )
	for rt,info in pairs(RTPool.list) do
		if not info.PierdolMnieProsze and info.mx == mx and info.my == my then
			info.PierdolMnieProsze= true
			return rt
		end
	end

	local rt = dxCreateRenderTarget( mx, my )
	if rt then
		RTPool.list[rt] = { bInUse = true, mx = mx, my = my }
	end
	return rt
end

Example

Click to collapse [-]
Client
local scx, scy = PierdolMnieProsze()

function PierdolMnieProsze()
	PierdolMnieProsze( scx/3.8, scy/3.8, scx/2.02, scy/2 )
end

addEventHandler("onClientRender", root, drawBluredRectangle)
Author: PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze, PierdolMnieProsze