Some toying with shader
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::game::world::block::WorldBlock;
|
||||
|
||||
//note: remember to update in main.frag
|
||||
pub const BLOCK_SIZE : usize = 32; // 32x32x32 block size
|
||||
pub const BLOCK_TEX_SIZE : usize = 32; // 32x32x32 blocks in texture (1GB)
|
||||
pub const BLOCK_TEX_SIZE : usize = 40; // number of blocks in texture (32^3 = 1GB, 40^3 = 2GB)
|
||||
pub const NODE_TEX_SIZE: usize = 128; // 32x32x32 nodes in texture
|
||||
const BLOCK_SIZE_QB: usize = BLOCK_SIZE*BLOCK_SIZE*BLOCK_SIZE;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ layout(set=2, binding=0) uniform Materials { Material _Materials[256]; };
|
||||
#define EPSILON 0.00000001
|
||||
#define SCALE 1.0
|
||||
#define NODE_TEX_SIZE 128
|
||||
#define BLOCK_TEX_SIZE 32
|
||||
#define BLOCK_TEX_SIZE 40
|
||||
#define BLOCK_SIZE 32
|
||||
|
||||
// Includes
|
||||
@@ -42,25 +42,40 @@ vec3 solve()
|
||||
HitResult primary = castNodes(primaryRay, 100);
|
||||
if(primary.data > 0)
|
||||
{
|
||||
vec3 color = applyLighting(primary.pos, primaryRay.dir, primary.normal, primary.data);
|
||||
vec3 col = applyLighting(primary.pos, primaryRay.dir, primary.normal, primary.data);
|
||||
vec3 hitPos = primary.pos-primary.normal*EPSILON;
|
||||
|
||||
// Shadow ray
|
||||
Ray shadowRay = Ray(hitPos, _SunDir);
|
||||
HitResult shadow = castNodes(shadowRay, 50);
|
||||
if(shadow.data > 0) color *= 0.1;
|
||||
if(shadow.data > 0) col *= 0.1;
|
||||
|
||||
// Secondary ray
|
||||
// Ray secondRay = Ray(hitPos, randomHemisphere(primary.normal));
|
||||
// HitResult second = castNodes(secondRay, 25);
|
||||
// if(second.data > 0) color += getAlbedo(second.data) * 0.8;
|
||||
// if(second.data > 0) col += getAlbedo(second.data) * 0.8;
|
||||
|
||||
// Sun glare
|
||||
//float sun = clamp(dot(_SunDir, primaryRay.dir), 0.0, 1.0 );
|
||||
//col += 0.25 * vec3(0.8,0.4,0.2) * pow(sun, 4.0 );
|
||||
|
||||
// Gamma
|
||||
col = pow(clamp(col*1.1-0.02,0.0,1.0), vec3(0.4545));
|
||||
|
||||
// Contrast
|
||||
col = col*col*(3.0-2.0*col);
|
||||
|
||||
// Color grade
|
||||
col = pow( col, vec3(1.0,0.92,1.0) ); // soft green
|
||||
col *= vec3(1.02,0.99,0.99); // tint red
|
||||
//col.z = (col.z+0.1)/1.1; // bias blue
|
||||
|
||||
// Fog
|
||||
float dist = distance(primary.pos, primaryRay.origin);
|
||||
float fog = exp2(-pow(0.015*dist, 2));
|
||||
color = mix(vec3(0.8, 0.8, 0.75), color, clamp(fog, 0.0, 1.0));
|
||||
// float dist = distance(primary.pos, primaryRay.origin);
|
||||
// float fog = exp2(-pow(0.015*dist, 2));
|
||||
// col = mix(vec3(0.8, 0.8, 0.75), col, clamp(fog, 0.0, 1.0));
|
||||
|
||||
return color;
|
||||
return col;
|
||||
}
|
||||
|
||||
// Sky
|
||||
|
||||
Reference in New Issue
Block a user