Updated almost all stuff
This commit is contained in:
38
resources/main/DefaultShaders.metal
Normal file
38
resources/main/DefaultShaders.metal
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "OgreUnifiedShader.h"
|
||||
|
||||
struct RasterizerData
|
||||
{
|
||||
vec4 pos [[position]];
|
||||
vec2 uv;
|
||||
};
|
||||
|
||||
struct Vertex
|
||||
{
|
||||
IN(vec3 pos, POSITION);
|
||||
IN(vec2 uv, TEXCOORD0);
|
||||
};
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
mat4 mvpMtx;
|
||||
mat4 texMtx;
|
||||
};
|
||||
|
||||
// first 15 slots are reserved for the vertex attributes
|
||||
#define UNIFORM_INDEX_START 16
|
||||
|
||||
vertex RasterizerData default_vp(Vertex in [[stage_in]],
|
||||
constant Uniform& u [[buffer(UNIFORM_INDEX_START)]])
|
||||
{
|
||||
RasterizerData out;
|
||||
out.pos = u.mvpMtx * vec4(in.pos, 1);
|
||||
out.uv = (u.texMtx * vec4(in.uv,1,1)).xy;
|
||||
return out;
|
||||
}
|
||||
|
||||
fragment half4 default_fp(RasterizerData in [[stage_in]],
|
||||
metal::texture2d<half> tex [[texture(0)]],
|
||||
metal::sampler s [[sampler(0)]])
|
||||
{
|
||||
return tex.sample(s, in.uv);
|
||||
}
|
||||
97
resources/main/GLSL_GL3Support.glsl
Normal file
97
resources/main/GLSL_GL3Support.glsl
Normal file
@@ -0,0 +1,97 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
|
||||
// @public-api
|
||||
|
||||
#if defined(OGRE_FRAGMENT_SHADER) && defined(OGRE_GLSLES)
|
||||
// define default precisions for ES fragement shaders
|
||||
precision mediump float;
|
||||
|
||||
#if __VERSION__ > 100
|
||||
precision lowp sampler2DArray;
|
||||
precision lowp sampler2DShadow;
|
||||
precision lowp sampler3D;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if __VERSION__ == 100
|
||||
mat2 transpose(mat2 m)
|
||||
{
|
||||
return mat2(m[0][0], m[1][0],
|
||||
m[0][1], m[1][1]);
|
||||
}
|
||||
|
||||
mat3 transpose(mat3 m)
|
||||
{
|
||||
return mat3(m[0][0], m[1][0], m[2][0],
|
||||
m[0][1], m[1][1], m[2][1],
|
||||
m[0][2], m[1][2], m[2][2]);
|
||||
}
|
||||
|
||||
mat4 transpose(mat4 m)
|
||||
{
|
||||
return mat4(m[0][0], m[1][0], m[2][0], m[3][0],
|
||||
m[0][1], m[1][1], m[2][1], m[3][1],
|
||||
m[0][2], m[1][2], m[2][2], m[3][2],
|
||||
m[0][3], m[1][3], m[2][3], m[3][3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __VERSION__ > 120 || defined(OGRE_GLSLANG)
|
||||
#define texture1D texture
|
||||
#define texture2D texture
|
||||
#define texture3D texture
|
||||
#define texture2DArray texture
|
||||
#define textureCube texture
|
||||
#define shadow2D texture
|
||||
#define shadow2DProj textureProj
|
||||
#define texture2DProj textureProj
|
||||
#define texture2DLod textureLod
|
||||
#define textureCubeLod textureLod
|
||||
|
||||
#if defined(OGRE_GLSLANG) || (__VERSION__ > 150 && defined(OGRE_VERTEX_SHADER)) || __VERSION__ >= 410
|
||||
#define IN(decl, loc) layout(location = loc) in decl;
|
||||
#else
|
||||
#define IN(decl, loc) in decl;
|
||||
#endif
|
||||
|
||||
#if defined(OGRE_GLSLANG) || (__VERSION__ > 150 && defined(OGRE_FRAGMENT_SHADER)) || __VERSION__ >= 410
|
||||
#define OUT(decl, loc) layout(location = loc) out decl;
|
||||
#else
|
||||
#define OUT(decl, loc) out decl;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef OGRE_VERTEX_SHADER
|
||||
#define IN(decl, loc) attribute decl;
|
||||
#define OUT(decl, loc) varying decl;
|
||||
#else
|
||||
#define IN(decl, loc) varying decl;
|
||||
#define OUT(decl, loc) out decl;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(OGRE_FRAGMENT_SHADER) && (defined(OGRE_GLSLANG) || (__VERSION__ > 130))
|
||||
#define gl_FragColor FragColor
|
||||
OUT(vec4 FragColor, 0)
|
||||
#endif
|
||||
|
||||
#ifdef VULKAN
|
||||
|
||||
#ifdef OGRE_VERTEX_SHADER
|
||||
#define OGRE_UNIFORMS_BEGIN layout(binding = 0, row_major) uniform OgreUniforms {
|
||||
#else
|
||||
#define OGRE_UNIFORMS_BEGIN layout(binding = 1, row_major) uniform OgreUniforms {
|
||||
#endif
|
||||
|
||||
#define OGRE_UNIFORMS_END };
|
||||
|
||||
#else
|
||||
|
||||
#define OGRE_UNIFORMS_BEGIN
|
||||
#define OGRE_UNIFORMS_END
|
||||
|
||||
#endif
|
||||
98
resources/main/HLSL_SM4Support.hlsl
Normal file
98
resources/main/HLSL_SM4Support.hlsl
Normal file
@@ -0,0 +1,98 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
|
||||
// @public-api
|
||||
|
||||
#if OGRE_HLSL >= 4
|
||||
|
||||
// SM4 separates sampler into Texture and SamplerState
|
||||
|
||||
#define sampler1D Sampler1D
|
||||
#define sampler2D Sampler2D
|
||||
#define sampler3D Sampler3D
|
||||
#define samplerCUBE SamplerCube
|
||||
|
||||
struct Sampler1D
|
||||
{
|
||||
Texture1D t;
|
||||
SamplerState s;
|
||||
};
|
||||
struct Sampler2D
|
||||
{
|
||||
Texture2D t;
|
||||
SamplerState s;
|
||||
};
|
||||
struct Sampler3D
|
||||
{
|
||||
Texture3D t;
|
||||
SamplerState s;
|
||||
};
|
||||
struct SamplerCube
|
||||
{
|
||||
TextureCube t;
|
||||
SamplerState s;
|
||||
};
|
||||
|
||||
float4 tex1D(Sampler1D s, float v) { return s.t.Sample(s.s, v); }
|
||||
float4 tex2D(Sampler2D s, float2 v) { return s.t.Sample(s.s, v); }
|
||||
float4 tex3D(Sampler3D s, float3 v) { return s.t.Sample(s.s, v); }
|
||||
float4 texCUBE(SamplerCube s, float3 v) { return s.t.Sample(s.s, v); }
|
||||
float4 texCUBElod(SamplerCube s, float4 v) { return s.t.SampleLevel(s.s, v.xyz, v.w); }
|
||||
|
||||
float4 tex2D(Sampler2D s, float2 v, float2 ddx, float2 ddy) { return s.t.SampleGrad(s.s, v, ddx, ddy); }
|
||||
float4 tex2Dproj(Sampler2D s, float4 v) { return s.t.Sample(s.s, v.xy/v.w); }
|
||||
float4 tex2Dlod(Sampler2D s, float4 v) { return s.t.SampleLevel(s.s, v.xy, v.w); }
|
||||
|
||||
#define SAMPLER1D(name, reg) \
|
||||
Texture1D name ## Tex : register(t ## reg);\
|
||||
SamplerState name ## State : register(s ## reg);\
|
||||
static Sampler1D name = {name ## Tex, name ## State}
|
||||
|
||||
#define SAMPLER2D(name, reg) \
|
||||
Texture2D name ## Tex : register(t ## reg);\
|
||||
SamplerState name ## State : register(s ## reg);\
|
||||
static Sampler2D name = {name ## Tex, name ## State}
|
||||
|
||||
#define SAMPLER3D(name, reg) \
|
||||
Texture3D name ## Tex : register(t ## reg);\
|
||||
SamplerState name ## State : register(s ## reg);\
|
||||
static Sampler3D name = {name ## Tex, name ## State}
|
||||
|
||||
#define SAMPLERCUBE(name, reg) \
|
||||
TextureCube name ## Tex : register(t ## reg);\
|
||||
SamplerState name ## State : register(s ## reg);\
|
||||
static SamplerCube name = {name ## Tex, name ## State}
|
||||
|
||||
// the following are not available in D3D9, but provided for convenience
|
||||
struct Sampler2DShadow
|
||||
{
|
||||
Texture2D t;
|
||||
SamplerComparisonState s;
|
||||
};
|
||||
struct Sampler2DArray
|
||||
{
|
||||
Texture2DArray t;
|
||||
SamplerState s;
|
||||
};
|
||||
|
||||
#define SAMPLER2DSHADOW(name, reg) \
|
||||
Texture2D name ## Tex : register(t ## reg);\
|
||||
SamplerComparisonState name ## State : register(s ## reg);\
|
||||
static Sampler2DShadow name = {name ## Tex, name ## State}
|
||||
|
||||
#define SAMPLER2DARRAY(name, reg) \
|
||||
Texture2DArray name ## Tex : register(t ## reg);\
|
||||
SamplerState name ## State : register(s ## reg);\
|
||||
static Sampler2DArray name = {name ## Tex, name ## State}
|
||||
|
||||
float tex2Dcmp(Sampler2DShadow s, float3 v) { return s.t.SampleCmpLevelZero(s.s, v.xy, v.z); }
|
||||
float4 tex2DARRAY(Sampler2DArray s, float3 v) { return s.t.Sample(s.s, v); }
|
||||
#else
|
||||
|
||||
#define SAMPLER1D(name, reg) sampler1D name : register(s ## reg)
|
||||
#define SAMPLER2D(name, reg) sampler2D name : register(s ## reg)
|
||||
#define SAMPLER3D(name, reg) sampler3D name : register(s ## reg)
|
||||
#define SAMPLERCUBE(name, reg) samplerCUBE name : register(s ## reg)
|
||||
|
||||
#endif
|
||||
185
resources/main/OgreUnifiedShader.h
Normal file
185
resources/main/OgreUnifiedShader.h
Normal file
@@ -0,0 +1,185 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
|
||||
// greatly inspired by
|
||||
// - shiny: https://ogrecave.github.io/shiny/defining-materials-shaders.html
|
||||
// - bgfx: https://github.com/bkaradzic/bgfx/blob/master/src/bgfx_shader.sh
|
||||
|
||||
/// general usage:
|
||||
// MAIN_PARAMETERS
|
||||
// IN(vec4 vertex, POSITION)
|
||||
// MAIN_DECLARATION
|
||||
// {
|
||||
// GLSL code here
|
||||
// }
|
||||
|
||||
/// configuration
|
||||
// use macros that will be default with Ogre 15
|
||||
// #define USE_OGRE_FROM_FUTURE
|
||||
|
||||
// @public-api
|
||||
|
||||
#if defined(OGRE_HLSL) || defined(OGRE_CG)
|
||||
// HLSL
|
||||
#include "HLSL_SM4Support.hlsl"
|
||||
#define vec2 float2
|
||||
#define vec3 float3
|
||||
#define vec4 float4
|
||||
#define mat3 float3x3
|
||||
#define mat4 float4x4
|
||||
|
||||
#define ivec2 int2
|
||||
#define ivec3 int3
|
||||
#define ivec4 int4
|
||||
|
||||
#define texture1D tex1D
|
||||
#define texture2D tex2D
|
||||
#define texture3D tex3D
|
||||
#define texture2DArray tex2DARRAY
|
||||
#define textureCube texCUBE
|
||||
#define shadow2D tex2Dcmp
|
||||
#define texture2DProj tex2Dproj
|
||||
vec4 texture2DLod(sampler2D s, vec2 v, float lod) { return tex2Dlod(s, vec4(v.x, v.y, 0, lod)); }
|
||||
|
||||
#define samplerCube samplerCUBE
|
||||
vec4 textureCubeLod(samplerCube s, vec3 v, float lod) { return texCUBElod(s, vec4(v.x, v.y, v.z, lod)); }
|
||||
|
||||
#define sampler2DShadow Sampler2DShadow
|
||||
|
||||
#define mix lerp
|
||||
#define fract frac
|
||||
#define inversesqrt rsqrt
|
||||
#define dFdx ddx
|
||||
#define dFdy ddy
|
||||
|
||||
float mod(float _a, float _b) { return _a - _b * floor(_a / _b); }
|
||||
vec2 mod(vec2 _a, vec2 _b) { return _a - _b * floor(_a / _b); }
|
||||
vec3 mod(vec3 _a, vec3 _b) { return _a - _b * floor(_a / _b); }
|
||||
vec4 mod(vec4 _a, vec4 _b) { return _a - _b * floor(_a / _b); }
|
||||
|
||||
vec2 vec2_splat(float x) { return vec2(x, x); }
|
||||
vec3 vec3_splat(float x) { return vec3(x, x, x); }
|
||||
vec4 vec4_splat(float x) { return vec4(x, x, x, x); }
|
||||
|
||||
mat4 mtxFromRows(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return mat4(a, b, c, d);
|
||||
}
|
||||
|
||||
mat3 mtxFromRows(vec3 a, vec3 b, vec3 c)
|
||||
{
|
||||
return mat3(a, b, c);
|
||||
}
|
||||
|
||||
mat3 mtxFromCols(vec3 a, vec3 b, vec3 c)
|
||||
{
|
||||
return transpose(mat3(a, b, c));
|
||||
}
|
||||
|
||||
#define STATIC static
|
||||
|
||||
#define OGRE_UNIFORMS_BEGIN
|
||||
#define OGRE_UNIFORMS_END
|
||||
|
||||
#define MAIN_PARAMETERS void main(
|
||||
|
||||
#ifdef OGRE_VERTEX_SHADER
|
||||
#define MAIN_DECLARATION out float4 gl_Position : POSITION)
|
||||
#else
|
||||
#define MAIN_DECLARATION in float4 gl_FragCoord : POSITION, out float4 gl_FragColor : COLOR)
|
||||
#endif
|
||||
|
||||
#define IN(decl, sem) in decl : sem,
|
||||
#define OUT(decl, sem) out decl : sem,
|
||||
#elif defined(OGRE_METAL)
|
||||
#define vec2 float2
|
||||
#define vec3 float3
|
||||
#define vec4 float4
|
||||
#define mat3 metal::float3x3
|
||||
#define mat4 metal::float4x4
|
||||
|
||||
#define IN(decl, sem) decl [[ attribute(sem) ]];
|
||||
#else
|
||||
// GLSL
|
||||
#include "GLSL_GL3Support.glsl"
|
||||
|
||||
#ifdef VULKAN
|
||||
#define _UNIFORM_BINDING(b) layout(binding = b + 2) uniform
|
||||
#elif __VERSION__ >= 420
|
||||
#define _UNIFORM_BINDING(b) layout(binding = b) uniform
|
||||
#else
|
||||
#define _UNIFORM_BINDING(b) uniform
|
||||
#endif
|
||||
|
||||
#define SAMPLER1D(name, reg) _UNIFORM_BINDING(reg) sampler1D name
|
||||
#define SAMPLER2D(name, reg) _UNIFORM_BINDING(reg) sampler2D name
|
||||
#define SAMPLER3D(name, reg) _UNIFORM_BINDING(reg) sampler3D name
|
||||
#define SAMPLER2DARRAY(name, reg) _UNIFORM_BINDING(reg) sampler2DArray name
|
||||
#define SAMPLERCUBE(name, reg) _UNIFORM_BINDING(reg) samplerCube name
|
||||
#define SAMPLER2DSHADOW(name, reg) _UNIFORM_BINDING(reg) sampler2DShadow name
|
||||
|
||||
#define saturate(x) clamp(x, 0.0, 1.0)
|
||||
#define mul(a, b) ((a) * (b))
|
||||
|
||||
#define vec2_splat vec2
|
||||
#define vec3_splat vec3
|
||||
#define vec4_splat vec4
|
||||
|
||||
mat4 mtxFromRows(vec4 a, vec4 b, vec4 c, vec4 d)
|
||||
{
|
||||
return transpose(mat4(a, b, c, d));
|
||||
}
|
||||
|
||||
mat3 mtxFromRows(vec3 a, vec3 b, vec3 c)
|
||||
{
|
||||
return transpose(mat3(a, b, c));
|
||||
}
|
||||
|
||||
mat3 mtxFromCols(vec3 a, vec3 b, vec3 c)
|
||||
{
|
||||
return mat3(a, b, c);
|
||||
}
|
||||
|
||||
#define STATIC
|
||||
|
||||
#define MAIN_PARAMETERS
|
||||
#define MAIN_DECLARATION void main()
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(OGRE_HLSL) && !defined(OGRE_CG)
|
||||
// semantics as aliases for attribute locations
|
||||
#define POSITION 0
|
||||
#define BLENDWEIGHT 1
|
||||
#define NORMAL 2
|
||||
#define COLOR0 3
|
||||
#define COLOR1 4
|
||||
#define COLOR COLOR0
|
||||
#define FOG 5
|
||||
#define BLENDINDICES 7
|
||||
#define TEXCOORD0 8
|
||||
#define TEXCOORD1 9
|
||||
#define TEXCOORD2 10
|
||||
#define TEXCOORD3 11
|
||||
#define TEXCOORD4 12
|
||||
#define TEXCOORD5 13
|
||||
#define TEXCOORD6 14
|
||||
#define TEXCOORD7 15
|
||||
#define TANGENT 14
|
||||
#endif
|
||||
|
||||
#define OGRE_UNIFORMS(params) OGRE_UNIFORMS_BEGIN params OGRE_UNIFORMS_END
|
||||
|
||||
// GL_EXT_shader_explicit_arithmetic_types polyfill
|
||||
#ifdef OGRE_GLSLES
|
||||
#define float32_t highp float
|
||||
#define f32vec2 highp vec2
|
||||
#define f32vec3 highp vec3
|
||||
#define f32vec4 highp vec4
|
||||
#else
|
||||
#define float32_t float
|
||||
#define f32vec2 vec2
|
||||
#define f32vec3 vec3
|
||||
#define f32vec4 vec4
|
||||
#endif
|
||||
85
resources/main/Shadow.material
Normal file
85
resources/main/Shadow.material
Normal file
@@ -0,0 +1,85 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
|
||||
material Ogre/TextureShadowCaster
|
||||
{
|
||||
receive_shadows false
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
// Lighting has to be on, because we need shadow coloured objects
|
||||
// Note that because we can't predict vertex programs, we'll have to
|
||||
// bind light values to those, and so we bind White to ambient
|
||||
// reflectance, and we'll set the ambient colour to the shadow colour
|
||||
ambient 1 1 1
|
||||
diffuse 0 0 0
|
||||
specular 0 0 0 1
|
||||
emissive 0 0 0
|
||||
fog_override true none
|
||||
// set depth bias in case this is used with PF_DEPTH
|
||||
depth_bias -1 -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material Ogre/StencilShadowModulationPass
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
lighting off
|
||||
scene_blend modulate
|
||||
depth_write off
|
||||
depth_check off
|
||||
cull_hardware none
|
||||
|
||||
vertex_program_ref Ogre/ShadowBlendVP {}
|
||||
fragment_program_ref Ogre/ShadowBlendFP {}
|
||||
texture_unit {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material Ogre/StencilShadowVolumes
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
// program will be set dynamically to match light type
|
||||
vertex_program_ref Ogre/ShadowExtrudeDirLightFinite
|
||||
{
|
||||
// however, the parameters here are shared between all programs
|
||||
param_named_auto worldviewproj_matrix worldviewproj_matrix
|
||||
param_named_auto light_position_object_space light_position_object_space 0
|
||||
param_named_auto shadow_extrusion_distance shadow_extrusion_distance 0
|
||||
}
|
||||
fragment_program_ref Ogre/ShadowBlendFP {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material Ogre/Debug/ShadowVolumes
|
||||
{
|
||||
technique
|
||||
{
|
||||
pass
|
||||
{
|
||||
depth_write off
|
||||
scene_blend add
|
||||
cull_hardware none
|
||||
|
||||
// program will be set dynamically to match light type
|
||||
vertex_program_ref Ogre/ShadowExtrudeDirLight
|
||||
{
|
||||
// however, the parameters here are shared between all programs
|
||||
param_named_auto worldviewproj_matrix worldviewproj_matrix
|
||||
param_named_auto light_position_object_space light_position_object_space 0
|
||||
}
|
||||
fragment_program_ref Ogre/ShadowBlendFP {}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
resources/main/ShadowBlend.frag
Normal file
11
resources/main/ShadowBlend.frag
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
OGRE_UNIFORMS(
|
||||
uniform vec4 shadowColor;
|
||||
)
|
||||
|
||||
MAIN_PARAMETERS
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
gl_FragColor = shadowColor;
|
||||
}
|
||||
12
resources/main/ShadowBlend.vert
Normal file
12
resources/main/ShadowBlend.vert
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
OGRE_UNIFORMS(
|
||||
uniform mat4 worldViewProj;
|
||||
)
|
||||
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 vertex, POSITION)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
gl_Position = mul(worldViewProj, vertex);
|
||||
}
|
||||
18
resources/main/ShadowExtrudeDirLight.vert
Normal file
18
resources/main/ShadowExtrudeDirLight.vert
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
// Directional light extrude
|
||||
uniform mat4 worldviewproj_matrix;
|
||||
uniform vec4 light_position_object_space; // homogenous, object space
|
||||
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 uv0, TEXCOORD0)
|
||||
IN(vec4 position, POSITION)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
// Extrusion in object space
|
||||
// Vertex unmodified if w==1, extruded if w==0
|
||||
vec4 newpos =
|
||||
(uv0.xxxx * (position + light_position_object_space)) - light_position_object_space;
|
||||
|
||||
gl_Position = mul(worldviewproj_matrix, newpos);
|
||||
}
|
||||
22
resources/main/ShadowExtrudeDirLightFinite.vert
Normal file
22
resources/main/ShadowExtrudeDirLightFinite.vert
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
// Directional light extrude - FINITE
|
||||
uniform mat4 worldviewproj_matrix;
|
||||
uniform vec4 light_position_object_space; // homogenous, object space
|
||||
uniform float shadow_extrusion_distance; // how far to extrude
|
||||
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 uv0, TEXCOORD0)
|
||||
IN(vec4 position, POSITION)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
// Extrusion in object space
|
||||
// Vertex unmodified if w==1, extruded if w==0
|
||||
vec3 extrusionDir = - light_position_object_space.xyz;
|
||||
extrusionDir = normalize(extrusionDir);
|
||||
|
||||
vec4 newpos = vec4(position.xyz +
|
||||
((1.0 - uv0.x) * shadow_extrusion_distance * extrusionDir), 1.0);
|
||||
|
||||
gl_Position = mul(worldviewproj_matrix, newpos);
|
||||
}
|
||||
19
resources/main/ShadowExtrudePointLight.vert
Normal file
19
resources/main/ShadowExtrudePointLight.vert
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
// Point light shadow volume extrude
|
||||
uniform mat4 worldviewproj_matrix;
|
||||
uniform vec4 light_position_object_space; // homogenous, object space
|
||||
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 uv0, TEXCOORD0)
|
||||
IN(vec4 position, POSITION)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
// Extrusion in object space
|
||||
// Vertex unmodified if w==1, extruded if w==0
|
||||
vec4 newpos =
|
||||
(uv0.xxxx * light_position_object_space) +
|
||||
vec4(position.xyz - light_position_object_space.xyz, 0.0);
|
||||
|
||||
gl_Position = mul(worldviewproj_matrix, newpos);
|
||||
}
|
||||
22
resources/main/ShadowExtrudePointLightFinite.vert
Normal file
22
resources/main/ShadowExtrudePointLightFinite.vert
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <OgreUnifiedShader.h>
|
||||
|
||||
// Point light shadow volume extrude - FINITE
|
||||
uniform mat4 worldviewproj_matrix;
|
||||
uniform vec4 light_position_object_space; // homogenous, object space
|
||||
uniform float shadow_extrusion_distance; // how far to extrude
|
||||
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 uv0, TEXCOORD0)
|
||||
IN(vec4 position, POSITION)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
// Extrusion in object space
|
||||
// Vertex unmodified if w==1, extruded if w==0
|
||||
vec3 extrusionDir = position.xyz - light_position_object_space.xyz;
|
||||
extrusionDir = normalize(extrusionDir);
|
||||
|
||||
vec4 newpos = vec4(position.xyz +
|
||||
((1.0 - uv0.x) * shadow_extrusion_distance * extrusionDir), 1.0);
|
||||
|
||||
gl_Position = mul(worldviewproj_matrix, newpos);
|
||||
}
|
||||
41
resources/main/ShadowVolumeExtude.program
Normal file
41
resources/main/ShadowVolumeExtude.program
Normal file
@@ -0,0 +1,41 @@
|
||||
// This file is part of the OGRE project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at https://www.ogre3d.org/licensing.
|
||||
|
||||
vertex_program Ogre/ShadowBlendVP glsl glsles hlsl glslang
|
||||
{
|
||||
source ShadowBlend.vert
|
||||
default_params
|
||||
{
|
||||
param_named_auto worldViewProj worldviewproj_matrix
|
||||
}
|
||||
}
|
||||
|
||||
fragment_program Ogre/ShadowBlendFP glsl glsles hlsl glslang
|
||||
{
|
||||
source ShadowBlend.frag
|
||||
default_params
|
||||
{
|
||||
param_named_auto shadowColor shadow_colour
|
||||
}
|
||||
}
|
||||
|
||||
vertex_program Ogre/ShadowExtrudePointLight glsl glsles hlsl
|
||||
{
|
||||
source ShadowExtrudePointLight.vert
|
||||
}
|
||||
|
||||
vertex_program Ogre/ShadowExtrudeDirLight glsl glsles hlsl
|
||||
{
|
||||
source ShadowExtrudeDirLight.vert
|
||||
}
|
||||
|
||||
vertex_program Ogre/ShadowExtrudePointLightFinite glsl glsles hlsl
|
||||
{
|
||||
source ShadowExtrudePointLightFinite.vert
|
||||
}
|
||||
|
||||
vertex_program Ogre/ShadowExtrudeDirLightFinite glsl glsles hlsl
|
||||
{
|
||||
source ShadowExtrudeDirLightFinite.vert
|
||||
}
|
||||
BIN
resources/main/spot_shadow_fade.dds
Normal file
BIN
resources/main/spot_shadow_fade.dds
Normal file
Binary file not shown.
Reference in New Issue
Block a user