Jump to content

add script "shader_block_world" to map [DD] minecraft


R0drig0SC

Recommended Posts

how do I start this resource with the map?

wanted to make a map style minecraft, someone can make this work?

como faço para esse resource iniciar com o mapa?

queria fazer um mapa minecraft, alguem pode fazer isso funcionar?

block_world.fx

// 
// block_world.fx 
// 
  
  
/////////////////////////////////////////////////////////////////////////////// 
// Global variables 
/////////////////////////////////////////////////////////////////////////////// 
float gRes : RES = 0.125; 
float gTime : TIME; 
float4 gColorize : COLORIZE; 
  
//------------------------------------------------------------------------------------------ 
// textureState - String value should be a texture number followed by 'Texture' 
//------------------------------------------------------------------------------------------ 
texture gTexture0           < string textureState="0,Texture"; >; 
  
  
//--------------------------------------------------------------------- 
// Sampler for the main texture 
//--------------------------------------------------------------------- 
sampler Sampler0 = sampler_state 
{ 
    Texture         = (gTexture0); 
    MinFilter       = Linear; 
    MagFilter       = Linear; 
    MipFilter       = Linear; 
}; 
  
//--------------------------------------------------------------------- 
// Structure of data sent to the pixel shader ( from the vertex shader ) 
//--------------------------------------------------------------------- 
struct PixelShaderInput 
{ 
    float4 Position : POSITION; 
    float4 Diffuse : COLOR0; 
    float2 TexCoord0: TEXCOORD0; 
}; 
  
  
//------------------------------------------------------------------------------------------ 
// PixelShaderFunction 
//------------------------------------------------------------------------------------------ 
float4 PixelShaderFunction(PixelShaderInput In) : COLOR0 
{ 
    float4 OutColor = 0; 
  
    // Remove lower bits in texture coords 
    float2 uv = In.TexCoord0 - fmod(In.TexCoord0,gRes); 
    float4 texel = tex2D(Sampler0, uv); 
  
    // Use full precision for sampling the alpha 
    float alpha = tex2D(Sampler0, In.TexCoord0).a; 
  
    // Modulate texture with lighting and colorization value 
    OutColor = texel * In.Diffuse * gColorize; 
    OutColor.a = alpha; 
  
    return OutColor; 
} 
  
  
/////////////////////////////////////////////////////////////////////////////// 
// Techniques 
/////////////////////////////////////////////////////////////////////////////// 
technique tec0 
{ 
    pass P0 
    { 
        PixelShader  = compile ps_2_0 PixelShaderFunction(); 
    } 
} 
  

c_block_world

-- 
-- c_block_world.lua 
-- 
  
local shaderList = {} 
local colorizeOff = false 
  
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 to test for any errors 
        local testShader, tec = dxCreateShader ( "block_world.fx" ) 
  
        if not testShader then 
            outputChatBox( "Could not create shader. Please use debugscript 3" ) 
        else 
            outputChatBox( "Using technique " .. tec ) 
  
            -- Create 26 shaders and apply each one to some world textures 
            for c=65,96 do 
                local clone = dxCreateShader ( "block_world.fx" ) 
                engineApplyShaderToWorldTexture ( clone, string.format( "%c*", c )  ) 
                shaderList[#shaderList+1] = clone 
            end 
  
            -- Initial colors 
            colorize() 
  
            outputChatBox( "Press 'k' to colorize" ) 
        end 
    end 
) 
  
  
---------------------------------------------------------------- 
-- Do change 
---------------------------------------------------------------- 
function colorize() 
    colorizeOff = not colorizeOff 
    for _,shader in ipairs(shaderList) do 
        local r,g,b = 0,0,0 
        while r+g+b < 2 do 
            r,g,b = math.random(0.25,1.25),math.random(0.25,1.25),math.random(0.25,1.25) 
        end 
        if colorizeOff then 
            r,g,b = 1,1,1 
        end 
        dxSetShaderValue ( shader, "COLORIZE", r,g,b ) 
    end 
end 
  
bindKey("k", "down", colorize ) 
  

    type="map" version="1.0.0">
    "[DD] minecraft.map" dimension="0">
    
        "#minplayers" value="[ 0 ]">
        "#maxplayers" value="[ 128 ]">
        "#gravity" value="[ 0.008000 ]">
        "#weather" value="[ 1 ]">
        "#time" value="12:0">
        "#locked_time" value="[ true ]">
        "#waveheight" value="[ 0 ]">
        "#gamespeed" value="[ 1 ]">
    
        

======================================================================

this worked!

but with "shader_block_world" failed

    

sorry for my bad english

sorry for my bad english

sorry for my bad english

sorry for my bad english

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