Jump to content

Pregunta con Facil de Shaders


Serginix

Recommended Posts

Posted

Bueenas, Estaba mirnado los Shaders (No deseo crear uno), solo quiero, q con un comando se vayan qactivando, por ejemplo, copies /shader_water, y se te ponga el shader del agua, por lo tanto taba haciendo esto (mriando esta parte de la Wiki y editando el Script de Shader_Water q taba en la Wiki) :

[url=https://wiki.multitheftauto.com/wiki/DxCreateShader]https://wiki.multitheftauto.com/wiki/DxCreateShader[/url] 

<---- Lei de ahi y logre:

  
addCommandHandler( "shader_water",  
    function() 
  
  
        if not myShader then 
            local myShader, tec = dxCreateShader ( "water.fx" )  
         
                 
            local textureVol = dxCreateTexture ( "images/smallnoise3d.dds" ); 
            local textureCube = dxCreateTexture ( "images/cube_env256.dds" ); 
            dxSetShaderValue ( myShader, "microflakeNMapVol_Tex", textureVol ); 
            dxSetShaderValue ( myShader, "showroomMapCube_Tex", textureCube ); 
  
            engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) 
  
            setTimer(   function() 
                            if myShader then 
                                local r,g,b,a = getWaterColor() 
                                dxSetShaderValue ( myShader, "gWaterColor", r/255, g/255, b/255, a/255 ); 
                            end 
                        end 
                        ,100,0 ) 
        else 
             
            destroyElement (myShader) 
            myShader = nil 
  
        end 
    end 
) 
  

Mas sin emabrgo solo Activa, Mas no desactiva al usar el mismo comando, no me atrevo a tocarlo mucho, dado q no se mucho de Shaders, entonces q podria hacer?

Gracias gente.

n-560x95_FFFFFF_FFFFFF_000000_000000.png

"Proyecto SX" Owner :P

Posted

Yo ya cree esto para SAUR, te dejo el codigo.

-- 
-- c_water.lua 
-- 
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        -- Version check 
        if getVersion ().sortable < "1.1.0" then 
            return 
        end 
  
        -- Create shader 
        myShader, tec = dxCreateShader ( "water.fx" ) 
        if myShader then 
            outputChatBox( "Using technique " .. tec ) 
            -- Set textures 
            local textureVol = dxCreateTexture ( "images/smallnoise3d.dds" ); 
            local textureCube = dxCreateTexture ( "images/cube_env256.dds" ); 
            dxSetShaderValue ( myShader, "microflakeNMapVol_Tex", textureVol ); 
            dxSetShaderValue ( myShader, "showroomMapCube_Tex", textureCube ); 
            enabled = false 
        end 
    end 
) 
  
function setWaterShaderEnabled(bool) 
if bool then 
    engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) 
    -- Update water color incase it gets changed by persons unknown 
    waterTimer = setTimer(  function() 
            if myShader then 
            local r,g,b,a = getWaterColor() 
            dxSetShaderValue ( myShader, "gWaterColor", r/255, g/255, b/255, a/255 ); 
        end 
    end 
    ,100,0 ) 
else 
    if isTimer(waterTimer) then killTimer(waterTimer) end 
    engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) 
    end 
enabled = bool 
end 
  
addCommandHandler("shader_water", 
function () 
     setWaterShaderEnabled(not enabled) 
end) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

De nada, espero te funcione (a mi me funciona, pero no lo uso asi).

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

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