Skip to content

Commit

Permalink
refactor and move camera up
Browse files Browse the repository at this point in the history
  • Loading branch information
MadrMan committed Jun 11, 2012
1 parent 5a007e4 commit 08507f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gpuraytrace/Graphics/Camera.cpp
Expand Up @@ -8,7 +8,7 @@

Camera::Camera()
{
position = XMVectorSet(0.0f, 50.0f, 0.0f, 0.0f);
position = XMVectorSet(0.0f, 100.0f, 0.0f, 0.0f);
rotation = XMQuaternionRotationRollPitchYaw(0.0f, 0.0f, 0.0f);

rotationEuler[0] = -3.0f;
Expand Down
13 changes: 9 additions & 4 deletions gpuraytrace/Media/common/shaders/tracing.hlsl
Expand Up @@ -32,8 +32,10 @@ struct RayResult
const static float RAY_STEP = 0.03f;
const static float RAY_FINAL_PRECISION = 0.02f;
#if RECORDING
const static float RAY_DENSITY_FACTOR = 0.08f;
const static float RAY_STEP_FACTOR = 1.001f;
#else
const static float RAY_DENSITY_FACTOR = 0.15f;
const static float RAY_STEP_FACTOR = 1.009f;
#endif
RayResult traceRay(float3 p, float dist, float enddist, float stepmod, float3 dir, bool calcfog, bool skiprefine);
Expand All @@ -45,8 +47,8 @@ RayResult traceRay(float3 p, float dist, float enddist, float stepmod, float3 di
{
RayResult rr;
float4 f = 0.0;
float totalSteps = 0.0f;
float d = 0.0f;
float totalSteps = 0.0f;
float dirLength = length(dir);
float step = RAY_STEP * stepmod * dirLength - dist * (1.0f - RAY_STEP_FACTOR);
float lastStep = step;
Expand All @@ -61,9 +63,10 @@ RayResult traceRay(float3 p, float dist, float enddist, float stepmod, float3 di

float3 rayp;
float hitlimit = RAY_FINAL_PRECISION * RAY_STEP; // * step; //-1.0f;
//bool refining = false;
[loop] while(dist < enddist && (step > hitlimit))
{
totalSteps += 1.0f;
totalSteps++;
rayp = p + dir * dist;

float4 fogstep = 0;
Expand All @@ -77,17 +80,19 @@ RayResult traceRay(float3 p, float dist, float enddist, float stepmod, float3 di
if(/*f.a > 1.0f ||*/ d > 0.0f)
{
if(skiprefine) break;
//refining = true;
dist -= lastStep;
step *= 0.4f;
//lastStep = step;
f -= fogstep;
//if(hitlimit < 0.0f) hitlimit = step * RAY_FINAL_PRECISION;
} else {
float stepmult = 1.0f + pow(abs(d), 0.4f);
float stepmult = 1.0f + pow(abs(min(d + 5.0f, 0.0f)), RAY_DENSITY_FACTOR);

step *= RAY_STEP_FACTOR;
lastStep = step * stepmult;
dist += lastStep;
f += fogstep;
//if(!refining) step = RAY_STEP * stepmod * dirLength - dist * (1.0f - RAY_STEP_FACTOR);
}
}

Expand Down

0 comments on commit 08507f6

Please sign in to comment.