Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#Actualgboxentertainment

Posted 13 July 2013 - 08:16 AM

Okay, so I've figured out the cause. Here's my code for reference:

bool raymarch_shadows(vec3 ro, vec3 rd, float maxDist, vec3 lightPos, out float t, out vec3 p, out float light_intensity)
{
	t = 0.0;
	float minStep = 0.001;
	light_intensity = 1.0;
	for(int i = 0; i< 10; i++) {
		p = ro + rd*t;
		float mDist = rm_obj(p);

		if(mDist < 0.0015) {
			return true;
		}

		light_intensity = min(light_intensity, 5.0*mDist/clamp(t,0.0,5.0));

		if(mDist < minStep) { mDist = minStep;}
		t += mDist;
		if(t >= maxDist) {break;}			
		
	}

	return false;
}

Its to do with this function: if(t >= maxDist) {break;}

where maxDist is length of ray (t) from each surface point to the light. The reason why I have to stop the ray when it reaches the light is because if the ray is coming from behind the light, and the occluder is on the other side of the light, if I don't stop the ray, it will overshoot and still capture the occluder. Here is what happens when I remove the "break":

 

[attachment=16761:givoxshadows3.jpg]

 

So the break function prevents this from happening; however, it creates another artifact, which is the sudden changes in lighting, like so:

[attachment=16762:givoxshadows4.jpg]

 

I have now figured out what causes this. It only occurs at locations where the distance from the surface point to the occluder is equal to the distance from the surface point to the light (maxDist). On one side of these points, t < maxDist, thus this side is darker. On the other side, t >= maxDist so this side is lighter.

 

Now I just wish I could figure out how to get it to gradually fade between lighting intensities. Please provide any advice or thoughts if you have any.


#2gboxentertainment

Posted 13 July 2013 - 08:15 AM

Okay, so I've figured out the cause. Here's my code for reference:

bool raymarch_shadows(vec3 ro, vec3 rd, float maxDist, vec3 lightPos, out float t, out vec3 p, out float light_intensity)
{
	t = 0.0;
	float minStep = 0.001;
	light_intensity = 1.0;
	for(int i = 0; i< 10; i++) {
		p = ro + rd*t;
		float mDist = rm_obj(p);

		if(mDist < 0.0015) {
			return true;
		}

		light_intensity = min(light_intensity, 5.0*mDist/clamp(t,0.0,5.0));

		if(mDist < minStep) { mDist = minStep;}
		t += mDist;
		if(t >= maxDist) {break;}			
		
	}

	return false;
}

Its to do with this function: if(t >= maxDist) {break;}

where maxDist is length of ray (t) from each surface point to the light. The reason why I have to stop the ray when it reaches the light is because if the ray is coming from behind the light, and the occluder is on the other side of the light, if I don't stop the ray, it will overshoot and still capture the occluder. Here is what happens when I remove the "break":

 

[attachment=16761:givoxshadows3.jpg]

 

So the break function prevents this from happening; however, it creates another artifact, which is the sudden changes in lighting, like so:

[attachment=16762:givoxshadows4.jpg]

 

I have now figured out what causes this. It only occurs at locations where the distance from the surface point to the occluder is equal to the distance from the surface point to the light (maxDist). On one side, t < maxDist, thus this side is darker. On the other side, t >= maxDist so this side is lighter.

 

Now I just wish I could figure out how to get it to gradually fade between lighting intensities. Please provide any advice or thoughts if you have any.


#1gboxentertainment

Posted 13 July 2013 - 08:14 AM

Okay, so I've figured out the cause. Here's my code for reference:

bool raymarch_shadows(vec3 ro, vec3 rd, float maxDist, vec3 lightPos, out float t, out vec3 p, out float light_intensity)
{
	t = 0.0;
	float minStep = 0.001;
	light_intensity = 1.0;
	for(int i = 0; i< 10; i++) {
		p = ro + rd*t;
		float mDist = rm_obj(p);

		if(mDist < 0.0015) {
			return true;
		}

		light_intensity = min(light_intensity, 5.0*mDist/clamp(t,0.0,5.0));

		if(mDist < minStep) { mDist = minStep;}
		t += mDist;
		if(t >= maxDist) {break;}			
		
	}

	return false;
}

Its to do with this function: if(t >= maxDist) {break;}

where maxDist is length of ray (t) from each surface point to the light. The reason why I have to stop the ray when it reaches the light is because if the ray is coming from behind the light, and the occluder is on the other side of the light, if I don't stop the ray, it will overshoot and still capture occluder. Here is what happens when I remove the "break":

 

[attachment=16761:givoxshadows3.jpg]

 

So the break function prevents this from happening; however, it creates another artifact, which is the sudden changes in lighting, like so:

[attachment=16762:givoxshadows4.jpg]

 

I have now figured out what causes this. It only occurs at locations where the distance from the surface point to the occluder is equal to the distance from the surface point to the light (maxDist). On one side, t < maxDist, thus this side is darker. On the other side, t >= maxDist so this side is lighter.

 

Now I just wish I could figure out how to get it to gradually fade between lighting intensities. Please provide any advice or thoughts if you have any.


PARTNERS