mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-04-29 08:17:59 +03:00
Refactored DX11 renderer; Added special effects and sprites rendering;
This commit is contained in:
parent
726d253513
commit
112112ff1a
15 changed files with 1590 additions and 393 deletions
|
@ -48,6 +48,7 @@ PixelShaderInput VS(VertexShaderInput input)
|
|||
return output;
|
||||
}
|
||||
|
||||
[earlydepthstencil]
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
cbuffer CameraMatrixBuffer
|
||||
struct RendererLight {
|
||||
float4 Position;
|
||||
float4 Color;
|
||||
float4 Direction;
|
||||
float Intensity;
|
||||
float In;
|
||||
float Out;
|
||||
float Range;
|
||||
};
|
||||
|
||||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
cbuffer LightsBuffer : register(b1)
|
||||
{
|
||||
RendererLight Lights[48];
|
||||
int NumLights;
|
||||
float3 Padding;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
|
@ -16,6 +33,7 @@ struct VertexShaderInput
|
|||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 WorldPosition: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
|
@ -32,16 +50,40 @@ PixelShaderInput VS(VertexShaderInput input)
|
|||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
output.WorldPosition = input.Position.xyz;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[earlydepthstencil]
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
float3 colorMul = min(input.Color.xyz, 1.0f) * 2.0f;
|
||||
output.xyz = output.xyz * colorMul.xyz;
|
||||
|
||||
float3 lighting = colorMul.xyz;
|
||||
|
||||
for (int i = 0; i < NumLights; i++)
|
||||
{
|
||||
float3 lightPos = Lights[i].Position.xyz;
|
||||
float3 color = Lights[i].Color.xyz;
|
||||
float radius = Lights[i].Out;
|
||||
float intensity = Lights[i].Intensity;
|
||||
|
||||
float3 lightVec = (lightPos - input.WorldPosition);
|
||||
float distance = length(lightVec);
|
||||
|
||||
if (distance > radius)
|
||||
continue;
|
||||
|
||||
lightVec = normalize(lightVec);
|
||||
float attenuation = (radius - distance) / radius;
|
||||
|
||||
lighting += color * intensity * attenuation;
|
||||
}
|
||||
|
||||
output.xyz = output.xyz * lighting;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
|
|
54
Build/Shaders/DX11_Sky.fx
Normal file
54
Build/Shaders/DX11_Sky.fx
Normal file
|
@ -0,0 +1,54 @@
|
|||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
cbuffer StaticMatrixBuffer : register(b1)
|
||||
{
|
||||
float4x4 World;
|
||||
float4 StaticPosition;
|
||||
float4 Color;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
float Bone : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
};
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState Sampler;
|
||||
|
||||
PixelShaderInput VS(VertexShaderInput input)
|
||||
{
|
||||
PixelShaderInput output;
|
||||
|
||||
output.Position = mul(mul(mul(float4(input.Position, 1.0f), World), View), Projection);
|
||||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
output.xyz = output.xyz * Color;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
}
|
47
Build/Shaders/DX11_Sprites.fx
Normal file
47
Build/Shaders/DX11_Sprites.fx
Normal file
|
@ -0,0 +1,47 @@
|
|||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
float Bone : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
};
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState Sampler;
|
||||
|
||||
PixelShaderInput VS(VertexShaderInput input)
|
||||
{
|
||||
PixelShaderInput output;
|
||||
|
||||
output.Position = mul(mul(float4(input.Position, 1.0f), View), Projection);
|
||||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
output.xyz = output.xyz * input.Color.xyz;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
}
|
|
@ -38,6 +38,7 @@
|
|||
#define MAX_LIGHTS 100
|
||||
#define MAX_STATICS 1000
|
||||
#define MAX_BONES 32
|
||||
#define MAX_SPRITES 16384
|
||||
|
||||
#define NO_ROOM 0xFF
|
||||
#define NO_HEIGHT (-0x7F00)
|
||||
|
|
|
@ -90,6 +90,7 @@ typedef enum RENDERER_FADE_STATUS {
|
|||
#define MAX_INDICES 400000
|
||||
|
||||
#define MAX_LINES_2D 256
|
||||
#define MAX_LINES_3D 16384
|
||||
|
||||
#define NUM_BUCKETS 4
|
||||
|
||||
|
@ -132,4 +133,6 @@ typedef enum RENDERER_FADE_STATUS {
|
|||
#define PRINTSTRING_COLOR_BLACK D3DCOLOR_ARGB(255, 0, 0, 0)
|
||||
|
||||
#define FADE_FRAMES_COUNT 16
|
||||
#define FADE_FACTOR 0.0625f
|
||||
#define FADE_FACTOR 0.0625f
|
||||
|
||||
#define NUM_LIGHTS_PER_BUFFER 48
|
File diff suppressed because it is too large
Load diff
|
@ -422,6 +422,35 @@ struct RendererBone
|
|||
}
|
||||
};
|
||||
|
||||
struct RendererLight {
|
||||
Vector4 Position;
|
||||
Vector4 Color;
|
||||
Vector4 Direction;
|
||||
float Intensity;
|
||||
float In;
|
||||
float Out;
|
||||
float Range;
|
||||
__int32 Type;
|
||||
__int32 Dynamic;
|
||||
__int32 Padding1;
|
||||
__int32 Padding2;
|
||||
|
||||
RendererLight()
|
||||
{
|
||||
Dynamic = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct ShaderLight {
|
||||
Vector4 Position;
|
||||
Vector4 Color;
|
||||
Vector4 Direction;
|
||||
float Intensity;
|
||||
float In;
|
||||
float Out;
|
||||
float Range;
|
||||
};
|
||||
|
||||
struct CCameraMatrixBuffer
|
||||
{
|
||||
Matrix View;
|
||||
|
@ -440,7 +469,13 @@ struct CStaticBuffer
|
|||
{
|
||||
Matrix World;
|
||||
Vector4 Position;
|
||||
Vector4 AmbientLight;
|
||||
Vector4 Color;
|
||||
};
|
||||
|
||||
struct CLightBuffer {
|
||||
ShaderLight Lights[NUM_LIGHTS_PER_BUFFER];
|
||||
__int32 NumLights;
|
||||
Vector3 Padding;
|
||||
};
|
||||
|
||||
struct RendererAnimatedTexture
|
||||
|
@ -467,23 +502,6 @@ struct RendererBucket
|
|||
__int32 NumIndices;
|
||||
};
|
||||
|
||||
struct RendererLight {
|
||||
Vector4 Position;
|
||||
Vector4 Color;
|
||||
Vector4 Direction;
|
||||
float Intensity;
|
||||
float In;
|
||||
float Out;
|
||||
float Range;
|
||||
LIGHT_TYPES Type;
|
||||
bool Dynamic;
|
||||
|
||||
RendererLight()
|
||||
{
|
||||
Dynamic = false;
|
||||
}
|
||||
};
|
||||
|
||||
struct RendererStatic {
|
||||
__int32 Id;
|
||||
__int16 RoomIndex;
|
||||
|
@ -504,6 +522,7 @@ struct RendererRoom
|
|||
bool Visited;
|
||||
float Distance;
|
||||
__int32 RoomNumber;
|
||||
PreallocatedVector<RendererLight> LightsToDraw;
|
||||
};
|
||||
|
||||
struct RendererRoomNode {
|
||||
|
@ -546,6 +565,54 @@ struct RendererObject
|
|||
bool HasDataInAnimatedBucket[NUM_BUCKETS];
|
||||
};
|
||||
|
||||
struct RendererSprite {
|
||||
__int32 Width;
|
||||
__int32 Height;
|
||||
Vector2 UV[4];
|
||||
};
|
||||
|
||||
struct RendererSpriteSequence {
|
||||
__int32 Id;
|
||||
RendererSprite** SpritesList;
|
||||
|
||||
RendererSpriteSequence(__int32 id, __int32 num)
|
||||
{
|
||||
Id = id;
|
||||
SpritesList = (RendererSprite**)malloc(sizeof(RendererSprite*) * num);
|
||||
}
|
||||
};
|
||||
|
||||
struct RendererSpriteToDraw {
|
||||
RENDERER_SPRITE_TYPE Type;
|
||||
RendererSprite* Sprite;
|
||||
float Distance;
|
||||
float Scale;
|
||||
float X, Y, Z;
|
||||
float X1, Y1, Z1;
|
||||
float X2, Y2, Z2;
|
||||
float X3, Y3, Z3;
|
||||
float X4, Y4, Z4;
|
||||
byte R;
|
||||
byte G;
|
||||
byte B;
|
||||
float Rotation;
|
||||
float Width;
|
||||
float Height;
|
||||
BLEND_MODES BlendMode;
|
||||
};
|
||||
|
||||
struct RendererLine3DToDraw {
|
||||
float X1;
|
||||
float Y1;
|
||||
float Z1;
|
||||
float X2;
|
||||
float Y2;
|
||||
float Z2;
|
||||
byte R;
|
||||
byte G;
|
||||
byte B;
|
||||
};
|
||||
|
||||
class Renderer11
|
||||
{
|
||||
private:
|
||||
|
@ -588,6 +655,10 @@ private:
|
|||
ID3D11PixelShader* m_psHairs;
|
||||
ID3D11VertexShader* m_vsStatics;
|
||||
ID3D11PixelShader* m_psStatics;
|
||||
ID3D11VertexShader* m_vsSky;
|
||||
ID3D11PixelShader* m_psSky;
|
||||
ID3D11VertexShader* m_vsSprites;
|
||||
ID3D11PixelShader* m_psSprites;
|
||||
|
||||
// Constant buffers
|
||||
CCameraMatrixBuffer m_stCameraMatrices;
|
||||
|
@ -596,6 +667,8 @@ private:
|
|||
ID3D11Buffer* m_cbItem;
|
||||
CStaticBuffer m_stStatic;
|
||||
ID3D11Buffer* m_cbStatic;
|
||||
CLightBuffer m_stRoomLights;
|
||||
ID3D11Buffer* m_cbRoomLights;
|
||||
|
||||
// Text and sprites
|
||||
SpriteFont* m_gameFont;
|
||||
|
@ -611,6 +684,7 @@ private:
|
|||
|
||||
// Level data
|
||||
Texture2D* m_textureAtlas;
|
||||
Texture2D* m_skyTexture;
|
||||
vector<RendererAnimatedTextureSet*> m_animatedTextureSets;
|
||||
VertexBuffer* m_roomsVertexBuffer;
|
||||
IndexBuffer* m_roomsIndexBuffer;
|
||||
|
@ -633,9 +707,17 @@ private:
|
|||
PreallocatedVector<RendererStatic> m_staticsToDraw;
|
||||
PreallocatedVector<RendererLight> m_lightsToDraw;
|
||||
PreallocatedVector<RendererLight> m_dynamicLights;
|
||||
PreallocatedVector<RendererSpriteToDraw> m_spritesToDraw;
|
||||
PreallocatedVector<RendererLine3DToDraw> m_lines3DToDraw;
|
||||
RendererSpriteToDraw* m_spritesBuffer;
|
||||
__int32 m_nextSprite;
|
||||
RendererLine3DToDraw* m_lines3DBuffer;
|
||||
__int32 m_nextLine3D;
|
||||
RendererLight* m_shadowLight;
|
||||
RendererObject** m_moveableObjects;
|
||||
RendererObject** m_staticObjects;
|
||||
RendererSprite** m_sprites;
|
||||
RendererSpriteSequence** m_spriteSequences;
|
||||
unordered_map<__int16*, RendererMesh*> m_meshPointersToMesh;
|
||||
Matrix m_LaraWorldMatrix;
|
||||
|
||||
|
@ -649,6 +731,7 @@ private:
|
|||
RendererEffect m_effects[NUM_ITEMS];
|
||||
RendererLight m_lights[MAX_LIGHTS];
|
||||
__int32 m_nextLight;
|
||||
__int32 m_currentY;
|
||||
|
||||
// Times for debug
|
||||
__int32 m_timeUpdate;
|
||||
|
@ -658,9 +741,9 @@ private:
|
|||
// Private functions
|
||||
bool drawScene(bool dump);
|
||||
bool drawAllStrings();
|
||||
ID3D11VertexShader* compileVertexShader(char* fileName);
|
||||
ID3D11VertexShader* compileVertexShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode);
|
||||
ID3D11GeometryShader* compileGeometryShader(char* fileName);
|
||||
ID3D11PixelShader* compilePixelShader(char* fileName);
|
||||
ID3D11PixelShader* compilePixelShader(char* fileName, char* function, char* model, ID3D10Blob** bytecode);
|
||||
ID3D11ComputeShader* compileComputeShader(char* fileName);
|
||||
ID3D11Buffer* createConstantBuffer(__int32 size);
|
||||
__int32 getAnimatedTextureInfo(__int16 textureId);
|
||||
|
@ -674,10 +757,10 @@ private:
|
|||
bool checkPortal(__int16 roomIndex, __int16* portal, Vector4* viewPort, Vector4* clipPort);
|
||||
void getVisibleRooms(int from, int to, Vector4* viewPort, bool water, int count);
|
||||
void collectRooms();
|
||||
inline void collectItems(__int16 roomNumber);
|
||||
inline void collectStatics(__int16 roomNumber);
|
||||
inline void collectLights(__int16 roomNumber);
|
||||
inline void collectEffects(__int16 roomNumber);
|
||||
inline void collectItems(__int16 roomNumber);
|
||||
inline void collectStatics(__int16 roomNumber);
|
||||
inline void collectLights(__int16 roomNumber);
|
||||
inline void collectEffects(__int16 roomNumber);
|
||||
void prepareLights();
|
||||
void clearSceneItems();
|
||||
bool updateConstantBuffer(ID3D11Buffer* buffer, void* data, __int32 size);
|
||||
|
@ -686,6 +769,29 @@ private:
|
|||
void updateEffects();
|
||||
__int32 getFrame(__int16 animation, __int16 frame, __int16** framePtr, __int32* rate);
|
||||
bool drawAmbientCubeMap(__int16 roomNumber);
|
||||
bool sphereBoxIntersection(Vector3 boxMin, Vector3 boxMax, Vector3 sphereCentre, float sphereRadius);
|
||||
bool drawHorizonAndSky();
|
||||
bool drawRooms();
|
||||
bool drawStatics();
|
||||
bool drawItems();
|
||||
bool drawLara();
|
||||
void printDebugMessage(char* message, ...);
|
||||
void drawFires();
|
||||
void drawSparks();
|
||||
void drawSmokes();
|
||||
void drawBlood();
|
||||
void drawDrips();
|
||||
void drawBubbles();
|
||||
void drawSplahes();
|
||||
bool drawSprites();
|
||||
bool drawLines3D();
|
||||
void createBillboardMatrix(Matrix* out, Vector3* particlePos, Vector3* cameraPos, float rotation);
|
||||
void drawShockwaves();
|
||||
void drawRipples();
|
||||
void drawUnderwaterDust();
|
||||
void addSpriteBillboard(RendererSprite* sprite, float x, float y, float z, byte r, byte g, byte b, float rotation, float scale, float width, float height, BLEND_MODES blendMode);
|
||||
void addSprite3D(RendererSprite* sprite, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4, byte r, byte g, byte b, float rotation, float scale, float width, float height, BLEND_MODES blendMode);
|
||||
void addLine3D(__int32 x1, __int32 y1, __int32 z1, __int32 x2, __int32 y2, __int32 z2, byte r, byte g, byte b);
|
||||
|
||||
public:
|
||||
Matrix View;
|
||||
|
|
|
@ -215,7 +215,7 @@ bool GameFlow::DoGameflow()
|
|||
SaveGameHeader header;
|
||||
|
||||
// DEBUG: test
|
||||
CurrentLevel = 3;
|
||||
CurrentLevel = 4;
|
||||
SelectedLevelForNewGame = 0;
|
||||
gfInitialiseGame = true;
|
||||
DoLevel(CurrentLevel, 126, false);
|
||||
|
|
|
@ -48,6 +48,7 @@ PixelShaderInput VS(VertexShaderInput input)
|
|||
return output;
|
||||
}
|
||||
|
||||
[earlydepthstencil]
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
cbuffer CameraMatrixBuffer
|
||||
struct RendererLight {
|
||||
float4 Position;
|
||||
float4 Color;
|
||||
float4 Direction;
|
||||
float Intensity;
|
||||
float In;
|
||||
float Out;
|
||||
float Range;
|
||||
};
|
||||
|
||||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
cbuffer LightsBuffer : register(b1)
|
||||
{
|
||||
RendererLight Lights[48];
|
||||
int NumLights;
|
||||
float3 Padding;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
|
@ -16,6 +33,7 @@ struct VertexShaderInput
|
|||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 WorldPosition: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
|
@ -32,16 +50,40 @@ PixelShaderInput VS(VertexShaderInput input)
|
|||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
output.WorldPosition = input.Position.xyz;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
[earlydepthstencil]
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
float3 colorMul = min(input.Color.xyz, 1.0f) * 2.0f;
|
||||
output.xyz = output.xyz * colorMul.xyz;
|
||||
|
||||
float3 lighting = colorMul.xyz;
|
||||
|
||||
for (int i = 0; i < NumLights; i++)
|
||||
{
|
||||
float3 lightPos = Lights[i].Position.xyz;
|
||||
float3 color = Lights[i].Color.xyz;
|
||||
float radius = Lights[i].Out;
|
||||
float intensity = Lights[i].Intensity;
|
||||
|
||||
float3 lightVec = (lightPos - input.WorldPosition);
|
||||
float distance = length(lightVec);
|
||||
|
||||
if (distance > radius)
|
||||
continue;
|
||||
|
||||
lightVec = normalize(lightVec);
|
||||
float attenuation = (radius - distance) / radius;
|
||||
|
||||
lighting += color * intensity * attenuation;
|
||||
}
|
||||
|
||||
output.xyz = output.xyz * lighting;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
|
|
54
TR5Main/Shaders/DX11_Sky.fx
Normal file
54
TR5Main/Shaders/DX11_Sky.fx
Normal file
|
@ -0,0 +1,54 @@
|
|||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
cbuffer StaticMatrixBuffer : register(b1)
|
||||
{
|
||||
float4x4 World;
|
||||
float4 StaticPosition;
|
||||
float4 Color;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
float Bone : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
};
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState Sampler;
|
||||
|
||||
PixelShaderInput VS(VertexShaderInput input)
|
||||
{
|
||||
PixelShaderInput output;
|
||||
|
||||
output.Position = mul(mul(mul(float4(input.Position, 1.0f), World), View), Projection);
|
||||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
output.xyz = output.xyz * Color;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
}
|
47
TR5Main/Shaders/DX11_Sprites.fx
Normal file
47
TR5Main/Shaders/DX11_Sprites.fx
Normal file
|
@ -0,0 +1,47 @@
|
|||
cbuffer CameraMatrixBuffer : register(b0)
|
||||
{
|
||||
float4x4 View;
|
||||
float4x4 Projection;
|
||||
};
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 Position: POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
float Bone : BLENDINDICES;
|
||||
};
|
||||
|
||||
struct PixelShaderInput
|
||||
{
|
||||
float4 Position: SV_POSITION;
|
||||
float3 Normal: NORMAL;
|
||||
float2 UV: TEXCOORD;
|
||||
float4 Color: COLOR;
|
||||
};
|
||||
|
||||
Texture2D Texture;
|
||||
SamplerState Sampler;
|
||||
|
||||
PixelShaderInput VS(VertexShaderInput input)
|
||||
{
|
||||
PixelShaderInput output;
|
||||
|
||||
output.Position = mul(mul(float4(input.Position, 1.0f), View), Projection);
|
||||
output.Normal = input.Normal;
|
||||
output.Color = input.Color;
|
||||
output.UV = input.UV;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
float4 PS(PixelShaderInput input) : SV_TARGET
|
||||
{
|
||||
float4 output = Texture.Sample(Sampler, input.UV);
|
||||
clip(output.w - 0.5f);
|
||||
output.xyz = output.xyz * input.Color.xyz;
|
||||
output.w = 1.0f;
|
||||
|
||||
return output;
|
||||
}
|
|
@ -537,6 +537,20 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
|
|||
<FileType>Text</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Shaders\DX11_Sky.fx">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
<FileType>Text</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Shaders\DX11_Sprites.fx">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
|
||||
<FileType>Text</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
<Import Project="..\packages\directxtk_desktop_2015.2018.11.20.1\build\native\directxtk_desktop_2015.targets" Condition="Exists('..\packages\directxtk_desktop_2015.2018.11.20.1\build\native\directxtk_desktop_2015.targets')" />
|
||||
|
|
|
@ -597,6 +597,8 @@
|
|||
<None Include="Shaders\DX11_Items.fx" />
|
||||
<None Include="Shaders\DX11_Hairs.fx" />
|
||||
<None Include="Shaders\DX11_Statics.fx" />
|
||||
<None Include="Shaders\DX11_Sky.fx" />
|
||||
<None Include="Shaders\DX11_Sprites.fx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Resources.rc">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue