Raymarching Cleanup
Removed redundant code from raymarching implementation Moved last remaining raymarching variable (Extinction) to environment settings
This commit is contained in:
parent
e585a8c3b1
commit
d61d2f19ed
150 changed files with 187 additions and 8921 deletions
31
Assets/Shaders/Raymarching/CloudNormalRaymarch.cginc
Normal file
31
Assets/Shaders/Raymarching/CloudNormalRaymarch.cginc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include "./CloudShaderHelper.cginc"
|
||||
|
||||
float GetDensity(float3 startPos, float3 dir, float maxSampleDistance, float raymarchOffset, out float3 intensity,out float depth) {
|
||||
float raymarchDistance = 0;
|
||||
|
||||
RaymarchStatus result;
|
||||
InitRaymarchStatus(result);
|
||||
|
||||
[loop]
|
||||
for (int j = 0; j < SAMPLE_COUNT; j++) {
|
||||
float prevRayDist = raymarchDistance;
|
||||
raymarchDistance = pow((j+raymarchOffset)/SAMPLE_COUNT,2) * _ProjectionParams.z;
|
||||
if(raymarchDistance > maxSampleDistance) break;
|
||||
float step = raymarchDistance - prevRayDist;
|
||||
float3 rayPos = startPos + dir * raymarchDistance;
|
||||
float fade = smoothstep(_ProjectionParams.z*.95,_ProjectionParams.z, raymarchDistance);
|
||||
IntegrateRaymarch(startPos, rayPos, fade, step, result);
|
||||
if (result.intTransmittance < 0.01f) {
|
||||
result.intTransmittance = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
depth = result.depth / result.depthweightsum / _ProjectionParams.z;
|
||||
if (depth == 0.0f) {
|
||||
depth = maxSampleDistance;
|
||||
}
|
||||
intensity = result.intensity;
|
||||
return (1.0f - result.intTransmittance);
|
||||
}
|
||||
Loading…
Reference in a new issue