Last active
October 13, 2024 00:17
-
-
Save maluoi/a050dfcb2387034989ad24c198829162 to your computer and use it in GitHub Desktop.
A shader for StereoKit that allows for rendering side-by-side stereo textures.
This file contains 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
#include <stereokit.hlsli> | |
//--color:color = 1,1,1,1 | |
//--tex_scale = 1 | |
//--diffuse = white | |
float4 color; | |
float tex_scale; | |
Texture2D diffuse : register(t0); | |
SamplerState diffuse_s : register(s0); | |
struct vsIn { | |
float4 pos : SV_POSITION; | |
float3 norm : NORMAL0; | |
float2 uv : TEXCOORD0; | |
float4 col : COLOR0; | |
}; | |
struct psIn { | |
float4 pos : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
float4 color : COLOR0; | |
uint view_id : SV_RenderTargetArrayIndex; | |
}; | |
psIn vs(vsIn input, uint id : SV_InstanceID) { | |
psIn o; | |
o.view_id = id % sk_view_count; | |
id = id / sk_view_count; | |
float4 world = mul(input.pos, sk_inst[id].world); | |
o.pos = mul(world, sk_viewproj[o.view_id]); | |
o.uv = input.uv * tex_scale * float2(0.5,1) + float2((o.view_id+sk_eye_offset)*0.5,0); | |
o.color = input.col * color * sk_inst[id].color; | |
return o; | |
} | |
float4 ps(psIn input) : SV_TARGET { | |
float4 col = diffuse.Sample(diffuse_s, input.uv); | |
return col * input.color; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment