![]() |
DirectX-Forum - Beitragsübersicht - |
|
Thema | DX8: analglyph |
Von |
(Nick-)Name |
Datum |
05. Juli 2011 um 17:38:26 |
Frage |
Hi Was ist in DirectX8 die schnellste Methode für Anaglyph 3D? LG |
|
Antwort: |
Von |
Nico |
E-Mail |
nico.schertler@studentpartners.de |
Datum |
05. Juli 2011 um 20:06:22 |
Antwort |
Hi,
ich hatte vor einiger Zeit dazu auch einen Shader geschrieben. Er bekommt die beiden Bilder als Texturen und die Einfärbung der Bilder (i.A. ist das rot/cyan, geht aber natürlich auch anders). Gerendert werden sollte das ganze als Fullscreen-Quad. Bei DX8 musst du da aber wegen der Texturkoordinaten aufpassen.
Nicotexture tex1; sampler tex1Sampler = sampler_state {Texture = tex1; minfilter = POINT; magfilter = POINT; mipfilter = POINT; AddressU = Wrap; AddressV = Wrap;}; texture tex2; sampler tex2Sampler = sampler_state {Texture = tex2; minfilter = POINT; magfilter = POINT; mipfilter = POINT; AddressU = Wrap; AddressV = Wrap;}; float4 Color1, Color2; struct VSIN { float4 Position : POSITION; float2 TextureCoordinates : TEXCOORD0; }; struct VSOUT { float4 Position : POSITION; float2 TextureCoordinates : TEXCOORD0; }; VSOUT VS(VSIN Input) { Return Input; } float4 PS_grauanaglyph(VSOUT Input) : COLOR { float4 FinalColor; float3 c1 = tex2D(tex1Sampler, Input.TextureCoordinates).rgb; float3 c2 = tex2D(tex2Sampler, Input.TextureCoordinates).rgb; FinalColor.rgb = (c1.r+c1.g+c1.b)/3 * Color1.rgb + (c2.r+c2.g+c2.b)/3 * Color2.rgb; FinalColor.a=1; Return FinalColor; } float4 PS_farbanaglyph(VSOUT Input) : COLOR { float4 FinalColor; float3 c1 = tex2D(tex1Sampler, Input.TextureCoordinates).rgb; float3 c2 = tex2D(tex2Sampler, Input.TextureCoordinates).rgb; FinalColor.rgb = c1 * Color1.rgb + c2 * Color2.rgb; FinalColor.a=1; Return FinalColor; } PixelShader shaders[2] = { compile ps_3_0 PS_grauanaglyph(), compile ps_3_0 PS_farbanaglyph() }; int techID = 1; technique Anaglyph { pass P0 { VertexShader = compile vs_3_0 VS(); PixelShader = (shaders[techID]); } } |
|
[ Antwort schreiben | Zurück zum DirectX-Forum | Forum-Hilfe ] |
|
Letzte Aktualisierung: Sonntag, 13. Dezember 2015 |
|