diff --git a/extern/shiny b/extern/shiny index fdc92a424..2408fda3e 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit fdc92a4243c98f5d86a33cbdf2ed0fbb94dad3f6 +Subproject commit 2408fda3e226dda1a1aa7bafd07a769324419b37 diff --git a/files/materials/clouds.shader b/files/materials/clouds.shader index 7677ecd95..f4258bf5d 100644 --- a/files/materials/clouds.shader +++ b/files/materials/clouds.shader @@ -6,7 +6,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shColourInput(float4) shOutput(float4, colourPassthrough) diff --git a/files/materials/core.h b/files/materials/core.h index c4d287761..306073a77 100644 --- a/files/materials/core.h +++ b/files/materials/core.h @@ -11,6 +11,7 @@ #define shUniform(type, name) , uniform type name + #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) @@ -52,7 +53,8 @@ #endif #if SH_GLSL == 1 - @version 130 + + @version 120 #define float2 vec2 #define float3 vec3 @@ -61,7 +63,7 @@ #define int3 ivec3 #define int4 ivec4/ #define shTexture2D sampler2D - #define shSample(tex, coord) texture(tex, coord) + #define shSample(tex, coord) texture2D(tex, coord) #define shLerp(a, b, t) mix(a, b, t) #define shSaturate(a) clamp(a, 0.0, 1.0) @@ -71,13 +73,19 @@ #define shMatrixMult(m, v) (m * v) + #define shOutputPosition gl_Position + + #define float4x4 mat4 + + // GLSL 1.3 + #if 0 + // automatically recognized by ogre when the input name equals this #define shInputPosition vertex - #define shOutputPosition gl_Position #define shOutputColour(num) oColor##num - #define float4x4 mat4 + #define shInput(type, name) in type name; #define shOutput(type, name) out type name; @@ -105,5 +113,47 @@ void main(void) + #endif + + #endif + + // GLSL 1.2 + + #if 1 + + // automatically recognized by ogre when the input name equals this + #define shInputPosition gl_Vertex + + #define shOutputColour(num) gl_FragData[num] + + #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 + + #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 diff --git a/files/materials/moon.shader b/files/materials/moon.shader index 4a4eaf0b4..7640563ce 100644 --- a/files/materials/moon.shader +++ b/files/materials/moon.shader @@ -7,7 +7,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) SH_START_PROGRAM diff --git a/files/materials/objects.shader b/files/materials/objects.shader index 39c9b42e0..238ccdcf6 100644 --- a/files/materials/objects.shader +++ b/files/materials/objects.shader @@ -28,7 +28,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shNormalInput(float4) #ifdef NEED_DEPTH @@ -207,6 +207,7 @@ float3 waterEyePos = float3(1,1,1); if (worldPos.y < waterLevel && waterEnabled == 1) { + // NOTE: this calculation would be wrong for non-uniform scaling float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0)); waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel); caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed); diff --git a/files/materials/quad.shader b/files/materials/quad.shader index 4fa38cac9..4620588c3 100644 --- a/files/materials/quad.shader +++ b/files/materials/quad.shader @@ -3,7 +3,7 @@ #ifdef SH_VERTEX_SHADER SH_BEGIN_PROGRAM - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) SH_START_PROGRAM diff --git a/files/materials/shadowcaster.shader b/files/materials/shadowcaster.shader index a5551509d..b312d414c 100644 --- a/files/materials/shadowcaster.shader +++ b/files/materials/shadowcaster.shader @@ -6,7 +6,7 @@ SH_BEGIN_PROGRAM #if ALPHA - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) #endif shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) diff --git a/files/materials/stars.shader b/files/materials/stars.shader index 75592fc72..5a55d171e 100644 --- a/files/materials/stars.shader +++ b/files/materials/stars.shader @@ -7,7 +7,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shOutput(float, fade) diff --git a/files/materials/sun.shader b/files/materials/sun.shader index ceab60565..45cd2f24b 100644 --- a/files/materials/sun.shader +++ b/files/materials/sun.shader @@ -7,7 +7,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) SH_START_PROGRAM diff --git a/files/materials/terrain.shader b/files/materials/terrain.shader index e0187959f..a562d1ec3 100644 --- a/files/materials/terrain.shader +++ b/files/materials/terrain.shader @@ -54,8 +54,8 @@ shUniform(float2, lodMorph) @shAutoConstant(lodMorph, custom, 1001) - shInput(float2, uv0) - shInput(float2, delta) // lodDelta, lodThreshold + shVertexInput(float2, uv0) + shVertexInput(float2, delta) // lodDelta, lodThreshold #if SHADOWS shUniform(float4x4, texViewProjMatrix0) @shAutoConstant(texViewProjMatrix0, texture_viewproj_matrix) @@ -226,6 +226,7 @@ float3 waterEyePos = float3(1,1,1); if (worldPos.y < waterLevel) { + // NOTE: this calculation would be wrong for non-uniform scaling float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0)); waterEyePos = intercept(worldPos, cameraPos.xyz - worldPos, float3(0,1,0), waterLevel); caustics = getCaustics(causticMap, worldPos, waterEyePos.xyz, worldNormal.xyz, lightDirectionWS0.xyz, waterLevel, waterTimer, windDir_windSpeed); diff --git a/files/materials/water.shader b/files/materials/water.shader index 805cf7b81..2145919b0 100644 --- a/files/materials/water.shader +++ b/files/materials/water.shader @@ -15,7 +15,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shOutput(float, depth) @@ -67,7 +67,7 @@ SH_BEGIN_PROGRAM shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) - shInput(float2, uv0) + shVertexInput(float2, uv0) shOutput(float2, UV) shOutput(float3, screenCoordsPassthrough)