Add more shaders
This commit is contained in:
+30
-30
@@ -14,8 +14,8 @@ const DEFAULT_SUBDIVISION: u32 = 16;
|
|||||||
const MAXIMUM_SUBDIVISION: u32 = 64;
|
const MAXIMUM_SUBDIVISION: u32 = 64;
|
||||||
const MINUMUM_SUBDIVISION: u32 = 8;
|
const MINUMUM_SUBDIVISION: u32 = 8;
|
||||||
|
|
||||||
const RUN_STANDARD_PIPELINE: bool = true;
|
const RUN_STANDARD_PIPELINE: bool = false;
|
||||||
const RUN_RT_PIPELINE: bool = false;
|
const RUN_RT_PIPELINE: bool = true;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@@ -2470,6 +2470,34 @@ impl App {
|
|||||||
|
|
||||||
let mut futures = camera_and_lights.boxed();
|
let mut futures = camera_and_lights.boxed();
|
||||||
|
|
||||||
|
let mut push_constant_future: Option<Box<dyn GpuFuture>> = None;
|
||||||
|
|
||||||
|
while push_constants_left > 0 {
|
||||||
|
for work in self.thread_work_completion.try_iter() {
|
||||||
|
match work {
|
||||||
|
WorkComplete::GetPushConstants(pc, future, index) => {
|
||||||
|
push_constants[index] = pc;
|
||||||
|
push_constant_future =
|
||||||
|
if let Some(push_constant_future) = push_constant_future {
|
||||||
|
Some(push_constant_future.join(future).boxed())
|
||||||
|
} else {
|
||||||
|
Some(future.boxed())
|
||||||
|
};
|
||||||
|
push_constants_left -= 1;
|
||||||
|
},
|
||||||
|
other => work_for_later.push(other),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(f) = push_constant_future {
|
||||||
|
futures = f
|
||||||
|
.then_signal_semaphore_and_flush()
|
||||||
|
.unwrap()
|
||||||
|
.join(futures)
|
||||||
|
.boxed();
|
||||||
|
}
|
||||||
|
|
||||||
if !self.gstate.csg.is_empty() {
|
if !self.gstate.csg.is_empty() {
|
||||||
self.add_commands_enable_gen(
|
self.add_commands_enable_gen(
|
||||||
&mut builder,
|
&mut builder,
|
||||||
@@ -2512,34 +2540,6 @@ impl App {
|
|||||||
.set_viewport(0, [rcx.viewport.clone()].into_iter().collect())
|
.set_viewport(0, [rcx.viewport.clone()].into_iter().collect())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut push_constant_future: Option<Box<dyn GpuFuture>> = None;
|
|
||||||
|
|
||||||
while push_constants_left > 0 {
|
|
||||||
for work in self.thread_work_completion.try_iter() {
|
|
||||||
match work {
|
|
||||||
WorkComplete::GetPushConstants(pc, future, index) => {
|
|
||||||
push_constants[index] = pc;
|
|
||||||
push_constant_future =
|
|
||||||
if let Some(push_constant_future) = push_constant_future {
|
|
||||||
Some(push_constant_future.join(future).boxed())
|
|
||||||
} else {
|
|
||||||
Some(future.boxed())
|
|
||||||
};
|
|
||||||
push_constants_left -= 1;
|
|
||||||
},
|
|
||||||
other => work_for_later.push(other),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(f) = push_constant_future {
|
|
||||||
futures = f
|
|
||||||
.then_signal_semaphore_and_flush()
|
|
||||||
.unwrap()
|
|
||||||
.join(futures)
|
|
||||||
.boxed();
|
|
||||||
}
|
|
||||||
|
|
||||||
if !self.gstate.csg.is_empty() {
|
if !self.gstate.csg.is_empty() {
|
||||||
self.add_commands_depth_pass(
|
self.add_commands_depth_pass(
|
||||||
&mut builder,
|
&mut builder,
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef brdf_include
|
||||||
|
#define brdf_include
|
||||||
|
|
||||||
#define PI 3.14159265
|
#define PI 3.14159265
|
||||||
|
|
||||||
float sqr(float x) {
|
float sqr(float x) {
|
||||||
@@ -133,3 +136,5 @@ BRDFResults DisneyBRDF(BRDFInput i) {
|
|||||||
|
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// global fragment shader
|
||||||
|
|
||||||
|
#version 460
|
||||||
|
#extension GL_GOOGLE_include_directive:require
|
||||||
|
#include "include.glsl"
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
|
//layout(location = 0) out vec4 f_color;
|
||||||
|
//layout(location = 1) out vec4 f_normal;
|
||||||
|
//layout(location = 2) out vec4 f_ao_r_m;
|
||||||
|
|
||||||
|
layout(location = 0) rayPayloadInEXT vec3 hit_value;
|
||||||
|
|
||||||
|
const float EPSILON = .0001;
|
||||||
|
|
||||||
|
vec3 getNormal(vec3 p) {
|
||||||
|
vec3 n;
|
||||||
|
n.x = scene(vec4(p.x + EPSILON, p.y, p.z, camera_uniforms.campos_and_time.w));
|
||||||
|
n.y = scene(vec4(p.x, p.y + EPSILON, p.z, camera_uniforms.campos_and_time.w));
|
||||||
|
n.z = scene(vec4(p.x, p.y, p.z + EPSILON, camera_uniforms.campos_and_time.w));
|
||||||
|
return normalize(n - (scene(vec4(p, camera_uniforms.campos_and_time.w))));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Implicit Surface Entrypoint
|
||||||
|
void main() {
|
||||||
|
vec3 position = gl_ObjectRayOriginEXT + (gl_ObjectRayDirectionEXT * gl_HitTEXT)
|
||||||
|
|
||||||
|
vec3 n = getNormal(position);
|
||||||
|
hit_value = n * 0.5 + 0.5;
|
||||||
|
|
||||||
|
//f_color = vec4(object_uniforms.colour, 1.0);
|
||||||
|
//f_ao_r_m.y = object_uniforms.roughness;
|
||||||
|
//f_ao_r_m.z = object_uniforms.metallic;
|
||||||
|
|
||||||
|
//mat3 rotation = mat3(pc.world[0].xyz, pc.world[1].xyz, pc.world[2].xyz);
|
||||||
|
|
||||||
|
//f_normal = vec4(normalize(rotation * n), 1.0);
|
||||||
|
|
||||||
|
//f_ao_r_m.x = 1.0;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#version 460
|
||||||
|
#extension GL_EXT_ray_tracing : require
|
||||||
|
#extension GL_GOOGLE_include_directive:require
|
||||||
|
#include "include.glsl"
|
||||||
|
#include "implicit_include.glsl"
|
||||||
|
|
||||||
|
const float EPSILON = .001;
|
||||||
|
|
||||||
|
const uint MAX_STEPS = 50;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
if (SPEC_BOUNDING_BOXES) {
|
||||||
|
reportIntersectionEXT(gl_RayTminEXT, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 raypos = gl_ObjectRayOriginEXT;
|
||||||
|
vec3 raydir = gl_ObjectRayDirectionEXT;
|
||||||
|
|
||||||
|
float farplane = gl_RayTmaxEXT;
|
||||||
|
|
||||||
|
vec3 p = raypos;
|
||||||
|
float total_dist = gl_RayTminEXT;
|
||||||
|
for (uint i = 0; i < MAX_STEPS; i++) {
|
||||||
|
float dist = scene(vec4(p, camera_uniforms.campos_and_time.w));
|
||||||
|
total_dist += dist;
|
||||||
|
p = fma(raydir, vec3(total_dist), raypos);
|
||||||
|
if (abs(dist) < EPSILON) {
|
||||||
|
reportIntersectionEXT(total_dist, 0);
|
||||||
|
return;
|
||||||
|
} else if (total_dist > farplane) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user