Update leenkx/Shaders/std/conetrace.glsl
This commit is contained in:
		@ -22,7 +22,7 @@ THE SOFTWARE.
 | 
				
			|||||||
#ifndef _CONETRACE_GLSL_
 | 
					#ifndef _CONETRACE_GLSL_
 | 
				
			||||||
#define _CONETRACE_GLSL_
 | 
					#define _CONETRACE_GLSL_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "std/voxels_constants.glsl"
 | 
					#include "std/constants.glsl"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// References
 | 
					// References
 | 
				
			||||||
// https://github.com/Friduric/voxel-cone-tracing
 | 
					// https://github.com/Friduric/voxel-cone-tracing
 | 
				
			||||||
@ -166,7 +166,7 @@ vec4 traceDiffuse(const vec3 origin, const vec3 normal, const sampler3D voxels,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 viewDir, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
 | 
					vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 viewDir, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
 | 
				
			||||||
	vec3 specularDir = reflect(normalize(-viewDir), normal);
 | 
						vec3 specularDir = reflect(-viewDir, normal);
 | 
				
			||||||
	vec3 P = origin + specularDir * ((BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5)) * voxelgiStep;
 | 
						vec3 P = origin + specularDir * ((BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5)) * voxelgiStep;
 | 
				
			||||||
	vec4 amount = traceCone(voxels, voxelsSDF, P, normal, specularDir, 0, true, roughness, voxelgiStep, clipmaps);
 | 
						vec4 amount = traceCone(voxels, voxelsSDF, P, normal, specularDir, 0, true, roughness, voxelgiStep, clipmaps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -177,8 +177,8 @@ vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity, const float opacity) {
 | 
					vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity, const float opacity) {
 | 
				
			||||||
 	const float transmittance = 1.0 - opacity;
 | 
					 	const float transmittance = 1.0;
 | 
				
			||||||
 	vec3 refractionDir = refract(normalize(-viewDir), normal, 1.0 / ior);
 | 
					 	vec3 refractionDir = refract(-viewDir, normal, 1.0 / ior);
 | 
				
			||||||
 	vec3 P = origin + refractionDir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
 | 
					 	vec3 P = origin + refractionDir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
 | 
				
			||||||
	vec4 amount =  transmittance * traceCone(voxels, voxelsSDF, P, normal, refractionDir, 0, true, roughness, voxelgiStep, clipmaps);
 | 
						vec4 amount =  transmittance * traceCone(voxels, voxelsSDF, P, normal, refractionDir, 0, true, roughness, voxelgiStep, clipmaps);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -330,7 +330,7 @@ float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const v
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
 | 
					float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
 | 
				
			||||||
 	vec3 P = origin + dir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
 | 
					 	vec3 P = origin + dir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
 | 
				
			||||||
	float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, DIFFUSE_CONE_APERTURE, voxelgiStep, clipmaps);
 | 
						float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, SHADOW_CONE_APERTURE, voxelgiStep, clipmaps);
 | 
				
			||||||
	amount = clamp(amount, 0.0, 1.0);
 | 
						amount = clamp(amount, 0.0, 1.0);
 | 
				
			||||||
	return amount * voxelgiOcc;
 | 
						return amount * voxelgiOcc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user