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
C-/C++-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 |
// Variablen // Matrix float4x4 matWorldViewProj; int iNumTextures = 4; string strTexturename0 = "Gras.dds"; string strTexturename1 = "Sand.dds"; string strTexturename2 = "Laub.dds"; string strTexturename3 = "Schnee.dds"; // texture1 texture Texture1; sampler TextureSampler1 = sampler_state { Texture = <Texture1>; }; // texture2 texture Texture2; sampler TextureSampler2 = sampler_state { Texture = <Texture2>; }; // texture3 texture Texture3; sampler TextureSampler3 = sampler_state { Texture = <Texture3>; }; // texture texture Texture4; sampler TextureSampler4 = sampler_state { Texture = <Texture4>; }; // ------------------------------------------------------------- // vertex shader output channels // ------------------------------------------------------------- struct VS_OUTPUT { float4 Pos: POSITION; float2 TexCoords0: TEXCOORD0; float2 TexCoords1: TEXCOORD1; float4 Color0: COLOR0; }; struct VS_INPUT { float4 Pos: POSITION; float2 TexCoords : TEXCOORD0; float4 Proportion : COLOR0; } Vertex : VERTEXDECL; // ------------------------------------------------------------- // vertex shader function (input channels) // ------------------------------------------------------------- VS_OUTPUT VS( float4 Pos: POSITION, float2 TexCoords : TEXCOORD0, float4 Proportion : COLOR0) { VS_OUTPUT Out = (VS_OUTPUT) 0; Out.Pos = mul(Pos, matWorldViewProj); // transform Position Out.TexCoords0 = TexCoords; Out.Color0 = Proportion; return Out; } // ------------------------------------------------------------- // Pixel Shader (input channels):output channel // ------------------------------------------------------------- float4 PS(float2 Tex: TEXCOORD0, float4 Color0: COLOR0) : COLOR { return ( tex2D(TextureSampler1, Tex) * Color0.x + tex2D(TextureSampler2, Tex) * Color0.y + tex2D(TextureSampler3, Tex) * (Color0.z) + tex2D(TextureSampler4, Tex) * (Color0.w)); } // ------------------------------------------------------------- // Name technique | pass | how to compile // ------------------------------------------------------------- technique TShader { pass P0 { // Texturen setzen Sampler[0] = (TextureSampler1); Sampler[1] = (TextureSampler2); Sampler[2] = (TextureSampler3); Sampler[3] = (TextureSampler4); // compiler directives VertexShader = compile vs_1_1 VS(); PixelShader = compile ps_1_4 PS(); } } |
Zitat von »"jojendersie"«
Warum nur Vertexshader
Werbeanzeige