forked from teamnwah/openmw-tes3coop
Remove unused resources
parent
82c4d01b37
commit
a592c1a1c2
@ -1,49 +0,0 @@
|
||||
project(resources)
|
||||
|
||||
set(WATER_FILES
|
||||
water_nm.png
|
||||
circle.png
|
||||
)
|
||||
|
||||
set(MATERIAL_FILES
|
||||
atmosphere.shader
|
||||
atmosphere.shaderset
|
||||
clouds.shader
|
||||
clouds.shaderset
|
||||
core.h
|
||||
moon.shader
|
||||
moon.shaderset
|
||||
objects.mat
|
||||
objects.shader
|
||||
objects.shaderset
|
||||
openmw.configuration
|
||||
quad.mat
|
||||
quad.shader
|
||||
quad.shaderset
|
||||
shadowcaster.mat
|
||||
shadowcaster.shader
|
||||
shadowcaster.shaderset
|
||||
shadows.h
|
||||
sky.mat
|
||||
stars.shader
|
||||
stars.shaderset
|
||||
sun.shader
|
||||
sun.shaderset
|
||||
terrain.shader
|
||||
terrain.shaderset
|
||||
underwater.h
|
||||
water.mat
|
||||
water.shader
|
||||
water.shaderset
|
||||
selection.mat
|
||||
selection.shader
|
||||
selection.shaderset
|
||||
mygui.mat
|
||||
mygui.shader
|
||||
mygui.shaderset
|
||||
ripples.particle
|
||||
)
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR}/water "${OpenMW_BINARY_DIR}/resources/water/" "${WATER_FILES}")
|
||||
|
||||
copy_all_files(${CMAKE_CURRENT_SOURCE_DIR}/materials "${OpenMW_BINARY_DIR}/resources/materials/" "${MATERIAL_FILES}")
|
@ -1,39 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, view) @shAutoConstant(view, view_matrix)
|
||||
shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
||||
|
||||
shOutput(float, alphaFade)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 viewFixed = view;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
viewFixed[0][3] = 0.0;
|
||||
viewFixed[1][3] = 0.0;
|
||||
viewFixed[2][3] = 0.0;
|
||||
#else
|
||||
viewFixed[3][0] = 0.0;
|
||||
viewFixed[3][1] = 0.0;
|
||||
viewFixed[3][2] = 0.0;
|
||||
#endif
|
||||
shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shInputPosition));
|
||||
alphaFade = shInputPosition.z < 150.0 ? 0.0 : 1.0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float, alphaFade)
|
||||
shUniform(float4, atmosphereColour) @shSharedParameter(atmosphereColour)
|
||||
shUniform(float4, horizonColour) @shSharedParameter(horizonColour, horizonColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = alphaFade * atmosphereColour + (1.0 - alphaFade) * horizonColour;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set atmosphere_vertex
|
||||
{
|
||||
source atmosphere.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set atmosphere_fragment
|
||||
{
|
||||
source atmosphere.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, worldview) @shAutoConstant(worldview, worldview_matrix)
|
||||
shUniform(float4x4, proj) @shAutoConstant(proj, projection_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shOutput(float, alphaFade)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 worldviewFixed = worldview;
|
||||
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
worldviewFixed[0][3] = 0.0;
|
||||
worldviewFixed[1][3] = 0.0;
|
||||
worldviewFixed[2][3] = 0.0;
|
||||
#else
|
||||
worldviewFixed[3][0] = 0.0;
|
||||
worldviewFixed[3][1] = 0.0;
|
||||
worldviewFixed[3][2] = 0.0;
|
||||
#endif
|
||||
|
||||
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
|
||||
UV = uv0;
|
||||
alphaFade = (shInputPosition.z <= 200.0) ? ((shInputPosition.z <= 100.0) ? 0.0 : 0.25) : 1.0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float2, UV)
|
||||
shInput(float, alphaFade)
|
||||
|
||||
shSampler2D(diffuseMap1)
|
||||
shSampler2D(diffuseMap2)
|
||||
|
||||
shUniform(float, cloudBlendFactor) @shSharedParameter(cloudBlendFactor)
|
||||
shUniform(float, cloudAnimationTimer) @shSharedParameter(cloudAnimationTimer)
|
||||
shUniform(float, cloudOpacity) @shSharedParameter(cloudOpacity)
|
||||
shUniform(float3, cloudColour) @shSharedParameter(cloudColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
// Scroll in y direction
|
||||
float2 scrolledUV = UV + float2(0,1) * cloudAnimationTimer * 0.003;
|
||||
|
||||
float4 albedo = shSample(diffuseMap1, scrolledUV) * (1.0-cloudBlendFactor) + shSample(diffuseMap2, scrolledUV) * cloudBlendFactor;
|
||||
|
||||
shOutputColour(0) = float4(cloudColour, 1) * albedo * float4(1,1,1, cloudOpacity * alphaFade);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set clouds_vertex
|
||||
{
|
||||
source clouds.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set clouds_fragment
|
||||
{
|
||||
source clouds.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,181 +0,0 @@
|
||||
#if SH_HLSL == 1 || SH_CG == 1
|
||||
|
||||
#define shTexture2D sampler2D
|
||||
#define shSample(tex, coord) tex2D(tex, coord)
|
||||
#define shCubicSample(tex, coord) texCUBE(tex, coord)
|
||||
#define shLerp(a, b, t) lerp(a, b, t)
|
||||
#define shSaturate(a) saturate(a)
|
||||
|
||||
#define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name)
|
||||
|
||||
#define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name)
|
||||
|
||||
#define shMatrixMult(m, v) mul(m, v)
|
||||
|
||||
#define shUniform(type, name) , uniform type name
|
||||
|
||||
#define shTangentInput(type) , in type tangent : TANGENT
|
||||
#define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
||||
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
|
||||
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
||||
|
||||
#define shNormalInput(type) , in type normal : NORMAL
|
||||
|
||||
#define shColourInput(type) , in type colour : COLOR
|
||||
|
||||
#define shFract(val) frac(val)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define shOutputPosition oPosition
|
||||
#define shInputPosition iPosition
|
||||
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
void main( \
|
||||
float4 iPosition : POSITION \
|
||||
, out float4 oPosition : POSITION
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
) \
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shOutputColour(num) oColor##num
|
||||
|
||||
#define shDeclareMrtOutput(num) , out float4 oColor##num : COLOR##num
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
void main( \
|
||||
out float4 oColor0 : COLOR
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
) \
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if SH_GLSL == 1 || SH_GLSLES == 1
|
||||
|
||||
#define shFract(val) fract(val)
|
||||
|
||||
#if SH_GLSLES == 1
|
||||
@version 100
|
||||
#else
|
||||
@version 120
|
||||
#endif
|
||||
|
||||
#if SH_GLSLES == 1
|
||||
precision mediump int;
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#define float2 vec2
|
||||
#define float3 vec3
|
||||
#define float4 vec4
|
||||
#define int2 ivec2
|
||||
#define int3 ivec3
|
||||
#define int4 ivec4
|
||||
#define shTexture2D sampler2D
|
||||
#define shSample(tex, coord) texture2D(tex, coord)
|
||||
#define shCubicSample(tex, coord) textureCube(tex, coord)
|
||||
#define shLerp(a, b, t) mix(a, b, t)
|
||||
#define shSaturate(a) clamp(a, 0.0, 1.0)
|
||||
|
||||
#define shUniform(type, name) uniform type name;
|
||||
|
||||
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
|
||||
|
||||
#define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name)
|
||||
|
||||
#define shMatrixMult(m, v) ((m) * (v))
|
||||
|
||||
#define shOutputPosition gl_Position
|
||||
|
||||
#define float4x4 mat4
|
||||
#define float3x3 mat3
|
||||
|
||||
// GLSL 1.3
|
||||
#if 0
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shInputPosition vertex
|
||||
|
||||
#define shOutputColour(num) oColor##num
|
||||
|
||||
#define shTangentInput(type) in type tangent;
|
||||
#define shVertexInput(type, name) in type name;
|
||||
#define shInput(type, name) in type name;
|
||||
#define shOutput(type, name) out type name;
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shNormalInput(type) in type normal;
|
||||
#define shColourInput(type) in type colour;
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
in float4 vertex;
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shDeclareMrtOutput(num) out vec4 oColor##num;
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
out float4 oColor0;
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// GLSL 1.2
|
||||
|
||||
#if 1
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shInputPosition vertex
|
||||
|
||||
#define shOutputColour(num) gl_FragData[num]
|
||||
|
||||
#define shTangentInput(type) attribute type tangent;
|
||||
#define shVertexInput(type, name) attribute type name;
|
||||
#define shInput(type, name) varying type name;
|
||||
#define shOutput(type, name) varying type name;
|
||||
|
||||
// automatically recognized by ogre when the input name equals this
|
||||
#define shNormalInput(type) attribute type normal;
|
||||
#define shColourInput(type) attribute type colour;
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
#define SH_BEGIN_PROGRAM \
|
||||
attribute vec4 vertex;
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SH_FRAGMENT_SHADER
|
||||
|
||||
#define shDeclareMrtOutput(num)
|
||||
|
||||
#define SH_BEGIN_PROGRAM
|
||||
|
||||
#define SH_START_PROGRAM \
|
||||
void main(void)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,51 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, world) @shAutoConstant(world, world_matrix)
|
||||
shUniform(float4x4, view) @shAutoConstant(view, view_matrix)
|
||||
shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 viewFixed = view;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
viewFixed[0][3] = 0.0;
|
||||
viewFixed[1][3] = 0.0;
|
||||
viewFixed[2][3] = 0.0;
|
||||
#else
|
||||
viewFixed[3][0] = 0.0;
|
||||
viewFixed[3][1] = 0.0;
|
||||
viewFixed[3][2] = 0.0;
|
||||
#endif
|
||||
shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shMatrixMult(world, shInputPosition)));
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shSampler2D(alphaMap)
|
||||
shInput(float2, UV)
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
shUniform(float4, atmosphereColour) @shSharedParameter(atmosphereColour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4 phaseTex = shSample(diffuseMap, UV);
|
||||
float4 fullCircleTex = shSample(alphaMap, UV);
|
||||
|
||||
shOutputColour(0).a = max(phaseTex.a, fullCircleTex.a) * materialDiffuse.a;
|
||||
|
||||
shOutputColour(0).xyz = fullCircleTex.xyz * atmosphereColour.xyz;
|
||||
shOutputColour(0).xyz = shLerp(shOutputColour(0).xyz, phaseTex.xyz, phaseTex.a);
|
||||
shOutputColour(0).xyz *= materialEmissive.xyz;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set moon_vertex
|
||||
{
|
||||
source moon.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set moon_fragment
|
||||
{
|
||||
source moon.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
material MyGUI/NoTexture
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_program mygui_vertex
|
||||
fragment_program mygui_fragment
|
||||
shader_properties
|
||||
{
|
||||
has_texture false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material MyGUI/OneTexture
|
||||
{
|
||||
pass
|
||||
{
|
||||
vertex_program mygui_vertex
|
||||
fragment_program mygui_fragment
|
||||
shader_properties
|
||||
{
|
||||
has_texture true
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#define TEXTURE @shPropertyBool(has_texture)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if TEXTURE
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
#endif
|
||||
shColourInput(float4)
|
||||
shOutput(float4, colourPassthrough)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = float4(shInputPosition.xyz, 1.0);
|
||||
#if TEXTURE
|
||||
UV.xy = uv0;
|
||||
#endif
|
||||
colourPassthrough = colour;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
|
||||
#if TEXTURE
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
#endif
|
||||
|
||||
shInput(float4, colourPassthrough)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
#if TEXTURE
|
||||
shOutputColour(0) = shSample(diffuseMap, UV.xy) * colourPassthrough;
|
||||
#else
|
||||
shOutputColour(0) = colourPassthrough;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set mygui_vertex
|
||||
{
|
||||
source mygui.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_3_0 vs_2_0
|
||||
}
|
||||
|
||||
shader_set mygui_fragment
|
||||
{
|
||||
source mygui.shader
|
||||
type fragment
|
||||
profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1
|
||||
profiles_hlsl ps_3_0 ps_2_0
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
material openmw_objects_base
|
||||
{
|
||||
diffuse 1.0 1.0 1.0 1.0
|
||||
specular 0 0 0 0 1
|
||||
ambient 1.0 1.0 1.0
|
||||
emissive 0.0 0.0 0.0
|
||||
vertmode 0
|
||||
diffuseMap black.png
|
||||
normalMap
|
||||
emissiveMap
|
||||
specMap
|
||||
darkMap
|
||||
use_emissive_map false
|
||||
use_detail_map false
|
||||
use_diffuse_map false
|
||||
use_dark_map false
|
||||
emissiveMapUVSet 0
|
||||
detailMapUVSet 0
|
||||
diffuseMapUVSet 0
|
||||
darkMapUVSet 0
|
||||
use_parallax false
|
||||
|
||||
scene_blend default
|
||||
depth_write default
|
||||
depth_check default
|
||||
alpha_rejection default
|
||||
transparent_sorting default
|
||||
polygon_mode default
|
||||
env_map false
|
||||
env_map_color 1 1 1
|
||||
|
||||
alphaTestMode 0
|
||||
alphaTestValue 0
|
||||
|
||||
pass
|
||||
{
|
||||
vertex_program openmw_objects_vertex
|
||||
fragment_program openmw_objects_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
vertexcolor_mode $vertmode
|
||||
normalMap $normalMap
|
||||
emissiveMapUVSet $emissiveMapUVSet
|
||||
detailMapUVSet $detailMapUVSet
|
||||
diffuseMapUVSet $diffuseMapUVSet
|
||||
darkMapUVSet $darkMapUVSet
|
||||
emissiveMap $emissiveMap
|
||||
detailMap $detailMap
|
||||
diffuseMap $diffuseMap
|
||||
specMap $specMap
|
||||
darkMap $darkMap
|
||||
env_map $env_map
|
||||
env_map_color $env_map_color
|
||||
use_parallax $use_parallax
|
||||
alphaTestMode $alphaTestMode
|
||||
alphaTestValue $alphaTestValue
|
||||
}
|
||||
|
||||
diffuse $diffuse
|
||||
specular $specular
|
||||
ambient $ambient
|
||||
emissive $emissive
|
||||
scene_blend $scene_blend
|
||||
alpha_rejection $alpha_rejection
|
||||
depth_write $depth_write
|
||||
depth_check $depth_check
|
||||
transparent_sorting $transparent_sorting
|
||||
polygon_mode $polygon_mode
|
||||
cull_hardware $cullmode
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $diffuseMap
|
||||
create_in_ffp $use_diffuse_map
|
||||
tex_coord_set $diffuseMapUVSet
|
||||
tex_address_mode $diffuseMapClampMode
|
||||
}
|
||||
|
||||
texture_unit normalMap
|
||||
{
|
||||
direct_texture $normalMap
|
||||
// force automips here for now
|
||||
num_mipmaps 4
|
||||
}
|
||||
|
||||
texture_unit darkMap
|
||||
{
|
||||
create_in_ffp $use_dark_map
|
||||
colour_op_ex modulate src_current src_texture
|
||||
alpha_op_ex modulate src_current src_texture
|
||||
direct_texture $darkMap
|
||||
tex_coord_set $darkMapUVSet
|
||||
tex_address_mode $darkMapClampMode
|
||||
}
|
||||
|
||||
texture_unit detailMap
|
||||
{
|
||||
create_in_ffp $use_detail_map
|
||||
colour_op_ex modulate_x2 src_current src_texture
|
||||
direct_texture $detailMap
|
||||
tex_coord_set $detailMapUVSet
|
||||
tex_address_mode $detailMapClampMode
|
||||
}
|
||||
|
||||
texture_unit emissiveMap
|
||||
{
|
||||
create_in_ffp $use_emissive_map
|
||||
colour_op add
|
||||
direct_texture $emissiveMap
|
||||
tex_coord_set $emissiveMapUVSet
|
||||
tex_address_mode $emissiveMapClampMode
|
||||
}
|
||||
|
||||
texture_unit envMap
|
||||
{
|
||||
create_in_ffp $env_map
|
||||
env_map spherical
|
||||
anim_texture2 textures\magicitem\caust.dds 32 2
|
||||
colour_op add
|
||||
}
|
||||
|
||||
texture_unit specMap
|
||||
{
|
||||
direct_texture $specMap
|
||||
}
|
||||
|
||||
texture_unit shadowMap0
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap1
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap2
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
}
|
||||
}
|
@ -1,591 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
|
||||
#define SHADOWS_PSSM @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
#endif
|
||||
|
||||
#if FOG || SHADOWS_PSSM
|
||||
#define NEED_DEPTH
|
||||
#endif
|
||||
|
||||
#define SPECULAR 1
|
||||
|
||||
#define NORMAL_MAP @shPropertyHasValue(normalMap)
|
||||
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
|
||||
#define DETAIL_MAP @shPropertyHasValue(detailMap)
|
||||
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
|
||||
#define DARK_MAP @shPropertyHasValue(darkMap)
|
||||
#define SPEC_MAP @shPropertyHasValue(specMap) && SPECULAR
|
||||
|
||||
#define ALPHATEST_MODE @shPropertyString(alphaTestMode)
|
||||
|
||||
#define PARALLAX @shPropertyBool(use_parallax)
|
||||
#define PARALLAX_SCALE 0.04
|
||||
#define PARALLAX_BIAS -0.02
|
||||
|
||||
// right now we support 2 UV sets max. implementing them is tedious, and we're probably not going to need more
|
||||
#define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet) || @shPropertyString(diffuseMapUVSet) || @shPropertyString(darkMapUVSet))
|
||||
|
||||
// if normal mapping is enabled, we force pixel lighting
|
||||
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
|
||||
|
||||
#define UNDERWATER @shGlobalSettingBool(render_refraction)
|
||||
|
||||
#define VERTEXCOLOR_MODE @shPropertyString(vertexcolor_mode)
|
||||
|
||||
#define VIEWPROJ_FIX @shGlobalSettingBool(viewproj_fix)
|
||||
|
||||
#define ENV_MAP @shPropertyBool(env_map)
|
||||
|
||||
#define NEED_NORMAL (!VERTEX_LIGHTING || ENV_MAP) || SPECULAR
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
// ------------------------------------- VERTEX ---------------------------------------
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
|
||||
shUniform(float4x4, textureMatrix0) @shAutoConstant(textureMatrix0, texture_matrix, 0)
|
||||
|
||||
#if (VIEWPROJ_FIX) || (SHADOWS)
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
|
||||
#if VIEWPROJ_FIX
|
||||
shUniform(float4, vpRow2Fix) @shSharedParameter(vpRow2Fix, vpRow2Fix)
|
||||
shUniform(float4x4, vpMatrix) @shAutoConstant(vpMatrix, viewproj_matrix)
|
||||
#endif
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
#if SECOND_UV_SET
|
||||
shVertexInput(float2, uv1)
|
||||
#endif
|
||||
shOutput(float4, UV)
|
||||
|
||||
shNormalInput(float4)
|
||||
|
||||
#if NORMAL_MAP
|
||||
shTangentInput(float4)
|
||||
shOutput(float3, tangentPassthrough)
|
||||
#endif
|
||||
|
||||
#if NEED_NORMAL
|
||||
shOutput(float3, normalPassthrough)
|
||||
#endif
|
||||
|
||||
// Depth in w
|
||||
shOutput(float4, objSpacePositionPassthrough)
|
||||
|
||||
#if VERTEXCOLOR_MODE != 0
|
||||
shColourInput(float4)
|
||||
#endif
|
||||
|
||||
#if VERTEXCOLOR_MODE != 0 && !VERTEX_LIGHTING
|
||||
shOutput(float4, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if ENV_MAP || VERTEX_LIGHTING
|
||||
shUniform(float4x4, worldView) @shAutoConstant(worldView, worldview_matrix)
|
||||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shUniform(float4, lightPosition[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightPosition, light_position_view_space_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightDiffuse[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightDiffuse, light_diffuse_colour_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAttenuation[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightAttenuation, light_attenuation_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
#if VERTEXCOLOR_MODE != 2
|
||||
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||
#endif
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
#if VERTEXCOLOR_MODE != 1
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shOutput(float4, lightSpacePos0)
|
||||
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shOutput(float4, lightSpacePos@shIterator)
|
||||
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||
@shEndForeach
|
||||
#if !VIEWPROJ_FIX
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shOutput(float4, lightResult)
|
||||
shOutput(float3, directionalResult)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
|
||||
UV.xy = shMatrixMult (textureMatrix0, float4(uv0,0,1)).xy;
|
||||
#if SECOND_UV_SET
|
||||
UV.zw = uv1;
|
||||
#endif
|
||||
|
||||
#if ENV_MAP || VERTEX_LIGHTING
|
||||
float3 viewNormal = normalize(shMatrixMult(worldView, float4(normal.xyz, 0)).xyz);
|
||||
#endif
|
||||
|
||||
#if ENV_MAP
|
||||
float3 viewVec = normalize( shMatrixMult(worldView, shInputPosition).xyz);
|
||||
|
||||
float3 r = reflect( viewVec, viewNormal );
|
||||
float m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
|
||||
UV.z = r.x/m + 0.5;
|
||||
UV.w = r.y/m + 0.5;
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAP
|
||||
tangentPassthrough = tangent.xyz;
|
||||
#endif
|
||||
#if NEED_NORMAL
|
||||
normalPassthrough = normal.xyz;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE != 0 && !VERTEX_LIGHTING
|
||||
colourPassthrough = colour;
|
||||
#endif
|
||||
|
||||
#ifdef NEED_DEPTH
|
||||
|
||||
|
||||
#if VIEWPROJ_FIX
|
||||
float4x4 vpFixed = vpMatrix;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
vpFixed[2] = vpRow2Fix;
|
||||
#else
|
||||
vpFixed[0][2] = vpRow2Fix.x;
|
||||
vpFixed[1][2] = vpRow2Fix.y;
|
||||
vpFixed[2][2] = vpRow2Fix.z;
|
||||
vpFixed[3][2] = vpRow2Fix.w;
|
||||
#endif
|
||||
|
||||
float4x4 fixedWVP = shMatrixMult(vpFixed, worldMatrix);
|
||||
|
||||
objSpacePositionPassthrough.w = shMatrixMult(fixedWVP, shInputPosition).z;
|
||||
#else
|
||||
objSpacePositionPassthrough.w = shOutputPosition.z;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
objSpacePositionPassthrough.xyz = shInputPosition.xyz;
|
||||
|
||||
#if SHADOWS
|
||||
lightSpacePos0 = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float4 wPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
@shForeach(3)
|
||||
lightSpacePos@shIterator = shMatrixMult(texViewProjMatrix@shIterator, wPos);
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
float3 viewPos = shMatrixMult(worldView, shInputPosition).xyz;
|
||||
|
||||
float3 lightDir;
|
||||
float d;
|
||||
lightResult = float4(0,0,0,1);
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
lightDir = lightPosition[@shIterator].xyz - (viewPos * lightPosition[@shIterator].w);
|
||||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += colour.xyz * lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(viewNormal.xyz, lightDir), 0.0);
|
||||
#else
|
||||
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(viewNormal.xyz, lightDir), 0.0);
|
||||
#endif
|
||||
|
||||
#if @shIterator == 0
|
||||
directionalResult = lightResult.xyz;
|
||||
#endif
|
||||
|
||||
@shEndForeach
|
||||
|
||||
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += lightAmbient.xyz * colour.xyz + materialEmissive.xyz;
|
||||
lightResult.a *= colour.a;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 1
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + colour.xyz;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 0
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + materialEmissive.xyz;
|
||||
#endif
|
||||
|
||||
lightResult.a *= materialDiffuse.a;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
#if NORMAL_MAP && SH_GLSLES
|
||||
mat3 transpose( mat3 m);
|
||||
#endif
|
||||
// ----------------------------------- FRAGMENT ------------------------------------------
|
||||
|
||||
#if UNDERWATER
|
||||
#include "underwater.h"
|
||||
#endif
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if DIFFUSE_MAP
|
||||
shSampler2D(diffuseMap)
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAP
|
||||
shSampler2D(normalMap)
|
||||
#endif
|
||||
|
||||
#if DARK_MAP
|
||||
shSampler2D(darkMap)
|
||||
#endif
|
||||
|
||||
#if DETAIL_MAP
|
||||
shSampler2D(detailMap)
|
||||
#endif
|
||||
|
||||
#if EMISSIVE_MAP
|
||||
shSampler2D(emissiveMap)
|
||||
#endif
|
||||
|
||||
#if ENV_MAP
|
||||
shSampler2D(envMap)
|
||||
shUniform(float3, env_map_color) @shUniformProperty3f(env_map_color, env_map_color)
|
||||
#endif
|
||||
|
||||
#if SPEC_MAP
|
||||
shSampler2D(specMap)
|
||||
#endif
|
||||
|
||||
#if ENV_MAP || SPECULAR || PARALLAX
|
||||
shUniform(float3, cameraPosObjSpace) @shAutoConstant(cameraPosObjSpace, camera_position_object_space)
|
||||
#endif
|
||||
#if SPECULAR
|
||||
shUniform(float3, lightSpec0) @shAutoConstant(lightSpec0, light_specular_colour, 0)
|
||||
shUniform(float3, lightPosObjSpace0) @shAutoConstant(lightPosObjSpace0, light_position_object_space, 0)
|
||||
shUniform(float, matShininess) @shAutoConstant(matShininess, surface_shininess)
|
||||
shUniform(float3, matSpec) @shAutoConstant(matSpec, surface_specular_colour)
|
||||
#endif
|
||||
|
||||
shInput(float4, UV)
|
||||
|
||||
#if NORMAL_MAP
|
||||
shInput(float3, tangentPassthrough)
|
||||
#endif
|
||||
#if NEED_NORMAL
|
||||
shInput(float3, normalPassthrough)
|
||||
#endif
|
||||
|
||||
shInput(float4, objSpacePositionPassthrough)
|
||||
|
||||
#if VERTEXCOLOR_MODE != 0 && !VERTEX_LIGHTING
|
||||
shInput(float4, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
shUniform(float3, fogColour) @shAutoConstant(fogColour, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shInput(float4, lightSpacePos0)
|
||||
shSampler2D(shadowMap0)
|
||||
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, 1)
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shInput(float4, lightSpacePos@shIterator)
|
||||
shSampler2D(shadowMap@shIterator)
|
||||
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(1))
|
||||
@shEndForeach
|
||||
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||
#endif
|
||||
|
||||
#if (UNDERWATER) || (FOG)
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
|
||||
#endif
|
||||
|
||||
#if UNDERWATER
|
||||
shUniform(float, waterLevel) @shSharedParameter(waterLevel)
|
||||
shUniform(float, waterEnabled) @shSharedParameter(waterEnabled)
|
||||
#endif
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shInput(float4, lightResult)
|
||||
shInput(float3, directionalResult)
|
||||
#else
|
||||
shUniform(float4, lightPosition[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightPosition, light_position_view_space_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightDiffuse[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightDiffuse, light_diffuse_colour_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAttenuation[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightAttenuation, light_attenuation_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
shUniform(float4x4, worldView) @shAutoConstant(worldView, worldview_matrix)
|
||||
#if VERTEXCOLOR_MODE != 2
|
||||
shUniform(float4, materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
||||
#endif
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
#if VERTEXCOLOR_MODE != 1
|
||||
shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ALPHATEST_MODE != 0
|
||||
shUniform(float, alphaTestValue) @shUniformProperty1f(alphaTestValue, alphaTestValue)
|
||||
#endif
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4 newUV = UV;
|
||||
|
||||
#ifdef NEED_DEPTH
|
||||
float depthPassthrough = objSpacePositionPassthrough.w;
|
||||
#endif
|
||||
|
||||
#if NEED_NORMAL
|
||||
float3 normal = normalPassthrough;
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAP
|
||||
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
||||
float3x3 tbn = float3x3(tangentPassthrough.xyz, binormal, normal.xyz);
|
||||
|
||||
#if SH_GLSL || SH_GLSLES
|
||||
tbn = transpose(tbn);
|
||||
#endif
|
||||
|
||||
float4 normalTex = shSample(normalMap, UV.xy);
|
||||
|
||||
normal = normalize (shMatrixMult( transpose(tbn), normalTex.xyz * 2.0 - 1.0 ));
|
||||
#endif
|
||||
|
||||
#if ENV_MAP || SPECULAR || PARALLAX
|
||||
float3 eyeDir = normalize(cameraPosObjSpace.xyz - objSpacePositionPassthrough.xyz);
|
||||
#endif
|
||||
|
||||
#if PARALLAX
|
||||
float3 TSeyeDir = normalize(shMatrixMult(tbn, eyeDir));
|
||||
|
||||
newUV += (TSeyeDir.xyxy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS )).xyxy;
|
||||
#endif
|
||||
|
||||
#if DIFFUSE_MAP
|
||||
#if @shPropertyString(diffuseMapUVSet)
|
||||
float4 diffuse = shSample(diffuseMap, newUV.zw);
|
||||
#else
|
||||
float4 diffuse = shSample(diffuseMap, newUV.xy);
|
||||
#endif
|
||||
#else
|
||||
float4 diffuse = float4(1,1,1,1);
|
||||
#endif
|
||||
|
||||
#if ALPHATEST_MODE == 1
|
||||
if (diffuse.a >= alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 2
|
||||
if (diffuse.a != alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 3
|
||||
if (diffuse.a > alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 4
|
||||
if (diffuse.a <= alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 5
|
||||
if (diffuse.a == alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 6
|
||||
if (diffuse.a < alphaTestValue)
|
||||
discard;
|
||||
#elif ALPHATEST_MODE == 7
|
||||
discard;
|
||||
#endif
|
||||
|
||||
|
||||
#if DETAIL_MAP
|
||||
#if @shPropertyString(detailMapUVSet)
|
||||
diffuse *= shSample(detailMap, newUV.zw)*2;
|
||||
#else
|
||||
diffuse *= shSample(detailMap, newUV.xy)*2;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DARK_MAP
|
||||
#if @shPropertyString(darkMapUVSet)
|
||||
diffuse *= shSample(darkMap, newUV.zw);
|
||||
#else
|
||||
diffuse *= shSample(darkMap, newUV.xy);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
shOutputColour(0) = diffuse;
|
||||
|
||||
#if !VERTEX_LIGHTING
|
||||
float3 viewPos = shMatrixMult(worldView, float4(objSpacePositionPassthrough.xyz,1)).xyz;
|
||||
float3 viewNormal = normalize(shMatrixMult(worldView, float4(normal.xyz, 0)).xyz);
|
||||
|
||||
float3 lightDir;
|
||||
float d;
|
||||
float4 lightResult = float4(0,0,0,1);
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
lightDir = lightPosition[@shIterator].xyz - (viewPos * lightPosition[@shIterator].w);
|
||||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += colourPassthrough.xyz * lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(viewNormal.xyz, lightDir), 0.0);
|
||||
#else
|
||||
lightResult.xyz += materialDiffuse.xyz * lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(viewNormal.xyz, lightDir), 0.0);
|
||||
#endif
|
||||
|
||||
#if @shIterator == 0
|
||||
float3 directionalResult = lightResult.xyz;
|
||||
#endif
|
||||
|
||||
@shEndForeach
|
||||
|
||||
|
||||
#if VERTEXCOLOR_MODE == 2
|
||||
lightResult.xyz += lightAmbient.xyz * colourPassthrough.xyz + materialEmissive.xyz;
|
||||
lightResult.a *= colourPassthrough.a;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 1
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + colourPassthrough.xyz;
|
||||
#endif
|
||||
#if VERTEXCOLOR_MODE == 0
|
||||
lightResult.xyz += lightAmbient.xyz * materialAmbient.xyz + materialEmissive.xyz;
|
||||
#endif
|
||||
|
||||
lightResult.a *= materialDiffuse.a;
|
||||
#endif
|
||||
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float shadow = pssmDepthShadow (lightSpacePos0, invShadowmapSize0, shadowMap0, lightSpacePos1, invShadowmapSize1, shadowMap1, lightSpacePos2, invShadowmapSize2, shadowMap2, depthPassthrough, pssmSplitPoints);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
|
||||
float fade = 1.0-((depthPassthrough - shadowFar_fadeStart.y) / fadeRange);
|
||||
shadow = (depthPassthrough > shadowFar_fadeStart.x) ? 1.0 : ((depthPassthrough > shadowFar_fadeStart.y) ? 1.0-((1.0-shadow)*fade) : shadow);
|
||||
#endif
|
||||
|
||||
#if !SHADOWS && !SHADOWS_PSSM
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if (UNDERWATER) || (FOG)
|
||||
float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePositionPassthrough.xyz,1)).xyz;
|
||||
#endif
|
||||
|
||||
#if UNDERWATER
|
||||
float3 waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0.0,0.0,1.0), waterLevel);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shOutputColour(0) *= (lightResult - float4(directionalResult * (1.0-shadow),0.0));
|
||||
#else
|
||||
shOutputColour(0) *= lightResult;
|
||||
#endif
|
||||
|
||||
#if EMISSIVE_MAP
|
||||
#if @shPropertyString(emissiveMapUVSet)
|
||||
shOutputColour(0).xyz += shSample(emissiveMap, newUV.zw).xyz;
|
||||
#else
|
||||
shOutputColour(0).xyz += shSample(emissiveMap, newUV.xy).xyz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENV_MAP
|
||||
// Everything looks better with fresnel
|
||||
float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0.0);
|
||||
float envFactor = shSaturate(0.25 + 0.75 * pow(facing, 1.0));
|
||||
|
||||
shOutputColour(0).xyz += shSample(envMap, UV.zw).xyz * envFactor * env_map_color;
|
||||
#endif
|
||||
|
||||
#if SPECULAR
|
||||
float3 light0Dir = normalize(lightPosObjSpace0.xyz);
|
||||
|
||||
float NdotL = max(dot(normal, light0Dir), 0.0);
|
||||
float3 halfVec = normalize (light0Dir + eyeDir);
|
||||
|
||||
float shininess = matShininess;
|
||||
#if SPEC_MAP
|
||||
float4 specTex = shSample(specMap, UV.xy);
|
||||
shininess *= (specTex.a);
|
||||
#endif
|
||||
|
||||
float3 specular = pow(max(dot(normal, halfVec), 0.0), shininess) * lightSpec0 * matSpec;
|
||||
#if SPEC_MAP
|
||||
specular *= specTex.xyz;
|
||||
#else
|
||||
specular *= diffuse.a;
|
||||
#endif
|
||||
|
||||
shOutputColour(0).xyz += specular * shadow;
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||
|
||||
|
||||
#if UNDERWATER
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, UNDERWATER_COLOUR, shSaturate(length(waterEyePos-worldPos) / VISIBILITY));
|
||||
#else
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// prevent negative colour output (for example with negative lights)
|
||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0.0,0.0,0.0));
|
||||
}
|
||||
#if NORMAL_MAP && SH_GLSLES
|
||||
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]
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set openmw_objects_vertex
|
||||
{
|
||||
source objects.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_3_0 vs_2_0
|
||||
}
|
||||
|
||||
shader_set openmw_objects_fragment
|
||||
{
|
||||
source objects.shader
|
||||
type fragment
|
||||
profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1
|
||||
profiles_hlsl ps_3_0 ps_2_0
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
configuration water_reflection
|
||||
{
|
||||
shadows false
|
||||
shadows_pssm false
|
||||
viewproj_fix true
|
||||
}
|
||||
|
||||
configuration water_refraction
|
||||
{
|
||||
viewproj_fix true
|
||||
render_refraction true
|
||||
}
|
||||
|
||||
configuration local_map
|
||||
{
|
||||
fog false
|
||||
shadows false
|
||||
shadows_pssm false
|
||||
simple_water true
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
material quad
|
||||
{
|
||||
depth_write on
|
||||
|
||||
pass
|
||||
{
|
||||
vertex_program transform_vertex
|
||||
fragment_program quad_fragment
|
||||
|
||||
depth_write $depth_write
|
||||
|
||||
texture_unit SceneBuffer
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material quad_noDepthWrite
|
||||
{
|
||||
parent quad
|
||||
depth_write off
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float2, UV)
|
||||
shSampler2D(SceneBuffer)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = shSample(SceneBuffer, UV);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set transform_vertex
|
||||
{
|
||||
source quad.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set quad_fragment
|
||||
{
|
||||
source quad.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
particle_system openmw/Ripples
|
||||
{
|
||||
material openmw/Ripple
|
||||
particle_width 30
|
||||
particle_height 30
|
||||
// To make the particles move with the scene node when the waterlevel changes
|
||||
local_space true
|
||||
quota 300
|
||||
billboard_type perpendicular_common
|
||||
common_up_vector 0 1 0
|
||||
common_direction 0 0 1
|
||||
|
||||
affector ColourFader
|
||||
{
|
||||
alpha -0.33
|
||||
}
|
||||
|
||||
affector Scaler
|
||||
{
|
||||
rate 120
|
||||
}
|
||||
|
||||
affector Rotator
|
||||
{
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
material SelectionColour
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program selection_vertex
|
||||
fragment_program selection_fragment
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4, colour) @shAutoConstant(colour, custom, 1)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = colour;
|
||||
//shOutputColour(0) = float4(1,0,0,1);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set selection_vertex
|
||||
{
|
||||
source selection.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set selection_fragment
|
||||
{
|
||||
source selection.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
material openmw_shadowcaster_default
|
||||
{
|
||||
create_configuration Default
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
fog_override true
|
||||
|
||||
vertex_program openmw_shadowcaster_vertex
|
||||
fragment_program openmw_shadowcaster_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
shadow_transparency true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_shadowcaster_noalpha
|
||||
{
|
||||
create_configuration Default
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
fog_override true
|
||||
|
||||
vertex_program openmw_shadowcaster_vertex
|
||||
fragment_program openmw_shadowcaster_fragment
|
||||
|
||||
shader_properties
|
||||
{
|
||||
shadow_transparency false
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#define ALPHA @shPropertyBool(shadow_transparency)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if ALPHA
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
#endif
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shOutput(float2, depth)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
// this is the view space position
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
|
||||
// depth info for the fragment.
|
||||
depth.x = shOutputPosition.z;
|
||||
depth.y = shOutputPosition.w;
|
||||
|
||||
// clamp z to zero. seem to do the trick. :-/
|
||||
shOutputPosition.z = max(shOutputPosition.z, 0.0);
|
||||
|
||||
#if ALPHA
|
||||
UV = uv0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
#if ALPHA
|
||||
shInput(float2, UV)
|
||||
shSampler2D(texture1)
|
||||
#endif
|
||||
shInput(float2, depth)
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float finalDepth = depth.x / depth.y;
|
||||
|
||||
|
||||
#if ALPHA
|
||||
// use alpha channel of the first texture
|
||||
float alpha = shSample(texture1, UV).a;
|
||||
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
shOutputColour(0) = float4(finalDepth, finalDepth, finalDepth, 1.0);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set openmw_shadowcaster_vertex
|
||||
{
|
||||
source shadowcaster.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set openmw_shadowcaster_fragment
|
||||
{
|
||||
source shadowcaster.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
|
||||
#define FIXED_BIAS 0.0003
|
||||
|
||||
float depthShadowPCF (shTexture2D shadowMap, float4 shadowMapPos, float2 offset)
|
||||
{
|
||||
shadowMapPos /= shadowMapPos.w;
|
||||
float3 o = float3(offset.xy, -offset.x) * 0.3;
|
||||
//float3 o = float3(0,0,0);
|
||||
float c = (shadowMapPos.z <= FIXED_BIAS + shSample(shadowMap, shadowMapPos.xy - o.xy).r) ? 1.0 : 0.0; // top left
|
||||
c += (shadowMapPos.z <= FIXED_BIAS + shSample(shadowMap, shadowMapPos.xy + o.xy).r) ? 1.0 : 0.0; // bottom right
|
||||
c += (shadowMapPos.z <= FIXED_BIAS + shSample(shadowMap, shadowMapPos.xy + o.zy).r) ? 1.0 : 0.0; // bottom left
|
||||
c += (shadowMapPos.z <= FIXED_BIAS + shSample(shadowMap, shadowMapPos.xy - o.zy).r) ? 1.0 : 0.0; // top right
|
||||
return c / 4.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float pssmDepthShadow (
|
||||
|
||||
|
||||
float4 lightSpacePos0,
|
||||
float2 invShadowmapSize0,
|
||||
shTexture2D shadowMap0,
|
||||
|
||||
float4 lightSpacePos1,
|
||||
float2 invShadowmapSize1,
|
||||
shTexture2D shadowMap1,
|
||||
|
||||
float4 lightSpacePos2,
|
||||
float2 invShadowmapSize2,
|
||||
shTexture2D shadowMap2,
|
||||
|
||||
float depth,
|
||||
float3 pssmSplitPoints)
|
||||
|
||||
{
|
||||
float shadow;
|
||||
|
||||
float pcf1 = depthShadowPCF(shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
float pcf2 = depthShadowPCF(shadowMap1, lightSpacePos1, invShadowmapSize1);
|
||||
float pcf3 = depthShadowPCF(shadowMap2, lightSpacePos2, invShadowmapSize2);
|
||||
|
||||
if (depth < pssmSplitPoints.x)
|
||||
shadow = pcf1;
|
||||
else if (depth < pssmSplitPoints.y)
|
||||
shadow = pcf2;
|
||||
else
|
||||
shadow = pcf3;
|
||||
|
||||
return shadow;
|
||||
}
|
@ -1,140 +0,0 @@
|
||||
material QueryTotalPixels
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program sun_vertex
|
||||
fragment_program sun_fragment
|
||||
cull_hardware none
|
||||
polygon_mode_overrideable off
|
||||
depth_check off
|
||||
depth_write off
|
||||
colour_write off
|
||||
}
|
||||
}
|
||||
|
||||
material QueryVisiblePixels
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program sun_vertex
|
||||
fragment_program sun_fragment
|
||||
cull_hardware none
|
||||
cull_software none
|
||||
polygon_mode_overrideable off
|
||||
depth_check on
|
||||
depth_write off
|
||||
colour_write off
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_moon
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program moon_vertex
|
||||
fragment_program moon_fragment
|
||||
cull_hardware none
|
||||
|
||||
polygon_mode_overrideable off
|
||||
depth_write off
|
||||
depth_check off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
texture_alias $texture
|
||||
}
|
||||
|
||||
texture_unit alphaMap
|
||||
{
|
||||
texture_alias $alphatexture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_clouds
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program clouds_vertex
|
||||
fragment_program clouds_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
|
||||
// second diffuse map is used for weather transitions
|
||||
texture_unit diffuseMap1
|
||||
{
|
||||
texture_alias cloud_texture_1
|
||||
}
|
||||
|
||||
texture_unit diffuseMap2
|
||||
{
|
||||
texture_alias cloud_texture_2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_atmosphere
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program atmosphere_vertex
|
||||
fragment_program atmosphere_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
depth_write off
|
||||
}
|
||||
}
|
||||
|
||||
material openmw_stars
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program stars_vertex
|
||||
fragment_program stars_fragment
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
depth_check off
|
||||
depth_write off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $texture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// used for both sun and sun glare
|
||||
material openmw_sun
|
||||
{
|
||||
allow_fixed_function false
|
||||
pass
|
||||
{
|
||||
vertex_program sun_vertex
|
||||
fragment_program sun_fragment
|
||||
cull_hardware none
|
||||
|
||||
polygon_mode_overrideable off
|
||||
|
||||
depth_check off
|
||||
depth_write off
|
||||
scene_blend alpha_blend
|
||||
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
direct_texture $texture
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, worldview) @shAutoConstant(worldview, worldview_matrix)
|
||||
shUniform(float4x4, proj) @shAutoConstant(proj, projection_matrix)
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
shOutput(float, fade)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 worldviewFixed = worldview;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
worldviewFixed[0][3] = 0.0;
|
||||
worldviewFixed[1][3] = 0.0;
|
||||
worldviewFixed[2][3] = 0.0;
|
||||
#else
|
||||
worldviewFixed[3][0] = 0.0;
|
||||
worldviewFixed[3][1] = 0.0;
|
||||
worldviewFixed[3][2] = 0.0;
|
||||
#endif
|
||||
|
||||
shOutputPosition = shMatrixMult(proj, shMatrixMult(worldviewFixed, shInputPosition));
|
||||
UV = uv0;
|
||||
|
||||
fade = (shInputPosition.z > 50.0) ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
|
||||
shInput(float2, UV)
|
||||
shInput(float, fade)
|
||||
|
||||
shSampler2D(diffuseMap)
|
||||
shUniform(float, nightFade) @shSharedParameter(nightFade)
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = shSample(diffuseMap, UV) * float4(1,1,1, nightFade * fade);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set stars_vertex
|
||||
{
|
||||
source stars.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set stars_fragment
|
||||
{
|
||||
source stars.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, world) @shAutoConstant(world, world_matrix)
|
||||
shUniform(float4x4, view) @shAutoConstant(view, view_matrix)
|
||||
shUniform(float4x4, projection) @shAutoConstant(projection, projection_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4x4 viewFixed = view;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
viewFixed[0][3] = 0.0;
|
||||
viewFixed[1][3] = 0.0;
|
||||
viewFixed[2][3] = 0.0;
|
||||
#else
|
||||
viewFixed[3][0] = 0.0;
|
||||
viewFixed[3][1] = 0.0;
|
||||
viewFixed[3][2] = 0.0;
|
||||
#endif
|
||||
shOutputPosition = shMatrixMult(projection, shMatrixMult(viewFixed, shMatrixMult(world, shInputPosition)));
|
||||
UV = uv0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(diffuseMap)
|
||||
shInput(float2, UV)
|
||||
shUniform(float4, materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
||||
//shUniform(float4, materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0) = float4(1,1,1,materialDiffuse.a) * shSample(diffuseMap, UV);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set sun_vertex
|
||||
{
|
||||
source sun.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 arbvp1
|
||||
profiles_hlsl vs_2_0
|
||||
}
|
||||
|
||||
shader_set sun_fragment
|
||||
{
|
||||
source sun.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps arbfp1
|
||||
profiles_hlsl ps_2_0
|
||||
}
|
@ -1,507 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 scrawl <scrawl@baseoftrash.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#define IS_FIRST_PASS (@shPropertyString(pass_index) == 0)
|
||||
|
||||
#define FOG (@shGlobalSettingBool(fog) && !@shPropertyBool(render_composite_map))
|
||||
|
||||
#define SHADOWS_PSSM @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
#endif
|
||||
|
||||
#define NUM_LAYERS @shPropertyString(num_layers)
|
||||
|
||||
#if FOG || SHADOWS_PSSM
|
||||
#define NEED_DEPTH 1
|
||||
#endif
|
||||
|
||||
#define UNDERWATER @shGlobalSettingBool(render_refraction)
|
||||
|
||||
#define VIEWPROJ_FIX @shGlobalSettingBool(viewproj_fix)
|
||||
|
||||
#define RENDERCMP @shPropertyBool(render_composite_map)
|
||||
|
||||
#define LIGHTING !RENDERCMP
|
||||
|
||||
#define COMPOSITE_MAP @shPropertyBool(display_composite_map)
|
||||
|
||||
#define NORMAL_MAP @shPropertyBool(normal_map_enabled)
|
||||
#define PARALLAX @shPropertyBool(parallax_enabled)
|
||||
|
||||
#define VERTEX_LIGHTING (!NORMAL_MAP)
|
||||
|
||||
#define PARALLAX_SCALE 0.04
|
||||
#define PARALLAX_BIAS -0.02
|
||||
|
||||
// This is just for the permutation handler
|
||||
#define NORMAL_MAPS @shPropertyString(normal_maps)
|
||||
|
||||
#if NEED_DEPTH
|
||||
@shAllocatePassthrough(1, depth)
|
||||
#endif
|
||||
|
||||
@shAllocatePassthrough(2, UV)
|
||||
|
||||
@shAllocatePassthrough(3, worldPos)
|
||||
|
||||
#if LIGHTING
|
||||
@shAllocatePassthrough(3, normalPassthrough)
|
||||
#if VERTEX_LIGHTING
|
||||
@shAllocatePassthrough(3, lightResult)
|
||||
@shAllocatePassthrough(3, directionalResult)
|
||||
#else
|
||||
@shAllocatePassthrough(3, colourPassthrough)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
@shAllocatePassthrough(4, lightSpacePos0)
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
@shAllocatePassthrough(4, lightSpacePos@shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
// ------------------------------------- VERTEX ---------------------------------------
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
shUniform(float4x4, viewProjMatrix) @shAutoConstant(viewProjMatrix, viewproj_matrix)
|
||||
|
||||
#if VIEWPROJ_FIX
|
||||
shUniform(float4, vpRow2Fix) @shSharedParameter(vpRow2Fix, vpRow2Fix)
|
||||
#endif
|
||||
|
||||
shVertexInput(float2, uv0)
|
||||
|
||||
#if LIGHTING
|
||||
shNormalInput(float4)
|
||||
shColourInput(float4)
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
shUniform(float4, lightPosition[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightPosition, light_position_object_space_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightDiffuse[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightDiffuse, light_diffuse_colour_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAttenuation[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightAttenuation, light_attenuation_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@shPassthroughVertexOutputs
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float4 worldPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
|
||||
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
|
||||
|
||||
#if NEED_DEPTH
|
||||
#if VIEWPROJ_FIX
|
||||
float4x4 vpFixed = viewProjMatrix;
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
vpFixed[2] = vpRow2Fix;
|
||||
#else
|
||||
vpFixed[0][2] = vpRow2Fix.x;
|
||||
vpFixed[1][2] = vpRow2Fix.y;
|
||||
vpFixed[2][2] = vpRow2Fix.z;
|
||||
vpFixed[3][2] = vpRow2Fix.w;
|
||||
#endif
|
||||
|
||||
float4x4 fixedWVP = shMatrixMult(vpFixed, worldMatrix);
|
||||
|
||||
float depth = shMatrixMult(fixedWVP, shInputPosition).z;
|
||||
@shPassthroughAssign(depth, depth);
|
||||
#else
|
||||
@shPassthroughAssign(depth, shOutputPosition.z);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@shPassthroughAssign(UV, uv0);
|
||||
|
||||
@shPassthroughAssign(worldPos, worldPos.xyz);
|
||||
|
||||
#if LIGHTING
|
||||
@shPassthroughAssign(normalPassthrough, normal.xyz);
|
||||
#endif
|
||||
#if LIGHTING && !VERTEX_LIGHTING
|
||||
@shPassthroughAssign(colourPassthrough, colour.xyz);
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
@shPassthroughAssign(lightSpacePos0, lightSpacePos);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float4 wPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
|
||||
float4 lightSpacePos;
|
||||
@shForeach(3)
|
||||
lightSpacePos = shMatrixMult(texViewProjMatrix@shIterator, wPos);
|
||||
@shPassthroughAssign(lightSpacePos@shIterator, lightSpacePos);
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
// Lighting
|
||||
float3 lightDir;
|
||||
float d;
|
||||
float3 lightResult = float3(0,0,0);
|
||||
float3 directionalResult = float3(0,0,0);
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
lightDir = lightPosition[@shIterator].xyz - (shInputPosition.xyz * lightPosition[@shIterator].w);
|
||||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
|
||||
lightResult.xyz += lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(normal.xyz, lightDir), 0.0);
|
||||
|
||||
#if @shIterator == 0
|
||||
directionalResult = lightResult.xyz;
|
||||
#endif
|
||||
@shEndForeach
|
||||
lightResult.xyz += lightAmbient.xyz;
|
||||
lightResult.xyz *= colour.xyz;
|
||||
directionalResult.xyz *= colour.xyz;
|
||||
|
||||
@shPassthroughAssign(lightResult, lightResult);
|
||||
@shPassthroughAssign(directionalResult, directionalResult);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// ----------------------------------- FRAGMENT ------------------------------------------
|
||||
|
||||
#if UNDERWATER
|
||||
#include "underwater.h"
|
||||
#endif
|
||||
#if NORMAL_MAP && SH_GLSLES
|
||||
mat3 transpose(mat3 m);
|
||||
#endif
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
|
||||
|
||||
#if COMPOSITE_MAP
|
||||
shSampler2D(compositeMap)
|
||||
#else
|
||||
|
||||
@shForeach(@shPropertyString(num_blendmaps))
|
||||
shSampler2D(blendMap@shIterator)
|
||||
@shEndForeach
|
||||
|
||||
@shForeach(@shPropertyString(num_layers))
|
||||
shSampler2D(diffuseMap@shIterator)
|
||||
#if @shPropertyBool(use_normal_map_@shIterator)
|
||||
shSampler2D(normalMap@shIterator)
|
||||
#endif
|
||||
@shEndForeach
|
||||
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
shUniform(float3, fogColour) @shAutoConstant(fogColour, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
#endif
|
||||
|
||||
@shPassthroughFragmentInputs
|
||||
|
||||
#if LIGHTING
|
||||
|
||||
#if !VERTEX_LIGHTING
|
||||
shUniform(float4, lightPosition[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightPosition, light_position_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightDiffuse[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightDiffuse, light_diffuse_colour_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAttenuation[@shGlobalSettingString(num_lights)]) @shAutoConstant(lightAttenuation, light_attenuation_array, @shGlobalSettingString(num_lights))
|
||||
shUniform(float4, lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
||||
shUniform(float4x4, worldView) @shAutoConstant(worldView, worldview_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS
|
||||
shSampler2D(shadowMap0)
|
||||
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, @shPropertyString(shadowtexture_offset))
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shSampler2D(shadowMap@shIterator)
|
||||
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(@shPropertyString(shadowtexture_offset)))
|
||||
@shEndForeach
|
||||
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (UNDERWATER) || (FOG)
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
|
||||
#if UNDERWATER
|
||||
shUniform(float, waterLevel) @shSharedParameter(waterLevel)
|
||||
#endif
|
||||
|
||||
|
||||
// For specular
|
||||
#if LIGHTING
|
||||
shUniform(float3, lightSpec0) @shAutoConstant(lightSpec0, light_specular_colour, 0)
|
||||
shUniform(float3, lightPos0) @shAutoConstant(lightPos0, light_position, 0)
|
||||
#endif
|
||||
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
|
||||
#if NEED_DEPTH
|
||||
float depth = @shPassthroughReceive(depth);
|
||||
#endif
|
||||
|
||||
float2 UV = @shPassthroughReceive(UV);
|
||||
|
||||
float3 worldPos = @shPassthroughReceive(worldPos);
|
||||
|
||||
#if LIGHTING
|
||||
float3 normal = @shPassthroughReceive(normalPassthrough);
|
||||
#endif
|
||||
|
||||
#if LIGHTING && !VERTEX_LIGHTING
|
||||
|
||||
#if NORMAL_MAP
|
||||
// derive the tangent space basis
|
||||
float3 tangent = float3(1,0, 0);
|
||||
|
||||
float3 binormal = normalize(cross(tangent, normal));
|
||||
tangent = normalize(cross(normal, binormal)); // note, now we need to re-cross to derive tangent again because it wasn't orthonormal
|
||||
|
||||
// derive final matrix
|
||||
float3x3 tbn = float3x3(tangent, binormal, normal);
|
||||
#if SH_GLSL || SH_GLSLES
|
||||
tbn = transpose(tbn);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if UNDERWATER
|
||||
float3 waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,0,1), waterLevel);
|
||||
#endif
|
||||
|
||||
#if !IS_FIRST_PASS
|
||||
// Opacity the previous passes should have, i.e. 1 - (opacity of this pass)
|
||||
float previousAlpha = 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
shOutputColour(0) = float4(1,1,1,1);
|
||||
|
||||
float3 TSnormal = float3(0,0,1);
|
||||
|
||||
#if COMPOSITE_MAP
|
||||
shOutputColour(0).xyz = shSample(compositeMap, UV).xyz;
|
||||
#else
|
||||
|
||||
// Layer calculations
|
||||
// rescale UV to directly map edge vertices to texel centers - this is
|
||||
// important to get correct blending at cell transitions
|
||||
// TODO: parameterize texel size
|
||||
float2 blendUV = (UV - 0.5) * (16.0 / (16.0+1.0)) + 0.5;
|
||||
@shForeach(@shPropertyString(num_blendmaps))
|
||||
float4 blendValues@shIterator = shSaturate(shSample(blendMap@shIterator, blendUV));
|
||||
@shEndForeach
|
||||
|
||||
|
||||
float4 albedo = float4(0,0,0,1);
|
||||
|
||||
float2 layerUV = float2(UV.x, 1.0-UV.y) * 16.0; // Reverse Y, required to get proper tangents
|
||||
float2 thisLayerUV;
|
||||
float4 normalTex;
|
||||
float4 diffuseTex;
|
||||
|
||||
float3 eyeDir = normalize(cameraPos.xyz - worldPos);
|
||||
#if PARALLAX
|
||||
float3 TSeyeDir = normalize(shMatrixMult(tbn, eyeDir));
|
||||
#endif
|
||||
|
||||
@shForeach(@shPropertyString(num_layers))
|
||||
thisLayerUV = layerUV;
|
||||
#if @shPropertyBool(use_normal_map_@shIterator)
|
||||
normalTex = shSample(normalMap@shIterator, thisLayerUV);
|
||||
#if @shIterator == 0 && IS_FIRST_PASS
|
||||
TSnormal = normalize(normalTex.xyz * 2.0 - 1.0);
|
||||
#else
|
||||
TSnormal = shLerp(TSnormal, normalTex.xyz * 2.0 - 1.0, blendValues@shPropertyString(blendmap_component_@shIterator));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if @shPropertyBool(use_parallax_@shIterator)
|
||||
thisLayerUV += TSeyeDir.xy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS );
|
||||
#endif
|
||||
|
||||
diffuseTex = shSample(diffuseMap@shIterator, layerUV);
|
||||
#if !@shPropertyBool(use_specular_@shIterator)
|
||||
diffuseTex.a = 0.0;
|
||||
#endif
|
||||
|
||||
#if @shIterator == 0
|
||||
albedo = diffuseTex;
|
||||
#else
|
||||
albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_component_@shIterator));
|
||||
#endif
|
||||
|
||||
#if !IS_FIRST_PASS
|
||||
previousAlpha *= 1.0-blendValues@shPropertyString(blendmap_component_@shIterator);
|
||||
#endif
|
||||
|
||||
|
||||
@shEndForeach
|
||||
|
||||
shOutputColour(0).rgb *= albedo.xyz;
|
||||
|
||||
#endif
|
||||
|
||||
#if LIGHTING
|
||||
|
||||
#if VERTEX_LIGHTING
|
||||
// Lighting
|
||||
float3 lightResult = @shPassthroughReceive(lightResult);
|
||||
float3 directionalResult = @shPassthroughReceive(directionalResult);
|
||||
#else
|
||||
|
||||
#if NORMAL_MAP
|
||||
normal = normalize (shMatrixMult( transpose(tbn), TSnormal ));
|
||||
#endif
|
||||
|
||||
float3 colour = @shPassthroughReceive(colourPassthrough);
|
||||
float3 lightDir;
|
||||
float d;
|
||||
float3 lightResult = float3(0,0,0);
|
||||
@shForeach(@shGlobalSettingString(num_lights))
|
||||
lightDir = lightPosition[@shIterator].xyz - (worldPos * lightPosition[@shIterator].w);
|
||||
d = length(lightDir);
|
||||
lightDir = normalize(lightDir);
|
||||
|
||||
lightResult.xyz += lightDiffuse[@shIterator].xyz
|
||||
* shSaturate(1.0 / ((lightAttenuation[@shIterator].y) + (lightAttenuation[@shIterator].z * d) + (lightAttenuation[@shIterator].w * d * d)))
|
||||
* max(dot(normal.xyz, lightDir), 0.0);
|
||||
#if @shIterator == 0
|
||||
float3 directionalResult = lightResult.xyz;
|
||||
#endif
|
||||
@shEndForeach
|
||||
lightResult.xyz += lightAmbient.xyz;
|
||||
lightResult.xyz *= colour.xyz;
|
||||
directionalResult.xyz *= colour.xyz;
|
||||
#endif
|
||||
|
||||
// shadows only for the first (directional) light
|
||||
#if SHADOWS
|
||||
float4 lightSpacePos0 = @shPassthroughReceive(lightSpacePos0);
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
float4 lightSpacePos@shIterator = @shPassthroughReceive(lightSpacePos@shIterator);
|
||||
@shEndForeach
|
||||
|
||||
float shadow = pssmDepthShadow (lightSpacePos0, invShadowmapSize0, shadowMap0, lightSpacePos1, invShadowmapSize1, shadowMap1, lightSpacePos2, invShadowmapSize2, shadowMap2, depth, pssmSplitPoints);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
|
||||
float fade = 1-((depth - shadowFar_fadeStart.y) / fadeRange);
|
||||
shadow = (depth > shadowFar_fadeStart.x) ? 1.0 : ((depth > shadowFar_fadeStart.y) ? 1.0-((1.0-shadow)*fade) : shadow);
|
||||
#endif
|
||||
|
||||
#if !SHADOWS && !SHADOWS_PSSM
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
shOutputColour(0).xyz *= (lightResult - directionalResult * (1.0-shadow));
|
||||
#endif
|
||||
|
||||
#if LIGHTING && !COMPOSITE_MAP
|
||||
// Specular
|
||||
float3 light0Dir = normalize(lightPos0.xyz);
|
||||
|
||||
float NdotL = max(dot(normal, light0Dir), 0.0);
|
||||
float3 halfVec = normalize (light0Dir + eyeDir);
|
||||
|
||||
float3 specular = pow(max(dot(normal, halfVec), 0.0), 32.0) * lightSpec0;
|
||||
shOutputColour(0).xyz += specular * (albedo.a) * shadow;
|
||||
#endif
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depth - fogParams.y) * fogParams.w);
|
||||
|
||||
#if UNDERWATER
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, UNDERWATER_COLOUR, shSaturate(length(waterEyePos-worldPos) / VISIBILITY));
|
||||
#else
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColour, fogValue);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// prevent negative colour output (for example with negative lights)
|
||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0,0,0));
|
||||
|
||||
#if IS_FIRST_PASS
|
||||
shOutputColour(0).a = 1.0;
|
||||
#else
|
||||
shOutputColour(0).a = 1.0-previousAlpha;
|
||||
#endif
|
||||
}
|
||||
#if NORMAL_MAP && SH_GLSLES
|
||||
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]
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set terrain_vertex
|
||||
{
|
||||
source terrain.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_3_0 vs_2_0
|
||||
}
|
||||
|
||||
shader_set terrain_fragment
|
||||
{
|
||||
source terrain.shader
|
||||
type fragment
|
||||
profiles_cg ps_3_0 ps_2_x ps_2_0 fp40 arbfp1
|
||||
profiles_hlsl ps_3_0 ps_2_0
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
#define UNDERWATER_COLOUR float3(0.090195, 0.115685, 0.12745)
|
||||
|
||||
#define VISIBILITY 1000.0 // how far you can look through water
|
||||
|
||||
#define BIG_WAVES_X 0.3 // strength of big waves
|
||||
#define BIG_WAVES_Y 0.3
|
||||
|
||||
#define MID_WAVES_X 0.3 // strength of middle sized waves
|
||||
#define MID_WAVES_Y 0.15
|
||||
|
||||
#define SMALL_WAVES_X 0.15 // strength of small waves
|
||||
#define SMALL_WAVES_Y 0.1
|
||||
|
||||
#define WAVE_CHOPPYNESS 0.15 // wave choppyness
|
||||
#define WAVE_SCALE 0.01 // overall wave scale
|
||||
|
||||
#define ABBERATION 0.001 // chromatic abberation amount
|
||||
|
||||
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
||||
|
||||
float3 intercept(float3 lineP,
|
||||
float3 lineN,
|
||||
float3 planeN,
|
||||
float planeD)
|
||||
{
|
||||
|
||||
float distance = (planeD - dot(planeN, lineP)) / dot(lineN, planeN);
|
||||
return lineP + lineN * distance;
|
||||
}
|
||||
|
||||
float3 perturb1(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
|
||||
{
|
||||
float2 nCoord = float2(0,0);
|
||||
bend *= WAVE_CHOPPYNESS;
|
||||
nCoord = coords * (WAVE_SCALE * 0.05) + windDir * timer * (windSpeed*0.04);
|
||||
float3 normal0 = 2.0 * shSample(tex, nCoord + float2(-timer*0.015,-timer*0.05)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 0.1) + windDir * timer * (windSpeed*0.08)-normal0.xy*bend;
|
||||
float3 normal1 = 2.0 * shSample(tex, nCoord + float2(+timer*0.020,+timer*0.015)).rgb - 1.0;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.25) + windDir * timer * (windSpeed*0.07)-normal1.xy*bend;
|
||||
float3 normal2 = 2.0 * shSample(tex, nCoord + float2(-timer*0.04,-timer*0.03)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 0.5) + windDir * timer * (windSpeed*0.09)-normal2.xy*bend;
|
||||
float3 normal3 = 2.0 * shSample(tex, nCoord + float2(+timer*0.03,+timer*0.04)).rgb - 1.0;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE* 1.0) + windDir * timer * (windSpeed*0.4)-normal3.xy*bend;
|
||||
float3 normal4 = 2.0 * shSample(tex, nCoord + float2(-timer*0.2,+timer*0.1)).rgb - 1.0;
|
||||
nCoord = coords * (WAVE_SCALE * 2.0) + windDir * timer * (windSpeed*0.7)-normal4.xy*bend;
|
||||
float3 normal5 = 2.0 * shSample(tex, nCoord + float2(+timer*0.1,-timer*0.06)).rgb - 1.0;
|
||||
|
||||
|
||||
float3 normal = normalize(normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y);
|
||||
return normal;
|
||||
}
|
||||
|
||||
float3 perturb(shTexture2D tex, float2 coords, float bend, float2 windDir, float windSpeed, float timer)
|
||||
{
|
||||
bend *= WAVE_CHOPPYNESS;
|
||||
float3 col = float3(0,0,0);
|
||||
float2 nCoord = float2(0,0); //normal coords
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.025) + windDir * timer * (windSpeed*0.03);
|
||||
col += shSample(tex,nCoord + float2(-timer*0.005,-timer*0.01)).rgb*0.20;
|
||||
nCoord = coords * (WAVE_SCALE * 0.1) + windDir * timer * (windSpeed*0.05)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.01,+timer*0.005)).rgb*0.20;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE * 0.2) + windDir * timer * (windSpeed*0.1)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(-timer*0.02,-timer*0.03)).rgb*0.20;
|
||||
nCoord = coords * (WAVE_SCALE * 0.5) + windDir * timer * (windSpeed*0.2)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.03,+timer*0.02)).rgb*0.15;
|
||||
|
||||
nCoord = coords * (WAVE_SCALE* 0.8) + windDir * timer * (windSpeed*1.0)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex, nCoord + float2(-timer*0.06,+timer*0.08)).rgb*0.15;
|
||||
nCoord = coords * (WAVE_SCALE * 1.0) + windDir * timer * (windSpeed*1.3)-(col.xy/col.zz)*bend;
|
||||
col += shSample(tex,nCoord + float2(+timer*0.08,-timer*0.06)).rgb*0.10;
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
|
||||
float3 getCaustics (shTexture2D causticMap, float3 worldPos, float3 waterEyePos, float3 worldNormal, float3 lightDirectionWS0, float waterLevel, float waterTimer, float3 windDir_windSpeed)
|
||||
{
|
||||
float waterDepth = shSaturate((waterEyePos.z - worldPos.z) / 50.0);
|
||||
|
||||
float3 causticPos = intercept(worldPos.xyz, lightDirectionWS0.xyz, float3(0,0,1), waterLevel);
|
||||
|
||||
///\ todo clean this up
|
||||
float causticdepth = length(causticPos-worldPos.xyz);
|
||||
causticdepth = 1.0-shSaturate(causticdepth / VISIBILITY);
|
||||
causticdepth = shSaturate(causticdepth);
|
||||
|
||||
// NOTE: the original shader calculated a tangent space basis here,
|
||||
// but using only the world normal is cheaper and i couldn't see a visual difference
|
||||
// also, if this effect gets moved to screen-space some day, it's unlikely to have tangent information
|
||||
float3 causticNorm = worldNormal.xyz * perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).xyz * 2.0 - 1.0;
|
||||
causticNorm = float3(causticNorm.x, causticNorm.y, -causticNorm.z);
|
||||
|
||||
//float fresnel = pow(clamp(dot(LV,causticnorm),0.0,1.0),2.0);
|
||||
|
||||
float NdotL = max(dot(worldNormal.xyz, lightDirectionWS0.xyz),0.0);
|
||||
|
||||
float causticR = 1.0-perturb(causticMap, causticPos.xy, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
|
||||
/// \todo sunFade
|
||||
|
||||
// float3 caustics = clamp(pow(float3(causticR)*5.5,float3(5.5*causticdepth)),0.0,1.0)*NdotL*sunFade*causticdepth;
|
||||
float3 caustics = clamp(pow(float3(causticR,causticR,causticR)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)),0.0,1.0)*NdotL*causticdepth;
|
||||
float causticG = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
float causticB = 1.0-perturb(causticMap,causticPos.xy+(1.0-causticdepth)*ABBERATION*2.0, causticdepth, windDir_windSpeed.xy, windDir_windSpeed.z, waterTimer).z;
|
||||
//caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth)))*NdotL*sunFade*causticdepth;
|
||||
caustics = shSaturate(pow(float3(causticR,causticG,causticB)*5.5,float3(5.5*causticdepth,5.5*causticdepth,5.5*causticdepth)))*NdotL*causticdepth;
|
||||
|
||||
caustics *= 3.0;
|
||||
|
||||
// shore transition
|
||||
caustics = shLerp (float3(1,1,1), caustics, waterDepth);
|
||||
|
||||
return caustics;
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
material Water
|
||||
{
|
||||
allow_fixed_function false
|
||||
|
||||
pass
|
||||
{
|
||||
emissive 1.0 1.0 1.0
|
||||
ambient 0 0 0
|
||||
diffuse 0 0 0 1
|
||||
specular 0 0 0 32
|
||||
|
||||
vertex_program water_vertex
|
||||
fragment_program water_fragment
|
||||
|
||||
cull_hardware none
|
||||
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
|
||||
texture_unit reflectionMap
|
||||
{
|
||||
texture_alias WaterReflection
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit refractionMap
|
||||
{
|
||||
direct_texture WaterRefraction
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit depthMap
|
||||
{
|
||||
texture_alias SceneDepth
|
||||
tex_address_mode clamp
|
||||
}
|
||||
|
||||
texture_unit normalMap
|
||||
{
|
||||
texture water_nm.png
|
||||
}
|
||||
|
||||
texture_unit rippleNormalMap
|
||||
{
|
||||
direct_texture RippleNormal
|
||||
tex_address_mode border
|
||||
tex_border_colour 0.5 0.5 1.0
|
||||
}
|
||||
|
||||
// for simple_water
|
||||
texture_unit animatedTexture
|
||||
{
|
||||
create_in_ffp true
|
||||
scale 0.1 0.1
|
||||
alpha_op_ex source1 src_manual src_current 0.7
|
||||
}
|
||||
|
||||
texture_unit shadowMap0
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap1
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
texture_unit shadowMap2
|
||||
{
|
||||
content_type shadow
|
||||
tex_address_mode clamp
|
||||
filtering none
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
material openmw/Ripple
|
||||
{
|
||||
// this will be overridden by Water_RippleFrameCount fallback setting
|
||||
anim_texture2 textures\water\ripple.dds 4 0.25
|
||||
pass
|
||||
{
|
||||
scene_blend alpha_blend
|
||||
depth_write off
|
||||
cull_hardware none
|
||||
diffuse vertexcolour
|
||||
emissive 1 1 1
|
||||
ambient 0 0 0
|
||||
texture_unit diffuseMap
|
||||
{
|
||||
create_in_ffp true
|
||||
anim_texture2 $anim_texture2
|
||||
|
||||
// to make sure rotating doesn't cause the texture to repeat
|
||||
tex_address_mode border
|
||||
tex_border_colour 0 0 0 0
|
||||
}
|
||||
}
|
||||
}
|
@ -1,354 +0,0 @@
|
||||
#include "core.h"
|
||||
|
||||
|
||||
#define SIMPLE_WATER @shGlobalSettingBool(simple_water)
|
||||
|
||||
#if SIMPLE_WATER
|
||||
// --------------------------------------- SIMPLE WATER ---------------------------------------------------
|
||||
|
||||
#define FOG @shGlobalSettingBool(fog)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
shVertexInput(float2, uv0)
|
||||
shOutput(float2, UV)
|
||||
|
||||
#if FOG
|
||||
shOutput(float, depth)
|
||||
#endif
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
UV = uv0;
|
||||
#if FOG
|
||||
depth = shOutputPosition.z;
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shSampler2D(animatedTexture)
|
||||
shInput(float2, UV)
|
||||
shInput(float, depth)
|
||||
|
||||
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputColour(0).xyz = shSample(animatedTexture, UV * float2(15.0, 15.0)).xyz * float3(1.0, 1.0, 1.0);
|
||||
shOutputColour(0).w = 0.7;
|
||||
|
||||
#if FOG
|
||||
float fogValue = shSaturate((depth - fogParams.y) * fogParams.w);
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
||||
|
||||
// Inspired by Blender GLSL Water by martinsh ( http://devlog-martinsh.blogspot.de/2012/07/waterundewater-shader-wip.html )
|
||||
|
||||
#define SHADOWS_PSSM @shGlobalSettingBool(shadows_pssm)
|
||||
#define SHADOWS @shGlobalSettingBool(shadows)
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
#include "shadows.h"
|
||||
#endif
|
||||
|
||||
#define REFRACTION @shGlobalSettingBool(refraction)
|
||||
|
||||
#ifdef SH_VERTEX_SHADER
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||
|
||||
shOutput(float3, screenCoordsPassthrough)
|
||||
shOutput(float4, position)
|
||||
shOutput(float, depthPassthrough)
|
||||
|
||||
|
||||
#if SHADOWS
|
||||
shOutput(float4, lightSpacePos0)
|
||||
shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix)
|
||||
#endif
|
||||
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shOutput(float4, lightSpacePos@shIterator)
|
||||
shUniform(float4x4, texViewProjMatrix@shIterator) @shAutoConstant(texViewProjMatrix@shIterator, texture_viewproj_matrix, @shIterator)
|
||||
@shEndForeach
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
|
||||
#endif
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||
|
||||
|
||||
#if !SH_GLSL && !SH_GLSLES
|
||||
float4x4 scalemat = float4x4( 0.5, 0.0, 0.0, 0.5,
|
||||
0.0, -0.5, 0.0, 0.5,
|
||||
0.0, 0.0, 0.5, 0.5,
|
||||
0.0, 0.0, 0.0, 1.0 );
|
||||
#else
|
||||
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 0.5, 0.0,
|
||||
0.5, 0.5, 0.5, 1.0);
|
||||
#endif
|
||||
|
||||
float4 texcoordProj = shMatrixMult(scalemat, shOutputPosition);
|
||||
screenCoordsPassthrough = float3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
|
||||
|
||||
position = shInputPosition;
|
||||
|
||||
depthPassthrough = shOutputPosition.z;
|
||||
|
||||
|
||||
#if SHADOWS
|
||||
lightSpacePos0 = shMatrixMult(texViewProjMatrix0, shMatrixMult(worldMatrix, shInputPosition));
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float4 wPos = shMatrixMult(worldMatrix, shInputPosition);
|
||||
@shForeach(3)
|
||||
lightSpacePos@shIterator = shMatrixMult(texViewProjMatrix@shIterator, wPos);
|
||||
@shEndForeach
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// tweakables ----------------------------------------------------
|
||||
|
||||
#define VISIBILITY 1500.0 // how far you can look through water
|
||||
|
||||
#define BIG_WAVES_X 0.1 // strength of big waves
|
||||
#define BIG_WAVES_Y 0.1
|
||||
|
||||
#define MID_WAVES_X 0.1 // strength of middle sized waves
|
||||
#define MID_WAVES_Y 0.1
|
||||
|
||||
#define SMALL_WAVES_X 0.1 // strength of small waves
|
||||
#define SMALL_WAVES_Y 0.1
|
||||
|
||||
#define WAVE_CHOPPYNESS 0.05 // wave choppyness
|
||||
#define WAVE_SCALE 75.0 // overall wave scale
|
||||
|
||||
#define BUMP 0.5 // overall water surface bumpiness
|
||||
#define REFL_BUMP 0.15 // reflection distortion amount
|
||||
#define REFR_BUMP 0.06 // refraction distortion amount
|
||||
|
||||
#define SCATTER_AMOUNT 0.3 // amount of sunlight scattering
|
||||
#define SCATTER_COLOUR float3(0.0,1.0,0.95) // colour of sunlight scattering
|
||||
|
||||
#define SUN_EXT float3(0.45, 0.55, 0.68) //sunlight extinction
|
||||
|
||||
#define SPEC_HARDNESS 256.0 // specular highlights hardness
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
float fresnel_dielectric(float3 Incoming, float3 Normal, float eta)
|
||||
{
|
||||
/* compute fresnel reflectance without explicitly computing
|
||||
the refracted direction */
|
||||
float c = abs(dot(Incoming, Normal));
|
||||
float g = eta * eta - 1.0 + c * c;
|
||||
float result;
|
||||
|
||||
if(g > 0.0) {
|
||||
g = sqrt(g);
|
||||
float A =(g - c)/(g + c);
|
||||
float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0);
|
||||
result = 0.5 * A * A *(1.0 + B * B);
|
||||
}
|
||||
else
|
||||
result = 1.0; /* TIR (no refracted component) */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SH_BEGIN_PROGRAM
|
||||
shInput(float3, screenCoordsPassthrough)
|
||||
shInput(float4, position)
|
||||
shInput(float, depthPassthrough)
|
||||
|
||||
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
|
||||
|
||||
shSampler2D(reflectionMap)
|
||||
#if REFRACTION
|
||||
shSampler2D(refractionMap)
|
||||
#endif
|
||||
shSampler2D(depthMap)
|
||||
shSampler2D(normalMap)
|
||||
|
||||
shUniform(float4x4, wMat) @shAutoConstant(wMat, world_matrix)
|
||||
shUniform(float3, windDir_windSpeed) @shSharedParameter(windDir_windSpeed)
|
||||
#define WIND_SPEED windDir_windSpeed.z
|
||||
#define WIND_DIR windDir_windSpeed.xy
|
||||
|
||||
shUniform(float, waterTimer) @shSharedParameter(waterTimer)
|
||||
shUniform(float2, waterSunFade_sunHeight) @shSharedParameter(waterSunFade_sunHeight)
|
||||
|
||||
shUniform(float4, sunPosition) @shAutoConstant(sunPosition, light_position, 0)
|
||||
shUniform(float4, sunSpecular) @shAutoConstant(sunSpecular, light_specular_colour, 0)
|
||||
|
||||
shUniform(float, renderTargetFlipping) @shAutoConstant(renderTargetFlipping, render_target_flipping)
|
||||
|
||||
|
||||
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
|
||||
|
||||
shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position_object_space)
|
||||
|
||||
|
||||
#if SHADOWS
|
||||
shInput(float4, lightSpacePos0)
|
||||
shSampler2D(shadowMap0)
|
||||
shUniform(float2, invShadowmapSize0) @shAutoConstant(invShadowmapSize0, inverse_texture_size, 1)
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
@shForeach(3)
|
||||
shInput(float4, lightSpacePos@shIterator)
|
||||
shSampler2D(shadowMap@shIterator)
|
||||
shUniform(float2, invShadowmapSize@shIterator) @shAutoConstant(invShadowmapSize@shIterator, inverse_texture_size, @shIterator(1))
|
||||
@shEndForeach
|
||||
shUniform(float3, pssmSplitPoints) @shSharedParameter(pssmSplitPoints)
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart)
|
||||
#endif
|
||||
|
||||
|
||||
SH_START_PROGRAM
|
||||
{
|
||||
float3 worldPos = shMatrixMult (wMat, position).xyz;
|
||||
float2 UV = worldPos.xy / (8192.0*5.0) * 3.0;
|
||||
UV.y *= -1.0;
|
||||
|
||||
#if SHADOWS
|
||||
float shadow = depthShadowPCF (shadowMap0, lightSpacePos0, invShadowmapSize0);
|
||||
#endif
|
||||
#if SHADOWS_PSSM
|
||||
float shadow = pssmDepthShadow (lightSpacePos0, invShadowmapSize0, shadowMap0, lightSpacePos1, invShadowmapSize1, shadowMap1, lightSpacePos2, invShadowmapSize2, shadowMap2, depthPassthrough, pssmSplitPoints);
|
||||
#endif
|
||||
|
||||
#if SHADOWS || SHADOWS_PSSM
|
||||
float fadeRange = shadowFar_fadeStart.x - shadowFar_fadeStart.y;
|
||||
float fade = 1.0-((depthPassthrough - shadowFar_fadeStart.y) / fadeRange);
|
||||
shadow = (depthPassthrough > shadowFar_fadeStart.x) ? 1.0 : ((depthPassthrough > shadowFar_fadeStart.y) ? 1.0-((1.0-shadow)*fade) : shadow);
|
||||
#endif
|
||||
|
||||
#if !SHADOWS && !SHADOWS_PSSM
|
||||
float shadow = 1.0;
|
||||
#endif
|
||||
|
||||
|
||||
float2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
|
||||
screenCoords.y = (1.0-shSaturate(renderTargetFlipping))+renderTargetFlipping*screenCoords.y;
|
||||
|
||||
float2 nCoord = float2(0.0,0.0);
|
||||
|
||||
nCoord = UV * (WAVE_SCALE * 0.05) + WIND_DIR * waterTimer * (WIND_SPEED*0.04);
|
||||
float3 normal0 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.015,-waterTimer*0.005)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 0.1) + WIND_DIR * waterTimer * (WIND_SPEED*0.08)-(normal0.xy/normal0.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal1 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.020,+waterTimer*0.015)).rgb - 1.0;
|
||||
|
||||
nCoord = UV * (WAVE_SCALE * 0.25) + WIND_DIR * waterTimer * (WIND_SPEED*0.07)-(normal1.xy/normal1.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal2 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.04,-waterTimer*0.03)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 0.5) + WIND_DIR * waterTimer * (WIND_SPEED*0.09)-(normal2.xy/normal2.z)*WAVE_CHOPPYNESS;
|
||||
float3 normal3 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.03,+waterTimer*0.04)).rgb - 1.0;
|
||||
|
||||
nCoord = UV * (WAVE_SCALE* 1.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.4)-(normal3.xy/normal3.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal4 = 2.0 * shSample(normalMap, nCoord + float2(-waterTimer*0.02,+waterTimer*0.1)).rgb - 1.0;
|
||||
nCoord = UV * (WAVE_SCALE * 2.0) + WIND_DIR * waterTimer * (WIND_SPEED*0.7)-(normal4.xy/normal4.zz)*WAVE_CHOPPYNESS;
|
||||
float3 normal5 = 2.0 * shSample(normalMap, nCoord + float2(+waterTimer*0.1,-waterTimer*0.06)).rgb - 1.0;
|
||||
|
||||
|
||||
|
||||
float3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y);
|
||||
|
||||
normal = normalize(float3(normal.x * BUMP, normal.y * BUMP, normal.z));
|
||||
normal = float3(normal.x, normal.y, -normal.z);
|
||||
|
||||
// normal for sunlight scattering
|
||||
float3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
|
||||
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1).xyz;
|
||||
lNormal = normalize(float3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z));
|
||||
lNormal = float3(lNormal.x, lNormal.y, -lNormal.z);
|
||||
|
||||
|
||||
float3 lVec = normalize(sunPosition.xyz);
|
||||
float3 vVec = normalize(position.xyz - cameraPos.xyz);
|
||||
|
||||
|
||||
float isUnderwater = (cameraPos.z > 0.0) ? 0.0 : 1.0;
|
||||
|
||||
// sunlight scattering
|
||||
float3 pNormal = float3(0,0,1);
|
||||
float3 lR = reflect(lVec, lNormal);
|
||||
float3 llR = reflect(lVec, pNormal);
|
||||
|
||||
float s = shSaturate(dot(lR, vVec)*2.0-1.2);
|
||||
float lightScatter = shadow * shSaturate(dot(-lVec,lNormal)*0.7+0.3) * s * SCATTER_AMOUNT * waterSunFade_sunHeight.x * shSaturate(1.0-exp(-waterSunFade_sunHeight.y));
|
||||
float3 scatterColour = shLerp(float3(SCATTER_COLOUR)*float3(1.0,0.4,0.0), SCATTER_COLOUR, shSaturate(1.0-exp(-waterSunFade_sunHeight.y*SUN_EXT)));
|
||||
|
||||
// fresnel
|
||||
float ior = (cameraPos.z>0.0)?(1.333/1.0):(1.0/1.333); //air to water; water to air
|
||||
float fresnel = fresnel_dielectric(-vVec, normal, ior);
|
||||
|
||||
fresnel = shSaturate(fresnel);
|
||||
|
||||
// reflection
|
||||
float3 reflection = shSample(reflectionMap, screenCoords+(normal.xy*REFL_BUMP)).rgb;
|
||||
|
||||
// refraction
|
||||
float3 R = reflect(vVec, normal);
|
||||
|
||||
#if REFRACTION
|
||||
float3 refraction = shSample(refractionMap, (screenCoords-(normal.xy*REFR_BUMP))*1.0).rgb;
|
||||
|
||||
// brighten up the refraction underwater
|
||||
refraction = (cameraPos.z < 0.0) ? shSaturate(refraction * 1.5) : refraction;
|
||||
#endif
|
||||
|
||||
// specular
|
||||
float specular = pow(max(dot(R, lVec), 0.0),SPEC_HARDNESS) * shadow;
|
||||
|
||||
#if REFRACTION
|
||||
shOutputColour(0).xyz = shLerp( shLerp(refraction, scatterColour, lightScatter), reflection, fresnel) + specular * sunSpecular.xyz;
|
||||
#else
|
||||
shOutputColour(0).xyz = shLerp(reflection, float3(0.090195, 0.115685, 0.12745), (1.0-fresnel)*0.5) + specular * sunSpecular.xyz;
|
||||
#endif
|
||||
// fog
|
||||
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
|
||||
|
||||
#if REFRACTION
|
||||
shOutputColour(0).w = 1.0;
|
||||
#else
|
||||
shOutputColour(0).w = shSaturate(fresnel*2.0 + specular);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
shader_set water_vertex
|
||||
{
|
||||
source water.shader
|
||||
type vertex
|
||||
profiles_cg vs_2_0 vp40 arbvp1
|
||||
profiles_hlsl vs_3_0 vs_2_0
|
||||
}
|
||||
|
||||
shader_set water_fragment
|
||||
{
|
||||
source water.shader
|
||||
type fragment
|
||||
profiles_cg ps_2_x ps_2_0 ps fp40 arbfp1
|
||||
profiles_hlsl ps_3_0 ps_2_0
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 753 B |
Binary file not shown.
Before Width: | Height: | Size: 24 KiB |
Loading…
Reference in New Issue