Показать сообщение отдельно
Старый 22.10.2009, 23:11   #22
Igor'
ПроЭктировщик
 
Аватар для Igor'
 
Регистрация: 15.10.2009
Сообщений: 190
Написано 47 полезных сообщений
(для 142 пользователей)
Ответ: BurnFX RayTracer - W.I.P

Первый более менее шейдер написал ,отражения,всё работает.

class Reflectionhader : public Shader
{
public:

	ReflectionShader(){
	}

	float3 shader_main( const Ray& ray , const RayHit& hit , void* data )
	{
		int bounces = 2;

		if(data){
			bounces = *static_cast<int*>(data);
		}

		float3 base = hit.material->getColor();

		if(bounces > 0 && hit.material->getReflective() > 0.0f ){
			bounces--;

			Ray r;
			r.o = hit.point + ( hit.normal * 1.01f );
			r.d = ray.d.reflect(hit.normal);

			RayHit hit2;
			hit2.empty();

			if(rayCast(r,hit2,10000.0f)){
				base = base * ( 1.0f - hit.material->getReflective() ) + hit2.material->getShader()->shader_main(r,hit2,&bounces) * hit.material->getReflective();
			}
		}

		return base;
	}
};
(Offline)
 
Ответить с цитированием