mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-27 09:36:49 +00:00
fog, mrt depth
This commit is contained in:
parent
de9b7a51de
commit
f8e3213996
4 changed files with 59 additions and 6 deletions
2
extern/shiny
vendored
2
extern/shiny
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 3928949316713d0c8aaf1ad564734d24ad773be9
|
Subproject commit 8d95f53464a779c7da643228ace02ae28ec6a503
|
|
@ -14,6 +14,8 @@
|
||||||
#define shInput(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 shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
|
||||||
|
|
||||||
|
#define shNormalInput(type) , in type normal : NORMAL
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
#define shOutputPosition oPosition
|
#define shOutputPosition oPosition
|
||||||
|
@ -32,7 +34,9 @@
|
||||||
|
|
||||||
#ifdef SH_FRAGMENT_SHADER
|
#ifdef SH_FRAGMENT_SHADER
|
||||||
|
|
||||||
#define shOutputColor oColor
|
#define shOutputColor(num) oColor##num
|
||||||
|
|
||||||
|
#define shDeclareMrtOutput(num) , out float4 oColor##num : COLOR##num
|
||||||
|
|
||||||
#define SH_BEGIN_PROGRAM \
|
#define SH_BEGIN_PROGRAM \
|
||||||
void main( \
|
void main( \
|
||||||
|
@ -67,13 +71,14 @@
|
||||||
|
|
||||||
#define shInputPosition vertex
|
#define shInputPosition vertex
|
||||||
#define shOutputPosition gl_Position
|
#define shOutputPosition gl_Position
|
||||||
#define shOutputColor oColor
|
#define shOutputColor(num) oColor##num
|
||||||
|
|
||||||
#define float4x4 mat4
|
#define float4x4 mat4
|
||||||
|
|
||||||
#define shInput(type, name) in type name;
|
#define shInput(type, name) in type name;
|
||||||
#define shOutput(type, name) out type name;
|
#define shOutput(type, name) out type name;
|
||||||
|
|
||||||
|
#define shNormalInput(type) in type normal;
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
|
@ -86,8 +91,10 @@
|
||||||
|
|
||||||
#ifdef SH_FRAGMENT_SHADER
|
#ifdef SH_FRAGMENT_SHADER
|
||||||
|
|
||||||
|
#define shDeclareMrtOutput(num) out vec4 oColor##num;
|
||||||
|
|
||||||
#define SH_BEGIN_PROGRAM \
|
#define SH_BEGIN_PROGRAM \
|
||||||
out float4 oColor;
|
out float4 oColor0;
|
||||||
#define SH_START_PROGRAM \
|
#define SH_START_PROGRAM \
|
||||||
void main(void)
|
void main(void)
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ material openmw_objects_base
|
||||||
emissive 0.0 0.0 0.0
|
emissive 0.0 0.0 0.0
|
||||||
has_vertex_colour false
|
has_vertex_colour false
|
||||||
diffuseMap black.png
|
diffuseMap black.png
|
||||||
|
fog true
|
||||||
|
is_transparent false // real transparency, alpha rejection doesn't count here
|
||||||
|
|
||||||
pass
|
pass
|
||||||
{
|
{
|
||||||
|
@ -16,10 +18,13 @@ material openmw_objects_base
|
||||||
specular $specular
|
specular $specular
|
||||||
ambient $ambient
|
ambient $ambient
|
||||||
emissive $emissive
|
emissive $emissive
|
||||||
|
fog $fog
|
||||||
|
|
||||||
ffp_vertex_colour_ambient $has_vertex_colour
|
ffp_vertex_colour_ambient $has_vertex_colour
|
||||||
has_vertex_colour $has_vertex_colour
|
has_vertex_colour $has_vertex_colour
|
||||||
|
|
||||||
|
is_transparent $is_transparent
|
||||||
|
|
||||||
texture_unit diffuseMap
|
texture_unit diffuseMap
|
||||||
{
|
{
|
||||||
texture $diffuseMap
|
texture $diffuseMap
|
||||||
|
|
|
@ -1,15 +1,36 @@
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define FOG @shPropertyBool(fog)
|
||||||
|
#define MRT @shPropertyNotBool(is_transparent)
|
||||||
|
|
||||||
|
#if MRT
|
||||||
|
#define NEED_DEPTH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FOG
|
||||||
|
#define NEED_DEPTH
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SH_VERTEX_SHADER
|
#ifdef SH_VERTEX_SHADER
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
|
||||||
shInput(float2, uv0)
|
shInput(float2, uv0)
|
||||||
shOutput(float2, UV)
|
shOutput(float2, UV)
|
||||||
|
shNormalInput(float4)
|
||||||
|
shOutput(float4, normalPassthrough)
|
||||||
|
#ifdef NEED_DEPTH
|
||||||
|
shOutput(float, depthPassthrough)
|
||||||
|
#endif
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
||||||
UV = uv0;
|
UV = uv0;
|
||||||
|
normalPassthrough = normal;
|
||||||
|
#ifdef NEED_DEPTH
|
||||||
|
depthPassthrough = shOutputPosition.z;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -17,11 +38,31 @@
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
shSampler2D(diffuseMap)
|
shSampler2D(diffuseMap)
|
||||||
shInput(float2, UV)
|
shInput(float2, UV)
|
||||||
|
shDeclareMrtOutput(1)
|
||||||
|
shInput(float4, normalPassthrough)
|
||||||
|
|
||||||
|
#ifdef NEED_DEPTH
|
||||||
|
shInput(float, depthPassthrough)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shUniform(float far) @shAutoConstant(far, far_clip_distance)
|
||||||
|
|
||||||
|
#if FOG
|
||||||
|
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
|
||||||
|
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
|
||||||
|
|
||||||
|
#endif
|
||||||
SH_START_PROGRAM
|
SH_START_PROGRAM
|
||||||
{
|
{
|
||||||
// shOutputColor = float4(1.0, 0.0, 0.0, 1.0);
|
//shOutputColor(0) = float4((normalize(normalPassthrough.xyz)+float3(1.0,1.0,1.0)) / 2.f, 1.0);
|
||||||
shOutputColor = shSample(diffuseMap, UV);
|
shOutputColor(0) = shSample(diffuseMap, UV);
|
||||||
|
|
||||||
|
#if FOG
|
||||||
|
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
|
||||||
|
shOutputColor(0).xyz = shLerp (shOutputColor(0).xyz, fogColor, fogValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shOutputColor(1) = float4(depthPassthrough / far,1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue