Replaced normal computation.

Didn't solve the problem at hand though
This commit is contained in:
Emmanuel BENOîT 2017-10-05 21:08:02 +02:00
parent c33efde305
commit 1fb3fac7da
2 changed files with 17 additions and 10 deletions

View file

@ -8,13 +8,19 @@ vec2 RM_Map( in vec3 pos );
vec3 RM_GetNormal(
in vec3 pos )
{
vec2 v = vec2( .0005 , 0 );
return normalize( vec3(
RM_Map( pos + v.xyy ).x - RM_Map( pos - v.xyy ).x ,
RM_Map( pos + v.yxy ).x - RM_Map( pos - v.yxy ).x ,
RM_Map( pos + v.yyx ).x - RM_Map( pos - v.yyx ).x ) );
const vec2 e = vec2( 1 , -1 ) * .0001;
const vec4 f = vec4(
RM_Map( pos + e.xyy ).x ,
RM_Map( pos + e.yyx ).x ,
RM_Map( pos + e.yxy ).x ,
RM_Map( pos + e.xxx ).x );
return normalize( f.x * e.xyy
+ f.y * e.yyx
+ f.z * e.yxy
+ f.w * e.xxx );
}
// -----------------------------------------------------------------------------
vec3 RM_Basic(

View file

@ -18,7 +18,7 @@ T_PBRMaterial PBRMaterials[1] = {
// Albedo color
vec3( .8 , 1 , .8 ) ,
// Roughness , metallic , subsurface , anisotropy
.2 , .7 , .7 , .7 ,
.2 , .8 , .5 , .0 ,
// Specular strength / tint%
.5 , .5
}
@ -49,10 +49,11 @@ vec2 RM_Map( vec3 pos )
vec3 q = pos;
HG_pMod2( q.xy , vec2( 8. ) );
HG_pR( q.xz , 1 );
return vec2( mix( HG_fBox( q , vec3( 1.5 ) ) ,
HG_fSphere( q , 1.5 ) ,
.35 ) ,
step( 0. , -HG_fSphere( pos , 3 ) ) );
return vec2( HG_fOpUnionColumns(
HG_fBox( q , vec3( 1.5 ) ) ,
HG_fSphere( q , 1.5 ) ,
1. , 8 ) ,
step( 0. , -HG_fSphere( pos , 3 ) ) );
}