Hikayeler

Reklam vermek için turkmmo@gmail.com

N2PLAY – Complete Files by Sasori [Merry Christmas 2025]🎁 protobuflu

Ekli dosyalar

  • ModelShader.rar
    2.9 KB · Görüntüleme: 0
  • metalcialiSimpleModelShader.rar
    2.7 KB · Görüntüleme: 0
  • renkdoygunuluguflaan varSimpleModelShader.rar
    2.7 KB · Görüntüleme: 0
  • SimpleModelShader.rar
    3.5 KB · Görüntüleme: 0
after
1770641221542.png

before
1770641443206.png
 
up2


source\root\shaders
SimpleModelShader.fx


Kod:
// ==================================================================================
//  MODERNIZED GRANNY SHADER - ULTRA (SATURATION + RIM + ACES + HD SPECULAR)
// ==================================================================================

// ----------------------------------------------------------------------------------
// AYARLAR (Buradan renkleri kısıp açabilirsin)
// ----------------------------------------------------------------------------------
static const float g_Saturation    = 1.3f;  // Renk Doygunluğu (1.0 = Normal, 1.5 = Çok Canlı)
static const float g_Contrast      = 1.1f;  // Kontrast (1.0 = Normal)
static const float g_Brightness    = 1.1f;  // Parlaklık
static const float g_SpecularBoost = 2.0f;  // Parlama Şiddeti (Arttırıldı)

// ----------------------------------------------------------------------------------
// YENİ EKLENEN UNIFORM DEĞİŞKENLER (C++ Tarafı ile Uyumlu)
// ----------------------------------------------------------------------------------
float4 g_vRimColor      = {0.7f, 0.7f, 0.7f, 0.7f}; // Kenar Işığı Rengi (Mavimsi beyaz)
float  g_fRimPower      = 2.5f;                     // Kenar Işığı Keskinliği
float4 g_metallicParams = {1.0f, 0.7f, 0.0f, 0.0f}; // x: Metaliklik, y: Pürüzsüzlük
float4 g_vCinemaParams  = {1.0f, 0.0f, 0.0f, 0.0f}; // x: ToneMapping Gücü

// ----------------------------------------------------------------------------------
// STRUCTS
// ----------------------------------------------------------------------------------
struct VS_IN
{
    float3  Position        : POSITION0;
    float4  BoneWeights     : BLENDWEIGHT;
    float4  BoneIndices     : BLENDINDICES;
    float3  Normal          : NORMAL;
    float3  Tangent         : TANGENT;
    float3  Binormal        : BINORMAL;
    float2  Tex0            : TEXCOORD0;
};

struct VS_IN_RIGID
{
    float3  Position        : POSITION0;
    float3  Normal          : NORMAL;
    float3  Tangent         : TANGENT;
    float3  Binormal        : BINORMAL;
    float2  Tex0            : TEXCOORD0;
};

struct VS_IN_RIGID_2
{
    float3  Position        : POSITION0;
    float3  Normal          : NORMAL;
    float3  Tangent         : TANGENT;
    float3  Binormal        : BINORMAL;
    float2  Tex0            : TEXCOORD0;
    float2  Tex1            : TEXCOORD1;
};

// Güncellenmiş VS_OUT - Rim Light için ek bilgiler
struct VS_OUT
{
    float4 Position         : POSITION;
    float4 Diffuse          : COLOR0;
    float2 Tex0             : TEXCOORD0;
    float2 TexSpec          : TEXCOORD1;
    float  FogValue         : TEXCOORD2;
    float3 WorldNormal      : TEXCOORD3; // Rim için Normal
    float3 ViewDir          : TEXCOORD4; // Rim için Bakış Yönü
};

struct VS_OUT_2
{
    float4 Position         : POSITION;
    float4 Diffuse          : COLOR0;
    float2 Tex0             : TEXCOORD0;
    float2 Tex1             : TEXCOORD1;
    float2 TexSpec          : TEXCOORD2;
    float  FogValue         : TEXCOORD3;
    float3 WorldNormal      : TEXCOORD4; // Rim için Normal
    float3 ViewDir          : TEXCOORD5; // Rim için Bakış Yönü
};

// ----------------------------------------------------------------------------------
// GLOBAL DEĞİŞKENLER
// ----------------------------------------------------------------------------------
float4x3 ObjToWorld;
float4x4 g_viewProj;
float3   g_vCameraPos;
float3   DirFromLight       = {0.5f, 1.0f, 0.5f};
float4   LightColour        = {1.0f, 0.9f, 0.8f, 1.0f}; // Sıcak ışık
float4   g_vDiffuseColor    = {1.0f, 1.0f, 1.0f, 1.0f};
float3   g_vFogColor;       
float3   g_vFogParams       = {300.0f, 2000.0f, 1700.0f};
float4   g_vMaterialDiffuse = {1.0f, 1.0f, 1.0f, 1.0f};
float4   g_vMaterialAmbient = {0.4f, 0.4f, 0.4f, 1.0f}; // Artırılmış ambient
float4x3 BoneMatrices[65];
float4x4 g_mViewToLightProj;
float    g_fAlphaValue      = 1.0f;
float4x4 shadowTexMatrix;
float3x3 g_specularMat;
bool     g_specularEnable   = false;
float    g_specularPower    = 16.0f; // Daha yüksek specular power

// ----------------------------------------------------------------------------------
// YARDIMCI FONKSİYONLAR
// ----------------------------------------------------------------------------------

// ACES Tone Mapping (Sinematik renk paleti)
float3 ACESFilm(float3 x)
{
    float a = 2.51f;
    float b = 0.03f;
    float c = 2.43f;
    float d = 0.59f;
    float e = 0.14f;
    return saturate((x*(a*x+b))/(x*(c*x+d)+e));
}

// Gelişmiş Renk İşleme Fonksiyonu (Doygunluk, Kontrast, Tone Mapping)
float3 ApplyColorGrading(float3 color)
{
    // 1. Doygunluk (Saturation)
    float3 luminanceWeights = float3(0.299, 0.587, 0.114);
    float grey = dot(color, luminanceWeights);
    color = lerp(grey, color, g_Saturation);

    // 2. Kontrast
    color = (color - 0.5f) * g_Contrast + 0.5f;

    // 3. Parlaklık
    color *= g_Brightness;

    // 4. ACES Tone Mapping (Eğer aktifse)
    if(g_vCinemaParams.x > 0.5f) {
        color = ACESFilm(color);
    }

    return saturate(color);
}

// Rim Lighting Hesaplama
float3 CalculateRimLight(float3 normal, float3 viewDir, float3 baseColor)
{
    float rimTerm = 1.0f - saturate(dot(normal, viewDir));
    rimTerm = pow(rimTerm, g_fRimPower);
    float3 rimColor = rimTerm * g_vRimColor.rgb * g_vRimColor.a;
    
    // Rim ışığını hafifçe uygula
    return baseColor + (rimColor * 0.5f);
}

void CalcDiffuseLight( float3 lightDir, float3 normal, float4 ambient, float4 diffuse, out float4 oDiffuse)
{
    float ndotl = saturate( dot( normal, lightDir ) );
    oDiffuse = ndotl * diffuse + (ambient * 0.5f);       
}

float FogValue(float fPoint)
{
    float fFogEnd = g_vFogParams.y;
    float fFogDist = g_vFogParams.z;
    return saturate((fFogEnd - fPoint) / fFogDist);
}

// ----------------------------------------------------------------------------------
// SAMPLERS
// ----------------------------------------------------------------------------------
texture diffuse_texture;
sampler2D diffuse_sampler = sampler_state
{
    Texture = <diffuse_texture>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
};

texture opacity_texture;
sampler2D opacity_sampler = sampler_state
{
    Texture = <opacity_texture>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
};

texture g_specularTex;
sampler2D specular_sampler = sampler_state
{
    Texture = <g_specularTex>;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    AddressU = WRAP;
    AddressV = WRAP;
};

texture g_txShadow;
sampler2D g_samShadow = sampler_state
{
    Texture = <g_txShadow>;
    MinFilter = Point;
    MagFilter = Point;
    MipFilter = Point;
    AddressU = Clamp;
    AddressV = Clamp;
};

// ----------------------------------------------------------------------------------
// VERTEX SHADERS
// ----------------------------------------------------------------------------------

VS_OUT SkinnedVS( VS_IN In )
{
    VS_OUT Out;
    float4 InPos     = float4( In.Position, 1 );
    float4 InNormal  = float4( In.Normal, 0 );
    float3 WorldPos    = 0;
    float3 WorldNormal = 0;
    int BoneIndices[4]   = (int[4])In.BoneIndices;

    for( int i = 0; i < 4; ++i )
    {
        float4x3 BoneMatrix = BoneMatrices[BoneIndices[i]];
        WorldPos    += In.BoneWeights[i] * mul( InPos, BoneMatrix );
        WorldNormal += In.BoneWeights[i] * mul( InNormal, BoneMatrix );
    }

    float4 ClipPos = mul(float4(WorldPos, 1), g_viewProj);

    float3 l = normalize( -DirFromLight );
    float3 n = normalize( WorldNormal );
    
    CalcDiffuseLight( l, n, g_vMaterialAmbient, LightColour * g_vMaterialDiffuse, Out.Diffuse );

    Out.Position   = ClipPos;
    Out.Tex0       = In.Tex0;
    Out.FogValue   = FogValue(Out.Position.z);
    
    // Rim lighting için ekstra hesaplamalar
    Out.WorldNormal = n;
    Out.ViewDir = normalize(g_vCameraPos - WorldPos);
    
    float3 EyeVec = g_vCameraPos.xyz - WorldPos.xyz;
    Out.TexSpec   = mul(reflect(normalize(EyeVec), n), g_specularMat).xy;

    return Out;
}

VS_OUT RigidVS( VS_IN_RIGID In )
{
    VS_OUT Out;
    float3 WorldPos = mul(float4(In.Position, 1), ObjToWorld);
    float4 ClipPos  = mul(float4(WorldPos, 1), g_viewProj);
    float4 InNormal = float4( In.Normal, 0);
    float3 ObjNormal = mul(InNormal, ObjToWorld);
    float3 l = normalize( -DirFromLight );
    float3 n = normalize( ObjNormal );
    
    CalcDiffuseLight( l, n, g_vMaterialAmbient, LightColour * g_vMaterialDiffuse, Out.Diffuse );

    Out.Position = ClipPos;
    Out.Tex0     = In.Tex0;
    Out.FogValue = FogValue(Out.Position.z);
    
    // Rim lighting için ekstra hesaplamalar
    Out.WorldNormal = n;
    Out.ViewDir = normalize(g_vCameraPos - WorldPos);
    
    float3 EyeVec = g_vCameraPos.xyz - WorldPos.xyz;
    Out.TexSpec  = mul(reflect(normalize(EyeVec), n), g_specularMat).xy;

    return Out;
}

VS_OUT_2 RigidVS2( VS_IN_RIGID_2 In )
{
    VS_OUT_2 Out;
    float3 WorldPos = mul(float4(In.Position, 1), ObjToWorld);
    float4 ClipPos  = mul(float4(WorldPos, 1), g_viewProj);
    float4 InNormal = float4( In.Normal, 0);
    float3 ObjNormal = mul(InNormal, ObjToWorld);
    float3 l = normalize( -DirFromLight );
    float3 n = normalize( ObjNormal );
    
    CalcDiffuseLight( l, n, g_vMaterialAmbient, LightColour * g_vMaterialDiffuse, Out.Diffuse );

    Out.Position = ClipPos;
    Out.Tex0     = In.Tex0;
    Out.Tex1     = In.Tex1;
    Out.FogValue = FogValue(Out.Position.z);
    
    // Rim lighting için ekstra hesaplamalar
    Out.WorldNormal = n;
    Out.ViewDir = normalize(g_vCameraPos - WorldPos);
    
    float3 EyeVec = g_vCameraPos.xyz - WorldPos.xyz;
    Out.TexSpec  = mul(reflect(normalize(EyeVec), n), g_specularMat).xy;

    return Out;
}

void SkinnedShadowVS( VS_IN In, out float4 oPos : POSITION, out float2 Depth : TEXCOORD0 )
{
    float BoneWeights[4] = (float[4])In.BoneWeights;
    int BoneIndices[4]   = (int[4])In.BoneIndices;
    float4 InPos     = float4( In.Position, 1 );
    float4 InNormal  = float4( In.Normal, 0 );
    float3 WorldPos    = 0;
    float3 WorldNormal = 0;

    for( int i = 0; i < 4; ++i )
    {
        float4x3 BoneMatrix = BoneMatrices[BoneIndices[i]];
        WorldPos    += BoneWeights[i] * mul( InPos, BoneMatrix );
        WorldNormal += BoneWeights[i] * mul( InNormal, BoneMatrix );
    }

    float4 ClipPos = mul(float4(WorldPos, 1), g_viewProj);
    oPos = ClipPos;
    Depth = ClipPos.zw;
}

void RigidShadowVS( VS_IN_RIGID In, out float4 oPos : POSITION, out float2 Depth : TEXCOORD0 )
{
    float3 WorldPos = mul(float4(In.Position, 1), ObjToWorld);
    float4 ClipPos  = mul(float4(WorldPos, 1), g_viewProj);
    oPos = ClipPos;
    Depth = ClipPos.zw;
}

// ----------------------------------------------------------------------------------
// PIXEL SHADERS (Geliştirilmiş - Rim + ACES + HD Specular)
// ----------------------------------------------------------------------------------

float4 ModernGrannyPS ( VS_OUT In ) : COLOR
{
    if(In.FogValue <= 0.0f) discard;

    float4 baseColor = tex2D( diffuse_sampler, In.Tex0 );
    float4 specularColor = tex2D(specular_sampler, In.TexSpec);

    // Temel Renk
    float3 color = baseColor.rgb * In.Diffuse.rgb;

    // Rim Lighting Uygula
    color = CalculateRimLight(normalize(In.WorldNormal), normalize(In.ViewDir), color);

    // Gelişmiş HD Parlama
    float3 specular = baseColor.a * specularColor.rgb * g_specularPower * g_SpecularBoost;
    
    // Metalik efekt (eğer aktifse)
    if (g_metallicParams.x > 0.0f) {
        specular = lerp(specular, baseColor.rgb * specular, g_metallicParams.x);
    }
    
    color += specular;

    // Gelişmiş Renk İşleme (Doygunluk + Kontrast + ACES)
    color = ApplyColorGrading(color);

    // Sis Uygula
    color = lerp(g_vFogColor, color, In.FogValue);
    
    // Global Diffuse (Oyun motoru rengi) ile çarp
    color *= g_vDiffuseColor.rgb;

    return float4( color, In.Diffuse.a );
}


float4 ModernGrannyPSOpacity ( VS_OUT In ) : COLOR
{
    if(In.FogValue <= 0.0f) discard;
        
    float4 baseColor = tex2D( diffuse_sampler, In.Tex0 );
    float4 specularColor = tex2D(specular_sampler, In.TexSpec);

    float3 color = baseColor.rgb * In.Diffuse.rgb;
    
    // Rim Lighting
    color = CalculateRimLight(normalize(In.WorldNormal), normalize(In.ViewDir), color);
    
    // Gelişmiş Parlama
    float3 specular = baseColor.a * specularColor.rgb * g_specularPower * g_SpecularBoost;
    
    if (g_metallicParams.x > 0.0f) {
        specular = lerp(specular, baseColor.rgb * specular, g_metallicParams.x);
    }
    
    color += specular;

    // Gelişmiş Renk İşleme
    color = ApplyColorGrading(color);

    // Sis
    color = lerp(g_vFogColor, color, In.FogValue);
    color *= g_vDiffuseColor.rgb;

    return float4(color, baseColor.a);
}


float4 ModernGrannyPS2 ( VS_OUT_2 In ) : COLOR
{
    if(In.FogValue <= 0.0f) discard;
        
    float4 baseColor = tex2D( diffuse_sampler, In.Tex0 );
    float4 specularColor = tex2D(specular_sampler, In.TexSpec);
    float4 tex2Color = tex2D( opacity_sampler, In.Tex1 );

    float3 color = baseColor.rgb * In.Diffuse.rgb;
    
    // Rim Lighting
    color = CalculateRimLight(normalize(In.WorldNormal), normalize(In.ViewDir), color);
    
    // Gelişmiş Parlama
    float3 specular = baseColor.a * specularColor.rgb * g_specularPower * g_SpecularBoost;
    
    if (g_metallicParams.x > 0.0f) {
        specular = lerp(specular, baseColor.rgb * specular, g_metallicParams.x);
    }
    
    color += specular;

    // İkinci texture ile karıştır
    color *= tex2Color.rgb;

    // Gelişmiş Renk İşleme
    color = ApplyColorGrading(color);

    // Sis
    color = lerp(g_vFogColor, color, In.FogValue);
    color *= g_vDiffuseColor.rgb;

    return float4(color, In.Diffuse.a);
}


float4 ModernGrannyPSBlend2 ( VS_OUT_2 In ) : COLOR
{
    if(In.FogValue <= 0.0f) discard;
    if(g_fAlphaValue < 0.1f) discard;

    float4 baseColor = tex2D( diffuse_sampler, In.Tex0 );
    float4 tex2Color = tex2D( opacity_sampler, In.Tex1 );

    float3 color = baseColor.rgb * In.Diffuse.rgb;
    
    // Rim Lighting (şeffaf objelerde daha hafif)
    color = CalculateRimLight(normalize(In.WorldNormal), normalize(In.ViewDir), color);
    color = color * 0.7f + baseColor.rgb * In.Diffuse.rgb * 0.3f;

    // İkinci texture etkisi
    color *= tex2Color.rgb;

    // Renk Ayarları
    color = ApplyColorGrading(color);

    // Sis
    color = lerp(g_vFogColor, color, In.FogValue);
    color *= g_vDiffuseColor.rgb;

    return float4(color, baseColor.a * In.Diffuse.a);
}


float4 ModernGrannyPSBlend ( VS_OUT In ) : COLOR
{
    if(In.FogValue <= 0.0f) discard;
    if(g_fAlphaValue < 0.1f) discard;

    float4 baseColor = tex2D( diffuse_sampler, In.Tex0 );
    float4 specularColor = tex2D(specular_sampler, In.TexSpec);

    float3 color = baseColor.rgb * In.Diffuse.rgb;
    
    // Rim Lighting (şeffaf objelerde daha hafif)
    color = CalculateRimLight(normalize(In.WorldNormal), normalize(In.ViewDir), color);
    
    // Parlama
    float3 specular = baseColor.a * specularColor.rgb * g_specularPower * g_SpecularBoost;
    
    if (g_metallicParams.x > 0.0f) {
        specular = lerp(specular, baseColor.rgb * specular, g_metallicParams.x);
    }
    
    color += specular;

    // Renk Ayarları
    color = ApplyColorGrading(color);

    // Sis
    color = lerp(g_vFogColor, color, In.FogValue);
    color *= g_vDiffuseColor.rgb;

    return float4(color, g_fAlphaValue);
}


float4 GrannyShadowPS( float4 oPos : POSITION, float2 Depth : TEXCOORD0) : COLOR
{
    float fColor = Depth.x / Depth.y;
    return float4( fColor, fColor, fColor, 1.f );
}

// ----------------------------------------------------------------------------------
// TECHNIQUES (Modern versiyonlarla güncellendi)
// ----------------------------------------------------------------------------------

technique Rigid
{
    pass Base
    {
        CullMode = None;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 RigidVS();
        PixelShader = compile ps_3_0 ModernGrannyPS();
    }

    pass Shadow
    {
        VertexShader = compile vs_3_0 RigidShadowVS();
        PixelShader = compile ps_3_0 GrannyShadowPS();
    }

    pass Blend
    {
        CullMode = None;
        AlphaBlendEnable = true;
        ZEnable = true;
        ZWriteEnable = false;
        SrcBlend = SrcAlpha;
        DestBlend = InvSrcAlpha;
        BlendOp = Add;
        VertexShader = compile vs_3_0 RigidVS();
        PixelShader = compile ps_3_0 ModernGrannyPSBlend();
    }

    pass Opacity
    {
        CullMode = None;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        AlphaTestEnable = true;
        AlphaFunc = Greater;
        AlphaRef = 0;
        VertexShader = compile vs_3_0 RigidVS();
        PixelShader = compile ps_3_0 ModernGrannyPSOpacity();
    }
    
    pass Object
    {
        CullMode = CW;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 RigidVS();
        PixelShader = compile ps_3_0 ModernGrannyPS();
    }
}

technique Skinned
{
    pass P0
    {
        CullMode = none;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 SkinnedVS();
        PixelShader = compile ps_3_0 ModernGrannyPS();
    }

    pass P1
    {
        VertexShader = compile vs_3_0 SkinnedShadowVS();
        PixelShader = compile ps_3_0 GrannyShadowPS();
    }
    
    pass P2
    {
        ZEnable = true;
        ZWriteEnable = true;
        CullMode = none;
        AlphaBlendEnable = true;
        SrcBlend = SrcAlpha;
        DestBlend = InvSrcAlpha;
        BlendOp = Add;
        VertexShader = compile vs_3_0 SkinnedVS();
        PixelShader = compile ps_3_0 ModernGrannyPSBlend();
    }

    pass Opacity
    {
        CullMode = none;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        AlphaTestEnable = true;
        AlphaFunc = Greater;
        AlphaRef = 0;
        VertexShader = compile vs_3_0 SkinnedVS();
        PixelShader = compile ps_3_0 ModernGrannyPSBlend();
    }
    
    pass Object
    {
        CullMode = CW;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 SkinnedVS();
        PixelShader = compile ps_3_0 ModernGrannyPS();
    }
}

technique RigidTwoTexture
{
    pass Base
    {
        CullMode = none;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 RigidVS2();
        PixelShader = compile ps_3_0 ModernGrannyPS2();
    }

    pass Shadow
    {
        VertexShader = compile vs_3_0 RigidShadowVS();
        PixelShader = compile ps_3_0 GrannyShadowPS();
    }

    pass Blend
    {
        CullMode = none;
        AlphaBlendEnable = true;
        ZEnable = true;
        ZWriteEnable = false;
        SrcBlend = SrcAlpha;
        DestBlend = InvSrcAlpha;
        BlendOp = Add;
        VertexShader = compile vs_3_0 RigidVS2();
        PixelShader = compile ps_3_0 ModernGrannyPSBlend2();
    }

    pass Opacity
    {
        CullMode = none;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        AlphaBlendEnable = false;
        VertexShader = compile vs_3_0 RigidVS2();
        PixelShader = compile ps_3_0 ModernGrannyPS2();
    }
    
    pass Object
    {
        CullMode = CW;
        AlphaBlendEnable = false;
        ZEnable = true;
        ZWriteEnable = true;
        VertexShader = compile vs_3_0 RigidVS2();
        PixelShader = compile ps_3_0 ModernGrannyPS2();
    }
}
 
up
gündüz

gece
 

Şu an konuyu görüntüleyenler (Toplam : 1, Üye: 0, Misafir: 1)

Geri
Üst