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
| float CustomFakeVoxelPyramidLight(float3 origin,float3 direction, float d, float r0, float r1) {
float3 normals[6] = { float3(0, 0, 1), float3(0, 0, -1), float3(1, 0, (r1 - r0)/(2.0f * d)), float3(0, 1, (r1 - r0)/(2.0f * d)), float3(-1, 0, (r1 - r0)/(2.0f * d)), float3(0, -1, (r1 - r0)/(2.0f * d)) }; float3 pPoints[6] = { float3(0, 0, d / 2.0), float3(0, 0, -d / 2.0), float3(r0 / 4.0 + r1 /4.0, 0, 0), float3(0, r0 /4.0 + r1 / 4.0, 0), float3(-r1 / 4.0 - r0 / 4.0, 0, 0), float3(0, -r1 / 4.0 - r0/4.0, 0) };
float t = FLT_MAX; float2 minLen = float2(FLT_MAX,FLT_MAX); float flag = false; float mid = 0; float z_length = 0; float test =0; for (int i = 0; i <6; ++i) { float tempT; if (IntersectRayPlane(normals[i], pPoints[i], origin,direction, tempT)) { float3 tempPoint = origin + tempT * direction; float2 len = IsPointInPrism(tempPoint, r0, r1, d,i); } }
float3 hitPoint = origin + t * direction; float3 hitPoint_mid = origin + z_length * direction/2; return smoothstep(0,0.3,mid) * smoothstep(0,_LightLengthFade,1-(d/2 -hitPoint_mid.z)/d); }
|