我在像素着色器的反射https://www.shadertoy.com/view/lsycD1中遇到了麻烦,我无法让它们工作,目前它们在我的主渲染循环中并且几乎显示我想要但不是真的,我尝试过使用反射( rayDirection,position)或反射(rayDirection,normals),但它们似乎都不起作用,如果有人有想法我会很高兴,谢谢!
// Normalized pixel coordinates (from -1 to 1)
vec2 uv = ( -iResolution.xy + 2.0 * fragCoord ) / iResolution.y;
vec2 mou = iMouse.xy / iResolution.xy;
if( mou.x == 0.0 ) mou = vec2( 0.4, 0.3 );
vec3 ro = 4.0 * vec3( sin( iTime * mou.x ), mou.y, cos( iTime * -mou.x ) );
vec3 ww = normalize( vec3( 0.0 ) - ro );
vec3 uu = normalize( cross( vec3( 0.0, 1.0, 0.0 ), ww ) );
vec3 vv = normalize( cross( ww, uu ) );
vec3 rd = normalize( uv.x * uu + uv.y * vv + 1.5 * ww );
//vec3 rd = normalize( vec3( uv, -1.0 ) );
float t = 0.0, d = EPS;
for( int i = 0; i < STEPS; ++i )
{
d = 0.5 * map( ro + rd * t ).x;
if( d < EPS || t > FAR ) break;
t += d;
// Here is where the problem is:
if( map( ro + rd * t ).y == 0.0 )
for( int j = 0; j < 64; j++ )
{
if( t > FAR ) break;
rd = normalize( reflect( rd, norm( ro + rd * t ) ) );
d = 0.5 * map( ro + rd * t ).x;
t += d;
}