Raymarcher data updated

This commit is contained in:
Emmanuel BENOîT 2017-10-03 10:06:26 +02:00
parent e66b107e73
commit be460bce83
2 changed files with 39 additions and 20 deletions

View file

@ -2,20 +2,31 @@
#define USE_MAP_MATERIAL #define USE_MAP_MATERIAL
T_BPMaterial BPMaterials[1] = { T_BPMaterial BPMaterials[1] = {
{ vec3( 1 , 1 , 0 ) , vec3( 1 ) , 4 , .3 } { vec3( 1 , 1 , 0 ) * .1 , vec3( .1 ) , 4 , .1 }
};
T_PBRMaterialOld PBRMaterialsOld[1] = {
{
// Albedo / specular colors
vec3( 1 , 1 , 0 ) , vec3( 1 , 1 , .4 ) * .1 ,
// Roughness , anisotropy , subsurface , metallic
.8 , .8 , .1 , .9
}
}; };
T_PBRMaterial PBRMaterials[1] = { T_PBRMaterial PBRMaterials[1] = {
{ {
// Albedo / specular colors // Albedo color
vec3( 1 , 1 , 0 ) , vec3( 1 , 1 , .4 ) , vec3( 1 , 1 , .4 ) ,
// Roughness , anisotropy , subsurface , metallic // Roughness , metallic , subsurface , anisotropy
.1 , 0 , 0 , .75 .3 , .1 , 0 , .0 ,
// Specular strength / tint%
1 , 1
} }
}; };
vec3 Glow[1] = { vec3 Glow[1] = {
vec3( 5. , .1 , 4. ) vec3( 0 , 0 , 0 )
}; };
void mapMaterial( void mapMaterial(
@ -26,16 +37,18 @@ void mapMaterial(
{ {
if ( matIndex == 0 ) { if ( matIndex == 0 ) {
type = 0; type = 0;
glowIndex = -1;
} else { } else {
type = 1; type = 1;
glowIndex = 0;
} }
tIndex = 0; tIndex = 0;
glowIndex = -1;
} }
vec2 map( vec3 pos ) vec2 map( vec3 pos )
{ {
pos = pos - vec3( 0 , 0 , 0 );
vec3 q = pos; vec3 q = pos;
q.xy = mod( q.xy + 4. , 8. ) - 4.; //q.xy = mod( q.xy + 4. , 8. ) - 4.;
return vec2( length( q ) - 1.8 , step( 0. , 1.9 - length( pos.xy ) ) ); return vec2( length( q ) - 1.8 , step( 0. , 1.9 - length( pos.xy ) ) );
} }

View file

@ -1,6 +1,6 @@
vec3 getNormal( vec3 pos ) vec3 getNormal( vec3 pos )
{ {
vec2 v = vec2( .01 , 0 ); vec2 v = vec2( .0005 , 0 );
return normalize( vec3( return normalize( vec3(
map( pos + v.xyy ).x - map( pos - v.xyy ).x , map( pos + v.xyy ).x - map( pos - v.xyy ).x ,
map( pos + v.yxy ).x - map( pos - v.xyx ).x , map( pos + v.yxy ).x - map( pos - v.xyx ).x ,
@ -47,20 +47,21 @@ void main( )
if ( r.y >= 0. ) { if ( r.y >= 0. ) {
const int midx = int( r.y ); const int midx = int( r.y );
const vec3 normal = getNormal( hitPos ); const vec3 normal = getNormal( hitPos );
const vec3 lightDir = normalize( -u_LightDir );
#if defined( USE_BP ) #if defined( USE_BP )
// Blinn-Phong only // Blinn-Phong only
bc = BP_Shade( BPMaterials[ midx ] , bc = BP_Shade( BPMaterials[ midx ] ,
rayDir , normal , -u_LightDir ); rayDir , normal , lightDir );
#else #else
#if defined( USE_PBR ) #if defined( USE_PBR )
// PBR only // PBR only
T_PBRMaterial material = PBRMaterials[ midx ]; T_PBRMaterialOld material = PBRMaterialsOld[ midx ];
T_PBRPrecomputed precomputed = PBR_Precompute( T_PBRPrecomputedOld precomputed = PBR_PrecomputeOld(
material , rayDir , normal ); material , rayDir , normal );
bc = PBR_Shade( material , precomputed , bc = PBR_ShadeOld( material , precomputed ,
rayDir , normal , -u_LightDir ); rayDir , normal , lightDir );
#else #else
#if defined( USE_MAP_MATERIAL ) #if defined( USE_MAP_MATERIAL )
@ -69,16 +70,21 @@ void main( )
mapMaterial( midx , mtype , mtidx , glowidx ); mapMaterial( midx , mtype , mtidx , glowidx );
if ( mtype == 0 ) { if ( mtype == 0 ) {
bc = BP_Shade( BPMaterials[ mtidx ] , bc = BP_Shade( BPMaterials[ mtidx ] ,
rayDir , normal , -u_LightDir ); rayDir , normal , lightDir );
} else { } else {
T_PBRMaterial material = PBRMaterials[ mtidx ]; #if 0
T_PBRPrecomputed precomputed = PBR_Precompute( T_PBRMaterialOld material = PBRMaterialsOld[ mtidx ];
T_PBRPrecomputedOld precomputed = PBR_PrecomputeOld(
material , rayDir , normal ); material , rayDir , normal );
bc = PBR_Shade( material , precomputed , bc = PBR_ShadeOld( material , precomputed ,
rayDir , normal , -u_LightDir ); rayDir , normal , lightDir );
#else
bc = PBR_Shade( PBRMaterials[ mtidx ] ,
-rayDir , normal , lightDir );
#endif
} }
#if defined( USE_GLOW ) #if defined( USE_GLOW )
if ( glowidx > 0 ) { if ( glowidx >= 0 ) {
bc += Glow[ glowidx ]; bc += Glow[ glowidx ];
} }
#endif #endif