Add new StandardMaterial properties to allow users to control FPS-style objects (hands, weapons, tools close to the camera)

Add new shader built in Z_CLIP_SCALE to easily adjust clipping distance to avoid clipping walls etc.

Add fov_override to StandardMaterial3D to easily have a custom FOV for FPS objects

Add IN_SHADOW_PASS built-in to shaders for tweaking materials without impacting shadow maps
This commit is contained in:
clayjohn 2024-06-13 15:16:18 -07:00
parent 25a3c27c41
commit 9a1def8da1
15 changed files with 254 additions and 90 deletions

View file

@ -46,6 +46,12 @@ LIGHTMAP_BICUBIC_FILTER = false
#define SHADER_IS_SRGB true
#define SHADER_SPACE_FAR -1.0
#if defined(RENDER_SHADOWS) || defined(RENDER_SHADOWS_LINEAR)
#define IN_SHADOW_PASS true
#else
#define IN_SHADOW_PASS false
#endif
#include "stdlib_inc.glsl"
#if !defined(MODE_RENDER_DEPTH) || defined(TANGENT_USED) || defined(NORMAL_MAP_USED) || defined(LIGHT_ANISOTROPY_USED) ||defined(LIGHT_CLEARCOAT_USED)
@ -607,6 +613,10 @@ void main() {
#endif
#endif
#ifdef Z_CLIP_SCALE_USED
float z_clip_scale = 1.0;
#endif
float roughness = 1.0;
highp mat4 modelview = scene_data.view_matrix * model_matrix;
@ -712,6 +722,12 @@ void main() {
gl_Position = projection_matrix * vec4(vertex_interp, 1.0);
#endif
#if !defined(RENDER_SHADOWS) && !defined(RENDER_SHADOWS_LINEAR)
#ifdef Z_CLIP_SCALE_USED
gl_Position.z = mix(gl_Position.w, gl_Position.z, z_clip_scale);
#endif
#endif
#ifdef RENDER_MATERIAL
vec2 uv_dest_attrib;
if (uv_scale != vec4(0.0)) {
@ -833,6 +849,12 @@ void main() {
#define SHADER_IS_SRGB true
#define SHADER_SPACE_FAR -1.0
#if defined(RENDER_SHADOWS) || defined(RENDER_SHADOWS_LINEAR)
#define IN_SHADOW_PASS true
#else
#define IN_SHADOW_PASS false
#endif
#define FLAGS_NON_UNIFORM_SCALE (1 << 4)
/* Varyings */