From a3c4099111ae6288174bf066d5f5050426ec4351 Mon Sep 17 00:00:00 2001 From: lanariel Date: Thu, 20 Feb 2014 15:15:54 +0100 Subject: [PATCH] Global Tint --- Code/Game/GameClient/GameClientState/GameState.cpp | 4 +++- Code/OysterGraphics/Definitions/GraphicalDefinition.h | 3 +++ Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 2 ++ Code/OysterGraphics/DllInterfaces/GFXAPI.h | 3 +++ Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl | 4 ++-- Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl | 2 +- Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli | 2 +- Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl | 7 +++++-- 8 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 532bd29d..e086e7e1 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -89,7 +89,9 @@ bool GameState::Init( SharedStateContent &shared ) Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); - gfxOp.AmbientValue = 1.0f; + gfxOp.AmbientValue = 0.5f; + gfxOp.GlobalGlowTint = Math::Float3(2,1,1); + gfxOp.GlobalTint = Math::Float3(1,1,1); Graphics::API::SetOptions(gfxOp); //tell server ready diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index c9b42c00..f6a6431c 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -62,6 +62,9 @@ namespace Oyster struct PostData { float Amb; + Math::Float3 Tint; + Math::Float3 GlowTint; + float PAD; }; struct Text2D diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 41063265..8f01bea4 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -123,6 +123,8 @@ namespace Oyster Definitions::PostData pd; pd.Amb = option.AmbientValue; + pd.Tint = option.GlobalTint; + pd.GlowTint = option.GlobalGlowTint; void* data = Render::Resources::Post::Data.Map(); memcpy(data,&pd,sizeof(Definitions::PostData)); diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 827f639f..795f649a 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -30,6 +30,9 @@ namespace Oyster //between 0-1 float AmbientValue; + Math::Float3 GlobalTint; + Math::Float3 GlobalGlowTint; + Math::Float2 Resolution; //Bytes on the GPU diff --git a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl index af095acf..11447238 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Gather/GatherPixel.hlsl @@ -41,8 +41,8 @@ PixelOut main(VertexOut input) { PixelOut output; float4 DiffGlow = Diffuse.Sample(S1, input.UV); - float3 tint = Color*(1-DiffGlow) + GlowColor * DiffGlow; - tint = tint / 2; + float3 tint = Color*(1-DiffGlow.w) + GlowColor * DiffGlow.w; + tint = Color*(1-DiffGlow.w) + GlowColor * DiffGlow.w; output.DiffuseGlow = DiffGlow * float4(tint,1); //NORMALIZE diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 96b8ab69..89ed06d3 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -47,7 +47,7 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) DepthBase = DepthBase /4; Ambient[DTid.xy/2] = float4(DiffBase.xyz, AmbValue); Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; - Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w * 10 /* * (2-DepthBase) */,1); + Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffBase.xyz * DiffBase.w /* * (2-DepthBase) */,DiffBase.w); Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz * float3(1,1,-1),1); } diff --git a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli index f2258905..c71cb4d5 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli @@ -1,7 +1,7 @@ #include "Defines.hlsli" #include "PosManipulation.hlsli" -static float Radius = 10; +static float Radius = 1; float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) { diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index 258d0f25..f7721d38 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -9,6 +9,8 @@ SamplerState S1 : register(s0); cbuffer Size : register(b0) { float AmbFactor; + float3 Color; + float3 GlowColor; } [numthreads(16, 16, 1)] @@ -26,9 +28,10 @@ void main( uint3 DTid : SV_DispatchThreadID ) SSAO = SSAO / 16; float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); - float3 Amb = Ambient[DTid.xy/2].xyz * SSAO; + float3 Amb = Ambient[DTid.xy/2].xyz * SSAO * Color; - float3 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)].xyz; + float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; + Glow = float4(Glow.xyz * GlowColor, 1); float4 GUI; uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);