Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Das habe ich schon gemerktEs gibt für D3D11 keine entsprechende Funktionalität in D3DX mehr. Selber implementieren oder irgendeine Bibliothek suchen, die das bietet.
HLSL-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
texture g_Textur0; texture g_Textur1; texture g_Textur2; texture g_Textur3; float4x4 g_ViewInv : ViewInverse; float4x4 g_View : View; float4x4 g_Projection : Projection; //-------------------------------------------------------------------------------------- // Texture samplers //-------------------------------------------------------------------------------------- sampler Textur0 = sampler_state { Texture = <g_Textur0>; Filter = MIN_MAG_MIP_LINEAR; AddressU = mirror; AddressV = mirror; }; sampler Textur1 = sampler_state { Texture = <g_Textur1>; Filter = MIN_MAG_MIP_LINEAR; AddressU = mirror; AddressV = mirror; }; sampler Textur2 = sampler_state { Texture = <g_Textur2>; Filter = MIN_MAG_MIP_LINEAR; AddressU = mirror; AddressV = mirror; }; sampler Textur3 = sampler_state { Texture = <g_Textur3>; Filter = MIN_MAG_MIP_LINEAR; AddressU = mirror; AddressV = mirror; }; //-------------------------------------------------------------------------------------- // Vertex shader output structure //-------------------------------------------------------------------------------------- struct VS_OUTPUT { float4 Position : POSITION; float4 Color : Color0; // vertex texture coords float2 TexCoords : TEXCOORD0; // vertex texture coords float TexID : TEXCOORD1; }; //-------------------------------------------------------------------------------------- // Pixel shader output structure //-------------------------------------------------------------------------------------- struct PS_OUTPUT { float4 RGBColor : COLOR0; // Pixel color }; //-------------------------------------------------------------------------------------- // 2D Part //-------------------------------------------------------------------------------------- VS_OUTPUT Render2DVS(float4 Position : POSITION, float4 Color : Color0, float2 TexCoords : TEXCOORD0, float TexID : TEXCOORD1, float4 Center : TEXCOORD2) { VS_OUTPUT Output; Output.Position = Position; Output.Color = Color; Output.TexCoords = TexCoords; Output.TexID = TexID; return Output; } PS_OUTPUT Render2DPS( VS_OUTPUT In ) { PS_OUTPUT Output; if(In.TexID > 2.5) Output.RGBColor = tex2D(Textur3 ,In.TexCoords) * In.Color; else if(In.TexID > 1.5) Output.RGBColor = tex2D(Textur2 ,In.TexCoords) * In.Color; else if(In.TexID > 0.5) Output.RGBColor = tex2D(Textur1 ,In.TexCoords) * In.Color; else Output.RGBColor = tex2D(Textur0 ,In.TexCoords) * In.Color; return Output; } //-------------------------------------------------------------------------------------- // 3D Part //-------------------------------------------------------------------------------------- VS_OUTPUT Render3DVS(float4 Position : POSITION, float4 Color : Color0, float2 TexCoords : TEXCOORD0, float TexID : TEXCOORD1, float4 Center : TEXCOORD2) { VS_OUTPUT Output; float4 pos = mul(Position - Center,g_ViewInv) + Center; Output.Position = mul(mul(pos,g_View),g_Projection);; //Output.Position = mul(mul(Position,g_View),g_Projection);; Output.Color = Color; Output.TexCoords = TexCoords; Output.TexID = TexID; return Output; } PS_OUTPUT Render3DPS( VS_OUTPUT In ) { PS_OUTPUT Output; if(In.TexID > 2.5) Output.RGBColor = tex2D(Textur3 ,In.TexCoords);// * In.Color; else if(In.TexID > 1.5) Output.RGBColor = tex2D(Textur2 ,In.TexCoords);// * In.Color; else if(In.TexID > 0.5) Output.RGBColor = tex2D(Textur1 ,In.TexCoords);// * In.Color; else Output.RGBColor = tex2D(Textur0 ,In.TexCoords);// * In.Color; return Output; } PS_OUTPUT Render3DPS_ATest( VS_OUTPUT In ) { PS_OUTPUT Output; if(In.TexID > 2.5) Output.RGBColor = tex2D(Textur3 ,In.TexCoords);// * In.Color; else if(In.TexID > 1.5) Output.RGBColor = tex2D(Textur2 ,In.TexCoords);// * In.Color; else if(In.TexID > 0.5) Output.RGBColor = tex2D(Textur1 ,In.TexCoords);// * In.Color; else Output.RGBColor = tex2D(Textur0 ,In.TexCoords);// * In.Color; if(Output.RGBColor.a <= 0.0) discard; return Output; } //-------------------------------------------------------------------------------------- // Techniques //-------------------------------------------------------------------------------------- technique11 Render2DAlpha { pass P0 { SetVertexShader(CompileShader(vs_5_0, Render2DVS())); SetPixelShader(CompileShader(vs_5_0, Render2DPS())); //VertexShader = compile vs_5_0 Render2DVS(); //PixelShader = compile ps_5_0 Render2DPS(); //CullMode = none; //ZEnable = false; //AlphaBlendEnable = true; //SrcBlend = SRCALPHA; //DestBlend = INVSRCALPHA; } } technique11 Render2D { pass P0 { SetVertexShader(CompileShader(vs_5_0, Render2DVS())); SetPixelShader(CompileShader(vs_5_0, Render2DPS())); //VertexShader = compile vs_5_0 Render2DVS(); //PixelShader = compile ps_5_0 Render2DPS(); //CullMode = none; } } technique11 Render3DAlphaTest { pass P0 { SetVertexShader(CompileShader(vs_5_0, Render3DVS())); SetPixelShader(CompileShader(vs_5_0, Render3DPS_ATest())); //VertexShader = compile vs_5_0 Render3DVS(); // PixelShader = compile ps_5_0 Render3DPS_ATest(); //CullMode = none; //ZEnable = false; //AlphaBlendEnable = true; //SrcBlend = SRCALPHA; //DestBlend = INVSRCALPHA; } } technique11 Render3DAlpha { pass P0 { SetVertexShader(CompileShader(vs_5_0, Render3DVS())); SetPixelShader(CompileShader(vs_5_0, Render3DPS())); //VertexShader = compile vs_5_0 Render3DVS(); //PixelShader = compile ps_5_0 Render3DPS(); //CullMode = none; //ZEnable = false; //AlphaBlendEnable = true; //SrcBlend = SRCALPHA; //DestBlend = INVSRCALPHA; } } technique11 Render3D { pass P0 { SetVertexShader(CompileShader(vs_5_0, Render2DVS())); SetPixelShader(CompileShader(vs_5_0, Render2DPS())); //VertexShader = compile vs_5_0 Render3DVS(); //PixelShader = compile ps_5_0 Render3DPS(); //CullMode = none; } } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »dot« (19.10.2011, 13:33)
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
struct PixelInputType { float4 position : SV_POSITION; float2 tex : TEXCOORD0; }; float4 PS(PixelInputType input) : SV_TARGET { float4 textureColor; textureColor = shaderTexture.Sample(SampleType, input.tex); return textureColor; } |
Werbeanzeige