Skip to content

Instantly share code, notes, and snippets.

@SophiePette
Created May 5, 2020 10:40
float3 cameraVec = -normalize(Parameters.CameraVector);
float3 cameraPos = ResolvedView.WorldCameraOrigin;
int raySteps = 30;
float marchingDist = 10;
float stepSize = marchingDist/raySteps;
float totalDensity = 0;
for(int i = 0; i < raySteps, i++){
float3 pos = cameraPos + cameraVec * stepSize * i;
float sample = Texture3DSample(Tex,GetMaterialSharedSampler(ShapeTexSampler,Material.Wrap_WorldGroupSettings),pos)).r;
totalDensity += sample / stepSize;
}
return totalDensity;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment