fog, mrt depth

actorid
scrawl 13 years ago
parent de9b7a51de
commit f8e3213996

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 shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
#define shNormalInput(type) , in type normal : NORMAL
#ifdef SH_VERTEX_SHADER
#define shOutputPosition oPosition
@ -32,7 +34,9 @@
#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 \
void main( \
@ -67,13 +71,14 @@
#define shInputPosition vertex
#define shOutputPosition gl_Position
#define shOutputColor oColor
#define shOutputColor(num) oColor##num
#define float4x4 mat4
#define shInput(type, name) in type name;
#define shOutput(type, name) out type name;
#define shNormalInput(type) in type normal;
#ifdef SH_VERTEX_SHADER
@ -86,8 +91,10 @@
#ifdef SH_FRAGMENT_SHADER
#define shDeclareMrtOutput(num) out vec4 oColor##num;
#define SH_BEGIN_PROGRAM \
out float4 oColor;
out float4 oColor0;
#define SH_START_PROGRAM \
void main(void)

@ -6,6 +6,8 @@ material openmw_objects_base
emissive 0.0 0.0 0.0
has_vertex_colour false
diffuseMap black.png
fog true
is_transparent false // real transparency, alpha rejection doesn't count here
pass
{
@ -16,9 +18,12 @@ material openmw_objects_base
specular $specular
ambient $ambient
emissive $emissive
fog $fog
ffp_vertex_colour_ambient $has_vertex_colour
has_vertex_colour $has_vertex_colour
is_transparent $is_transparent
texture_unit diffuseMap
{

@ -1,15 +1,36 @@
#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
SH_BEGIN_PROGRAM
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
shInput(float2, uv0)
shOutput(float2, UV)
shNormalInput(float4)
shOutput(float4, normalPassthrough)
#ifdef NEED_DEPTH
shOutput(float, depthPassthrough)
#endif
SH_START_PROGRAM
{
shOutputPosition = shMatrixMult(wvp, shInputPosition);
UV = uv0;
normalPassthrough = normal;
#ifdef NEED_DEPTH
depthPassthrough = shOutputPosition.z;
#endif
}
#else
@ -17,11 +38,31 @@
SH_BEGIN_PROGRAM
shSampler2D(diffuseMap)
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
{
// shOutputColor = float4(1.0, 0.0, 0.0, 1.0);
shOutputColor = shSample(diffuseMap, UV);
//shOutputColor(0) = float4((normalize(normalPassthrough.xyz)+float3(1.0,1.0,1.0)) / 2.f, 1.0);
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

Loading…
Cancel
Save