# render.SetRenderTargetEx

- **Ortam:** İstemci
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/render.SetRenderTargetEx
- **Çeviri tarihi:** 2025-10-24

```lua
render.SetRenderTargetEx( number rtIndex, ITexture texture = nil )
```

## Açıklama

`COLOR[n]`'nin belirtilen dizinine sahip render hedefini belirtilen rt'ye ayarlar, bu da [Çoklu Render Hedefleri (MRT)](https://learn.microsoft.com/en-us/windows/win32/direct3d9/multiple-render-targets) ile çalışmanıza olanak tanır. Standart shader'lar MRT kullanmadığı için, bunu [Shaders/screenspace_general](https://gmod.tr/wiki/Shaders/screenspace_general) adresinde faydalı bulabilirsiniz.

> **NOT:** MRT, [render.DrawScreenQuad](https://gmod.tr/wiki/render.DrawScreenQuad) gibi 2D render fonksiyonları ile çalışmaz. Bunun yerine, [cam.Start2D](https://gmod.tr/wiki/cam.Start2D) kullanarak bir [render.DrawQuad](https://gmod.tr/wiki/render.DrawQuad) render edebilirsiniz.

> **UYARI:** MSAA ile render yapmaya çalışır ve ana RenderTarget'ı başka bir RenderTarget ile ayarlarsanız, hiçbir şey render edilmeyecektir.
>
> [MRT hakkındaki Direct3D 9 dokümantasyonuna bağlantı](https://learn.microsoft.com/en-us/windows/win32/direct3d9/multiple-render-targets#:%7E:text=No%20antialiasing%20is%20supported)
>
> `Çoklu render hedeflerinin aşağıdaki kısıtlamaları vardır:`
>
> - *Kenar yumuşatma (antialiasing) desteklenmez.*

## Argümanlar

1. [number](https://gmod.tr/wiki/number) **rtIndex**: Pixel-shader'dan gelen `COLOR[n]` çıktısının [semantics](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics) dizini. Min: `0`, maks: `3`.
2. [ITexture](https://gmod.tr/wiki/ITexture) **texture** = nil: Kullanılacak yeni render hedefi.

### Örnek

2D bağlamında Çoklu Render Hedefleri:

```lua
local w, h = ScrW(), ScrH()
local tex0 = GetRenderTarget( "ExampleRT0", w, h )
local tex1 = GetRenderTarget( "ExampleRT1", w, h )

local mat = Material("pp/ssao") -- özel shader ve COLOR0, COLOR1 çıktısı olan materyaliniz
-- Ayrıntılar için https://github.com/meetric1/gmod_shader_guide/tree/main?tab=readme-ov-file#example-8---multi-render-targets adresine bakın

local quad = {
    vector_origin,
    Vector(w, 0),
    Vector(w, h),
    Vector(0, h),
}

local function DrawScreenQuadMRT()
    cam.Start2D()
        cam.IgnoreZ( true )
        render.DrawQuad(
            quad[1],
            quad[2],
            quad[3],
            quad[4]
        )
        cam.IgnoreZ( false )
    cam.End2D()
end

hook.Add( "RenderScreenspaceEffects", "2DMRT", function()
	render.SetRenderTargetEx(0, tex0)
	render.SetRenderTargetEx(1, tex1)

	render.SetMaterial(mat)
	DrawScreenQuadMRT()

	render.SetRenderTargetEx(1)
	render.SetRenderTargetEx(0)
end )
```

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/render.SetRenderTargetEx
