Created
August 6, 2013 19:23
-
-
Save aras-p/6167714 to your computer and use it in GitHub Desktop.
ARB_texture_swizzle "emulation" for D3D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform float4 weightsR; // default 1,0,0,0 | |
uniform float4 weightsG; // default 0,1,0,0 | |
uniform float4 weightsB; // default 0,0,1,0 | |
uniform float4 weightsA; // default 0,0,0,1 | |
float4 swizzledTex2D (sampler2D smp, float2 uv) | |
{ | |
float4 smp = tex2D (mysampler, myuv); | |
float4 res; | |
res.r = dot(smp,weightsR); | |
res.g = dot(smp,weightsG); | |
res.b = dot(smp,weightsB); | |
res.a = dot(smp,weightsA); | |
return res; | |
} | |
// for example to splat just R channel of a texture into all four channels, set up | |
// weightsR..A to all be (1,0,0,0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment