Первый более менее шейдер написал
,отражения,всё работает.
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;
}
};