From e2ad1b298959f3046f8a4a9f56038f454c6d10ed Mon Sep 17 00:00:00 2001 From: RobertBeckebans Date: Sun, 20 Apr 2014 17:44:17 +0200 Subject: [PATCH] More Cg shader fixes for Mesa and Qualcomm drivers #90 --- base/renderprogs/global.inc | 9 +++++++++ base/renderprogs/heatHazeWithMask.vertex | 7 ++++++- base/renderprogs/heatHazeWithMaskAndVertex.vertex | 5 +++++ base/renderprogs/heathaze.vertex | 5 +++++ base/renderprogs/skinning.inc | 6 ++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/base/renderprogs/global.inc b/base/renderprogs/global.inc index 74f33ffb..715776f0 100644 --- a/base/renderprogs/global.inc +++ b/base/renderprogs/global.inc @@ -3,6 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -158,6 +159,14 @@ float rand( float2 co ) { return frac( sin( dot( co.xy, float2( 12.9898, 78.233 ) ) ) * 43758.5453 ); } +// RB begin +#ifndef PI +#define PI 3.14159265358979323846 +#endif + +#define DEG2RAD( a ) ( ( a ) * PI / 180.0f ) +#define RAD2DEG( a ) ( ( a ) * 180.0f / PI ) +// RB end #define _half2( x ) half2( x ) #define _half3( x ) half3( x ) diff --git a/base/renderprogs/heatHazeWithMask.vertex b/base/renderprogs/heatHazeWithMask.vertex index 31e7fd9f..88dace45 100644 --- a/base/renderprogs/heatHazeWithMask.vertex +++ b/base/renderprogs/heatHazeWithMask.vertex @@ -2,7 +2,8 @@ =========================================================================== Doom 3 BFG Edition GPL Source Code -Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -28,7 +29,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc" +// RB: no GPU skinning with ES 2.0 +#if defined(USE_GPU_SKINNING) uniform matrices_ubo { float4 matrices[408]; }; +#endif +// RB end uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude diff --git a/base/renderprogs/heatHazeWithMaskAndVertex.vertex b/base/renderprogs/heatHazeWithMaskAndVertex.vertex index e5a6c2f6..857c629f 100644 --- a/base/renderprogs/heatHazeWithMaskAndVertex.vertex +++ b/base/renderprogs/heatHazeWithMaskAndVertex.vertex @@ -3,6 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -28,7 +29,11 @@ If you have questions concerning this license or the applicable additional terms #include "global.inc" +// RB: no GPU skinning with ES 2.0 +#if defined(USE_GPU_SKINNING) uniform matrices_ubo { float4 matrices[408]; }; +#endif +// RB end uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude diff --git a/base/renderprogs/heathaze.vertex b/base/renderprogs/heathaze.vertex index b194add2..9a661350 100644 --- a/base/renderprogs/heathaze.vertex +++ b/base/renderprogs/heathaze.vertex @@ -3,6 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -33,7 +34,11 @@ If you have questions concerning this license or the applicable additional terms uniform float4 rpUser0 : register(c128); // rpScroll uniform float4 rpUser1 : register(c129); // rpDeformMagnitude +// RB: no GPU skinning with ES 2.0 +#if defined(USE_GPU_SKINNING) uniform matrices_ubo { float4 matrices[408]; }; +#endif +// RB end struct VS_IN { float4 position : POSITION; diff --git a/base/renderprogs/skinning.inc b/base/renderprogs/skinning.inc index 05dfb3f0..02e00495 100644 --- a/base/renderprogs/skinning.inc +++ b/base/renderprogs/skinning.inc @@ -3,6 +3,7 @@ Doom 3 BFG Edition GPL Source Code Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. +Copyright (C) 2013 Robert Beckebans This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). @@ -27,6 +28,9 @@ If you have questions concerning this license or the applicable additional terms */ float4 modelPosition = vertex.position; + +// RB: no GPU skinning with ES 2.0 +#if defined(USE_GPU_SKINNING) BRANCH if ( rpEnableSkinning.x > 0.0 ) { //-------------------------------------------------------------- // GPU transformation of the normal / binormal / bitangent @@ -64,6 +68,8 @@ BRANCH if ( rpEnableSkinning.x > 0.0 ) { modelPosition.z = dot4( matZ, vertex.position ); modelPosition.w = 1.0; } +#endif +// RB end result.position.x = dot4( modelPosition, rpMVPmatrixX ); result.position.y = dot4( modelPosition, rpMVPmatrixY );