Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2017-02-04, 21:16


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

venzikk, zobacz kod u g?ry edytowa?em go

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:21


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Dalej to samo, ale na karoserie tak jest zrobione:


function zaladujshadery()

            
            end -- funkcja ktora laduje pliki shaderow
function wlaczauta()
if not autoshader then autoshaderdxCreateShader "car_paint.fx" end
            local AutatextureVol dxCreateTexture "images/smallnoise3d.dds" )
            local AutatextureCube dxCreateTexture "images/cube_env256.dds" )
            dxSetShaderValue autoshader"sRandomTexture"AutatextureVol )
            dxSetShaderValue autoshader"sReflectionTexture"AutatextureCube )
engineApplyShaderToWorldTexture autoshader"vehiclegrunge256" )
            engineApplyShaderToWorldTexture (autoshader"?emap*" )
end
function wylaczauta()
engineRemoveShaderFromWorldTexture autoshader"vehiclegrunge256" )
            engineRemoveShaderFromWorldTexture (autoshader"?emap*" )
            
            destroyElement(autoshader)
            autoshader=nil
end
addEventHandler("onClientResourceStart"resourceRoot,
    function()
        GUIEditor.window[1] = guiCreateWindow(1053227226391"Panel Shader?w by VenZ"false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.button[1] = guiCreateButton(934320738"Zamknij okno"falseGUIEditor.window[1])
        GUIEditor.checkbox[1] = guiCreateCheckBox(102620667"Karoseria Pojazd?w"falsefalseGUIEditor.window[1])
        GUIEditor.checkbox[2] = guiCreateCheckBox(99420771"Odbicie pod?o?a"falsefalseGUIEditor.window[1])
        GUIEditor.checkbox[3] = guiCreateCheckBox(916820768"BUDOWA"falsefalseGUIEditor.window[1])
        GUIEditor.checkbox[4] = guiCreateCheckBox(923720763"BUD0WA"falsefalseGUIEditor.window[1])    
    end)
    showCursor(true)
    addEventHandler "onClientGUIClick",root,
    function() 
    if source==GUIEditor.checkbox[1then
    
        if guiCheckBoxGetSelected(GUIEditor.checkbox[1])==true then 
        wlaczauta()
        elseif guiCheckBoxGetSelected(GUIEditor.checkbox[1])==false then
        wylaczauta()
        end
        end
    end)


I dzia?a na karoserie a to nie ;/

Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:27


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

venzikk, mo?e zamiast * daj nazwy tych shader?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:28


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Hazmudex, Da?em, ale teraz nawet shader si? nie odpali :/

Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:29


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

venzikk, pokaz kod

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:32


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

hadertec nil
     function nazwa()
            local shadertec dxCreateShader "roadshine.fx" )
            if engineApplyShaderToWorldTexture shader"roadshine" then return true end
            return false
        end


function wylaczauta1()
if shader then
engineRemoveShaderFromWorldTexture (shader"roadshine" )    
destroyElement(shader)
shader nil
return true
end
return false
end

addEventHandler "onClientGUIClick",root,
    function() 
    if source == GUIEditor.checkbox[2then
    
        if guiCheckBoxGetSelected(sourcethen 
            if nazwa() then

            end
        else
              if wylaczauta1() then
            end
        end
        end
    end)





Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:34


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

venzikk, nazwe shader z pliku .fx

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:36


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

To jest kod tego shadera

--
-- c_roadshine.lua
--


addEventHandler"onClientResourceStart"resourceRoot,
    function()

        -- Version check
        if getVersion ().sortable "1.1.0" then
            outputChatBox"Resource is not compatible with this client." )
            return
        end

        -- Create shader
        local shadertec dxCreateShader "roadshine.fx" )

        if not shader then
            outputChatBox"Could not create shader. Please use debugscript 3" )
        else
            outputChatBox"Using technique " .. tec )

            -- Apply shader to all world textures
            engineApplyShaderToWorldTexture shader"*" )
        end
    end
)


Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:37


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3809 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2315

Respekt: 240
Respekt: 240Respekt: 240


function wylaczsha()
engineRemoveShaderFromWorldTexture (roadshader"*" )
            
            destroyElement(roadshader)
            roadshader=nil
end

function wlaczsha()
    if not roadshader then roadshader dxCreateShader "roadshine3.fx"0end

    dxSetShaderValueroadshader"sStrength"1.5 )
    dxSetShaderValueroadshader"sFadeEnd"maxEffectDistance )
    dxSetShaderValueroadshader"sFadeStart"maxEffectDistance/)
    engineApplyShaderToWorldTexture roadshader"*" )
end

takie trudne?

PS.
podpi?cie pod gui:

    addEventHandler "onClientGUIClick",root,
    function() 
    if source==GUIEditor.checkbox[2then
    
    if guiCheckBoxGetSelected(GUIEditor.checkbox[2])==true then
        wlaczsha()
        elseif guiCheckBoxGetSelected(GUIEditor.checkbox[2])==false then
        wylaczsha()
        
        end
        end
    end)


Ostatnio zmieniony przez Pawel5321 2017-02-04, 21:38, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:37


_Haze

Peace Yo!






Wiek: 24
Na forum: 4184 dni
Posty: 1648
Nick w MP: Haze

Piwa: 2628

Respekt: 1020
Respekt: 1020

venzikk, otw?rz plik .fx i podaj mi go

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:39


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Pawel5321, Teraz to wcale nie dzia?a :V

[ Dodano: 2017-02-04, 21:41 ]
//
// Example shader - roadshine.fx
//


//---------------------------------------------------------------------
// Road shine settings
//---------------------------------------------------------------------
float3 sLightDir float3(0.507,-0.507,-0.2);
float sSpecularPower 16;


//---------------------------------------------------------------------
// Include some common stuff
//---------------------------------------------------------------------
#define GENERATE_NORMALS      // Uncomment for normals to be generated
#include "mta-helper.fx"


//---------------------------------------------------------------------
// Sampler for the main texture
//---------------------------------------------------------------------
sampler Sampler0 sampler_state
{
    Texture = (gTexture0);
};


//---------------------------------------------------------------------
// Structure of data sent to the vertex shader
//---------------------------------------------------------------------
struct VSInput
{
  float3 Position POSITION0;
  float3 Normal NORMAL0;
  float4 Diffuse COLOR0;
  float2 TexCoord TEXCOORD0;
};

//---------------------------------------------------------------------
// Structure of data sent to the pixel shader ( from the vertex shader )
//---------------------------------------------------------------------
struct PSInput
{
  float4 Position POSITION0;
  float4 Diffuse COLOR0;
  float2 TexCoord TEXCOORD0;
  float3 WorldNormal TEXCOORD1;
  float3 WorldPos TEXCOORD2;
};


//------------------------------------------------------------------------------------------
// VertexShaderFunction
//  1. Read from VS structure
//  2. Process
//  3. Write to PS structure
//------------------------------------------------------------------------------------------
PSInput VertexShaderFunction(VSInput VS)
{
    PSInput PS = (PSInput)0;

    // Make sure normal is valid
    MTAFixUpNormalVS.Normal );

    // Calculate screen pos of vertex
    PS.Position MTACalcScreenPosition VS.Position );

    // Pass through tex coord
    PS.TexCoord VS.TexCoord;

    // Calculate GTA lighting for buildings
    PS.Diffuse MTACalcGTABuildingDiffuseVS.Diffuse );

    // Set information to do specular calculation in pixel shader
    PS.WorldNormal MTACalcWorldNormalVS.Normal );
    PS.WorldPos MTACalcWorldPositionVS.Position );

    return PS;
}

//------------------------------------------------------------------------------------------
// PixelShaderFunction
//  1. Read from PS structure
//  2. Process
//  3. Return pixel color
//------------------------------------------------------------------------------------------
float4 PixelShaderFunction(PSInput PS) : COLOR0
{
    // Get texture pixel
    float4 texel tex2D(Sampler0PS.TexCoord);

    //
    // Specular calculation
    //

    float3 lightDir normalize(sLightDir);

    // Using Blinn half angle modification for performance over correctness
    float3 h normalize(normalize(gCameraPosition PS.WorldPos) - lightDir);
    float specLighting pow(saturate(dot(hPS.WorldNormal)), sSpecularPower);


    // Modulate specular with texture a little bit to break up the surface
    specLighting *= texel.texel.g;

    // Apply diffuse lighting
    float4 finalColor texel PS.Diffuse;

    // Apply specular
    finalColor.rgb += texel.rgb specLighting;

    return finalColor;
}


//------------------------------------------------------------------------------------------
// Techniques
//------------------------------------------------------------------------------------------
technique shine
{
    pass P0
    {
        VertexShader compile vs_2_0 VertexShaderFunction();
        PixelShader compile ps_2_0 PixelShaderFunction();
    }
}

// Fallback
technique fallback
{
    pass P0
    {
        // Just draw normally
    }
}


Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:43


Pawel5321

Szkrypter






Wiek: 36
Na forum: 3809 dni
Posty: 237
Nick w MP: Pawell

Piwa: 2315

Respekt: 240
Respekt: 240Respekt: 240

venzikk, bo zrobi?em to pod roadshine3 . Zaraz ci pode?l? na pw dzia?aj?ce

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:44


venzikk

LUA, MODELER






Wiek: 24
Na forum: 3823 dni
Posty: 235
Nick w MP: VenZ

Piwa: 3158

Respekt: 240
Respekt: 240Respekt: 240

Pawel5321, Okey ;v

Podpis



Hej
,Tak ty! Pomogłem ci? zostaw
:piwo:


Pomagam w miarę możliwości :)

Kontakt:
Discord: VenZio#8080
GG:63293490
skype:szymex1021
Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-02-04, 21:46


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

function wylaczsha()
engineRemoveShaderFromWorldTexture (roadshader"*" )
            
            destroyElement(roadshader)
            roadshader=nil
end

function wlaczsha()
    if not roadshader then roadshader dxCreateShader "roadshine.fx"0end

    dxSetShaderValueroadshader"sStrength"1.5 )
    dxSetShaderValueroadshader"sFadeEnd"maxEffectDistance )
    dxSetShaderValueroadshader"sFadeStart"maxEffectDistance/)
    engineApplyShaderToWorldTexture roadshader"*" )
end


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Tagi: function
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Function Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku