mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-01 17:28:00 +03:00
Merge branch 'master' of https://github.com/MontyTRC89/TR5Main
This commit is contained in:
commit
c3890b0e68
6 changed files with 56 additions and 12 deletions
|
@ -35,6 +35,11 @@ cbuffer CShadowLightBuffer : register(b4)
|
||||||
float3 Padding2;
|
float3 Padding2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cbuffer RoomBuffer : register(b5)
|
||||||
|
{
|
||||||
|
float4 AmbientColor;
|
||||||
|
};
|
||||||
|
|
||||||
struct VertexShaderInput
|
struct VertexShaderInput
|
||||||
{
|
{
|
||||||
float3 Position: POSITION;
|
float3 Position: POSITION;
|
||||||
|
@ -61,7 +66,6 @@ Texture2D CausticsTexture : register(t1);
|
||||||
|
|
||||||
Texture2D ShadowMap : register(t2);
|
Texture2D ShadowMap : register(t2);
|
||||||
SamplerState ShadowMapSampler : register(s1);
|
SamplerState ShadowMapSampler : register(s1);
|
||||||
|
|
||||||
PixelShaderInput VS(VertexShaderInput input)
|
PixelShaderInput VS(VertexShaderInput input)
|
||||||
{
|
{
|
||||||
PixelShaderInput output;
|
PixelShaderInput output;
|
||||||
|
@ -76,6 +80,19 @@ PixelShaderInput VS(VertexShaderInput input)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getShadowFactor(Texture2D shadowMap, SamplerState shadowMapSampler, float2 coords, float realDepth) {
|
||||||
|
const float texelSize = 1.0f / 1024;
|
||||||
|
float shadowFactor = 0.0f;
|
||||||
|
//doing 9 samples
|
||||||
|
for (float x = -1; x <= 1.0f; x++) {
|
||||||
|
for (float y = -1; y <= 1.0f; y++) {
|
||||||
|
float shadowMapDepth = ShadowMap.SampleLevel(ShadowMapSampler, coords + (float2(x, y)*texelSize),0).r;
|
||||||
|
shadowFactor += shadowMapDepth < realDepth ? 1.0f : 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shadowFactor / 9.0f;
|
||||||
|
}
|
||||||
|
|
||||||
[earlydepthstencil]
|
[earlydepthstencil]
|
||||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
{
|
{
|
||||||
|
@ -104,8 +121,8 @@ float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
float realDepth = input.LightPosition.z;
|
float realDepth = input.LightPosition.z;
|
||||||
|
|
||||||
// If clip space z value greater than shadow map value then pixel is in shadow
|
// If clip space z value greater than shadow map value then pixel is in shadow
|
||||||
if (shadowMapDepth < realDepth)
|
float shadow = getShadowFactor(ShadowMap, ShadowMapSampler, coords, realDepth);
|
||||||
return float4(output.xyz* colorMul.xyz / 2.0f, 1.0f);
|
lighting = lerp(lighting, AmbientColor * 2, saturate(shadow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,3 +177,4 @@ float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1136,7 +1136,7 @@ int CreatureActive(short itemNumber)
|
||||||
|
|
||||||
void InitialiseCreature(short itemNumber)
|
void InitialiseCreature(short itemNumber)
|
||||||
{
|
{
|
||||||
InitialiseCreature(itemNumber);
|
ClearItem(itemNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StalkBox(ITEM_INFO* item, ITEM_INFO* enemy, short boxNumber)
|
int StalkBox(ITEM_INFO* item, ITEM_INFO* enemy, short boxNumber)
|
||||||
|
|
|
@ -73,7 +73,7 @@ typedef enum RENDERER_FADE_STATUS {
|
||||||
FADE_OUT
|
FADE_OUT
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SHADOW_MAP_SIZE 2048
|
#define SHADOW_MAP_SIZE 1024
|
||||||
|
|
||||||
#define TEXTURE_ATLAS_SIZE 4096
|
#define TEXTURE_ATLAS_SIZE 4096
|
||||||
#define TEXTURE_PAGE_SIZE 262144
|
#define TEXTURE_PAGE_SIZE 262144
|
||||||
|
|
|
@ -602,7 +602,7 @@ bool Renderer11::Initialise(int w, int h, int refreshRate, bool windowed, HWND h
|
||||||
m_cbLights = createConstantBuffer(sizeof(CLightBuffer));
|
m_cbLights = createConstantBuffer(sizeof(CLightBuffer));
|
||||||
m_cbMisc = createConstantBuffer(sizeof(CMiscBuffer));
|
m_cbMisc = createConstantBuffer(sizeof(CMiscBuffer));
|
||||||
m_cbShadowMap = createConstantBuffer(sizeof(CShadowLightBuffer));
|
m_cbShadowMap = createConstantBuffer(sizeof(CShadowLightBuffer));
|
||||||
|
m_cbRoom = createConstantBuffer(sizeof(CRoomBuffer));
|
||||||
m_currentCausticsFrame = 0;
|
m_currentCausticsFrame = 0;
|
||||||
m_firstWeather = true;
|
m_firstWeather = true;
|
||||||
|
|
||||||
|
@ -921,7 +921,9 @@ bool Renderer11::drawRooms(bool transparent, bool animated)
|
||||||
m_stMisc.AlphaTest = !transparent;
|
m_stMisc.AlphaTest = !transparent;
|
||||||
updateConstantBuffer(m_cbMisc, &m_stMisc, sizeof(CMiscBuffer));
|
updateConstantBuffer(m_cbMisc, &m_stMisc, sizeof(CMiscBuffer));
|
||||||
m_context->PSSetConstantBuffers(3, 1, &m_cbMisc);
|
m_context->PSSetConstantBuffers(3, 1, &m_cbMisc);
|
||||||
|
m_stRoom.AmbientColor = room->AmbientLight;
|
||||||
|
updateConstantBuffer(m_cbRoom, &m_stRoom, sizeof(CRoomBuffer));
|
||||||
|
m_context->PSSetConstantBuffers(5, 1, &m_cbRoom);
|
||||||
for (int j = firstBucket; j < lastBucket; j++)
|
for (int j = firstBucket; j < lastBucket; j++)
|
||||||
{
|
{
|
||||||
RendererBucket* bucket;
|
RendererBucket* bucket;
|
||||||
|
|
|
@ -582,6 +582,10 @@ struct CMiscBuffer {
|
||||||
float Padding[14];
|
float Padding[14];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CRoomBuffer {
|
||||||
|
Vector4 AmbientColor;
|
||||||
|
};
|
||||||
|
|
||||||
struct RendererAnimatedTexture
|
struct RendererAnimatedTexture
|
||||||
{
|
{
|
||||||
int Id;
|
int Id;
|
||||||
|
@ -832,6 +836,8 @@ private:
|
||||||
ID3D11Buffer* m_cbLights;
|
ID3D11Buffer* m_cbLights;
|
||||||
CMiscBuffer m_stMisc;
|
CMiscBuffer m_stMisc;
|
||||||
ID3D11Buffer* m_cbMisc;
|
ID3D11Buffer* m_cbMisc;
|
||||||
|
CRoomBuffer m_stRoom;
|
||||||
|
ID3D11Buffer* m_cbRoom;
|
||||||
CShadowLightBuffer m_stShadowMap;
|
CShadowLightBuffer m_stShadowMap;
|
||||||
ID3D11Buffer* m_cbShadowMap;
|
ID3D11Buffer* m_cbShadowMap;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,11 @@ cbuffer CShadowLightBuffer : register(b4)
|
||||||
float3 Padding2;
|
float3 Padding2;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cbuffer RoomBuffer : register(b5)
|
||||||
|
{
|
||||||
|
float4 AmbientColor;
|
||||||
|
};
|
||||||
|
|
||||||
struct VertexShaderInput
|
struct VertexShaderInput
|
||||||
{
|
{
|
||||||
float3 Position: POSITION;
|
float3 Position: POSITION;
|
||||||
|
@ -61,7 +66,6 @@ Texture2D CausticsTexture : register(t1);
|
||||||
|
|
||||||
Texture2D ShadowMap : register(t2);
|
Texture2D ShadowMap : register(t2);
|
||||||
SamplerState ShadowMapSampler : register(s1);
|
SamplerState ShadowMapSampler : register(s1);
|
||||||
|
|
||||||
PixelShaderInput VS(VertexShaderInput input)
|
PixelShaderInput VS(VertexShaderInput input)
|
||||||
{
|
{
|
||||||
PixelShaderInput output;
|
PixelShaderInput output;
|
||||||
|
@ -76,6 +80,19 @@ PixelShaderInput VS(VertexShaderInput input)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float getShadowFactor(Texture2D shadowMap, SamplerState shadowMapSampler, float2 coords, float realDepth) {
|
||||||
|
const float texelSize = 1.0f / 1024;
|
||||||
|
float shadowFactor = 0.0f;
|
||||||
|
//doing 9 samples
|
||||||
|
for (float x = -1; x <= 1.0f; x++) {
|
||||||
|
for (float y = -1; y <= 1.0f; y++) {
|
||||||
|
float shadowMapDepth = ShadowMap.SampleLevel(ShadowMapSampler, coords + (float2(x, y)*texelSize),0).r;
|
||||||
|
shadowFactor += shadowMapDepth < realDepth ? 1.0f : 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shadowFactor / 9.0f;
|
||||||
|
}
|
||||||
|
|
||||||
[earlydepthstencil]
|
[earlydepthstencil]
|
||||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
{
|
{
|
||||||
|
@ -104,8 +121,8 @@ float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
float realDepth = input.LightPosition.z;
|
float realDepth = input.LightPosition.z;
|
||||||
|
|
||||||
// If clip space z value greater than shadow map value then pixel is in shadow
|
// If clip space z value greater than shadow map value then pixel is in shadow
|
||||||
if (shadowMapDepth < realDepth)
|
float shadow = getShadowFactor(ShadowMap, ShadowMapSampler, coords, realDepth);
|
||||||
return float4(output.xyz* colorMul.xyz / 2.0f, 1.0f);
|
lighting = lerp(lighting, AmbientColor * 2, saturate(shadow));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,3 +177,4 @@ float4 PS(PixelShaderInput input) : SV_TARGET
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue