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
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 |
Texture2DArray<float4> SplatTextureArray : register(t1); Texture2D<float4> BlendTexture : register(t2); float2 GetBlendValAndWorldTextureSize(float val) { float2 ret; ret.x = frac(val) * 10; // blend weight auslesen ret.y = 512.f / floor(val); // UV Multiplier um die Wiederholung der Textur zu bestimmen return ret; } uint3 GetIndices(uint indices) { uint3 retval; retval.x = indices & 256; retval.y = (indices>>8) & 256; retval.z = (indices>>16) & 256; return retval; } float4 GetColour(int3 index, SamplerState splattexturarraystate, float2 uv) { float4 blendinfo = BlendTexture.Load(index & 255); uint3 indices = GetIndices((uint)blendinfo.w); float2 blend = GetBlendValAndWorldTextureSize(blendinfo[0]); float4 result = SplatTextureArray.Sample(splattexturarraystate, float3(uv * blend.y, indices[0])); [unroll] for(uint i = 1; i < 3; ++i) { blend = GetBlendValAndWorldTextureSize(blendinfo[i]); if(blend.x) { result = lerp(result, SplatTextureArray.Sample(splattexturarraystate, float3(uv * blend.y, indices[i])), blend.x); } } return result; } float4 TerrainFragmentShader(TerrainVSOutput inputval, uniform SamplerState splattexturarraystate : TEXUNIT1) : SV_TARGET { float2 uv = inputval.sPosition.xz / 511; int3 index = int3((int2)(frac(inputval.sTexCoords) * 256), 0); float4 tl = GetColour(index, splattexturarraystate, uv); float4 tr = GetColour(index + int3(1, 0, 0), splattexturarraystate, uv); float4 bl = GetColour(index + int3(0, 1, 0), splattexturarraystate, uv); float4 br = GetColour(index + int3(1, 1, 0), splattexturarraystate, uv); float2 lf = frac(inputval.sTexCoords * 256); float4 result = lerp(lerp(tl, tr, lf.x), lerp(bl, br, lf.x), lf.y); return result; } |