Jump to content

[REL]GTAIV-style hud 1.3 RELEASED


karlis

Recommended Posts

  • Replies 170
  • Created
  • Last Reply

Top Posters In This Topic

advise to resource author: circle radar now can be made by

  • dxCreateTexture -- map and mask images
    dxCreateRenderTarget, dxSetRenderTarget -- draw piece of map ^ into custom new texture
    dxCreateShader, dxSetShaderValue -- use `mask` image as alpha channel for custom texture ^
    dxDrawImage -- draw shader ^ to screen

all you need is knowledge of HLSL for creating a shader .fx file

Link to comment
  • 2 weeks later...
  • 2 months later...

i can show you a right and simple way to make round radar as I said earlier. Here is example resource.

Here lua script from it

local uMyShader=        dxCreateShader(  "shaders/mask.fx" ) 
local uMyImage =        dxCreateTexture( "images/grass.png" ) 
local uMyMask =         dxCreateTexture( "images/grayscaleMask.png" ) 
local uRenderImage =    dxCreateRenderTarget( 256,256, true ) 
  
if not uMyShader or not uMyImage or not uRenderImage or not uMyMask then 
    outputChatBox( "Can't create shader or textures for it!" ) 
    return 
end 
  
  
  
dxSetShaderValue( uMyShader, "tex0",     uMyImage ) 
dxSetShaderValue( uMyShader, "maskTex0", uMyMask ) 
  
  
  
-- simple rotation example 
addEventHandler( "onClientRender", root, 
    function() 
        dxSetRenderTarget( uRenderImage, false ) -- draw to render texture 
        dxDrawImage( 0, 0, 256, 256, uMyShader ) 
  
        dxSetRenderTarget() -- draw to screen 
        dxDrawImage( 
            300, 300, 
            256, 256, 
            uRenderImage, 
            getPedRotation(localPlayer) or 0 
        ) 
    end 
) 
  

here hlsl script from it too

texture tex0;       // texture 
texture maskTex0;   // mask 
  
sampler sBase = sampler_state { Texture = (tex0); }; 
sampler sAlpha = sampler_state { Texture = (maskTex0); }; 
  
  
  
  
  
struct PS_IN { float2 Base : TEXCOORD0; }; 
  
float4 ps( PS_IN In ) : COLOR 
{ 
    float4 color; 
    float4 alpha; 
  
    color = tex2D( sBase, In.Base.xy ); 
    alpha = tex2D( sAlpha, In.Base.xy ); 
  
    color.a = alpha.r * alpha.g * alpha.b; 
  
    return color; 
} 
  
  
  
  
  
technique mask 
{ 
    pass p0 
    { 
        PixelShader = compile ps_2_0 ps(); 
    } 
} 
  

all these scripts, sample image and mask image you can find in the example resource ^

Link to comment

thnx, problem is that w/o hlsl i still can't script the hud, so i still have to learn it.

ill give it a try.

EDIT: cuz i need to use dxDrawImageSection it didnt work propertly, but still, what could be the reason for simple float4 to cause error?

Edited by Guest
Link to comment

i aim it to be quite more advanced.

we'll see how it goes

dont you see a ovbious mistake in this line?

  
struct PS_IN { float2 texCord : TEXCOORD0, float2 pixelPos : VPOS0 }; 

edit:

or this

struct PS_IN { float2 texCord : TEXCOORD0; float2 pixelPos : VPOS }; 

Link to comment

use shader only for masking, for other calculations, texture scaling, rotating, fading .. - use lua dx functions.

some correct steps to make round radar:

  • draw to the first clean render texture needed scaled piece of the map texture, using dxDrawImageSection
  • also draw needed gang zone images to this render target
  • set new texture value for mask shader to this render texture
  • draw this shader to the second clean render target
  • draw a round border to it
  • draw this second render target to the screen with rotation parameter related to local player's camera position/target
  • draw (N) icon image to the screen
  • draw needed icon images to the screen
  • draw local player's icon image to the screen

Link to comment

some suggestions:

use grayscaled map

use thin borders around health/armor bar

copy (N) from original GTA IV radar

use round blips

use original ">" blip for the local player

draw blips over the health/armor bar

off course radar size must be based on client screen size

just see the difference

Radar-GTA4.pngmjv1o2.png

good work, keep going

Link to comment

at least i dont like the thin borders, my target arent making one exact like iv, by calling it iv hud i mean i want to get the good stuff from the iv(circular radar areas, zoom, hp and armor bar, radio, hidable content, etc.)

but ill consider your suggestions

and size is based on res already, but i find hard to find right formula, cuz proportional wouldnt work.

PS:im not a photoshop artist, im a scripter, ill fail even at creating basic things in it.

PPS:and drawing blips over hp/armor would be good for sp, but in mp, which often have dozens of blips they would jsut totally block the view.

Link to comment

yay done the circular radar areas!

24lmzyu.png

functions(use exports.IVhud:functionName(args) ):

element/boolean createRoundRadarArea(float x,float y,float radius,int r,int g,int b,int a) 
--[[ 
x and y: pos on the world 
radius: radius of area on the world 
r,g,b and a:4last args optional, the color of radar area(default:white, 150alpha) 
  
returns false if invalid args, element of "roundradararea" type if sucessful 
]] 

boolean/float float float areaDimensions(element area,float x,float y,float radius) 
--[[ 
  
sets and gets position and radius of specified area 
call it with only 1st argument to return pos and radius of area, call with all 4 to set them 
  
  

boolean/int int int int roundRadarAreaColor(element area,int r,int g,int b,int a) 
  
--[[ 
sets and gets radar area color 
call it with only 1st argument to return color, call with all 5 to set the color 
  
  
  

boolean isElementInRoundArea(element theElement,element area) 
  
--[[checks is particular element inside the round radar area 
returns boolean 
  
  
  

  
boolean/table getElementsInRoundRadarArea(element area,string elemType) 
  
--[[ 
gets all elements in particula round radar area, filters them by type, if elemType specified. 
returns table(may be empty) or false if invalid arguments 
  
  
  

boolean/int int int int int string float float float roundRadarAreaFlashing(element area,int interval,int r2,int g2,int b2,int a2,sting easetype,float easeperiod,float easeamplitude,float easeovershoot) 
  
--[[ 
makes round radar area flash. 
interval: how long will the flash/interpolation go before reaching the edge 
r2,g2,b2,a2: second color for the flash, first being the normal one. 
easetype: any type of easing used for interpolation of colors 
  NOTE: "Binary" is aviable aswell-it just switches from color1 to color2 and back without easing. 
easeperiod,easeamplitude,easeovershoot: arguments for the easing, OPTIONAL 
  
to turn flashing off call it with only first 2 arguments. 
  
to return all arguments specified before(except area itself ofc) call it only with first argument. 
  
  
  

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...