Skip to content

Commit

Permalink
Renamed resource types (#883)
Browse files Browse the repository at this point in the history
* Cleaned up some visual noise by reducing redundancies in resource names

* Changed wireframe to match the other uniform buffers
  • Loading branch information
jaremieromer authored Jan 29, 2025
1 parent a821d34 commit 4f1c447
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 132 deletions.
14 changes: 7 additions & 7 deletions resources/shaders/Normals.psh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "Lighting.fxh"

Texture2D TextureBufferData[];
SamplerState TextureBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D Textures[];
SamplerState Textures_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -30,7 +30,7 @@ struct MaterialData
float padding3;
};

StructuredBuffer<MaterialData> MaterialBufferData : register(t1);
StructuredBuffer<MaterialData> Materials : register(t1);

struct PSInput
{
Expand All @@ -49,9 +49,9 @@ struct PSOutput
void main(in PSInput PSIn, out PSOutput PSOut)
{
float4 Color;
uint normalIndex = MaterialBufferData[PSIn.MaterialIndex].normalIndex;
Color = TextureBufferData[normalIndex].Sample(TextureBufferData_sampler, PSIn.UV);
uint normalIndex = Materials[PSIn.MaterialIndex].normalIndex;
Color = Textures[normalIndex].Sample(Textures_sampler, PSIn.UV);
float3 viewDir = normalize(cameraPosition - PSIn.WorldPos);
float3 adjustedNormals = PSIn.Normal * MaterialBufferData[PSIn.MaterialIndex].normalIntensity;
float3 adjustedNormals = PSIn.Normal * Materials[PSIn.MaterialIndex].normalIntensity;
PSOut.Color = float4(adjustedNormals, 1-dot(PSIn.Normal, -viewDir));
}
10 changes: 5 additions & 5 deletions resources/shaders/PPEnd.psh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# define NonUniformResourceIndex(x) x
#endif

Texture2D PostProcessColorSinkBufferData[];
Texture2D PostProcessDepthSinkBufferData[];
SamplerState PostProcessColorSinkBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D ColorSinks[];
Texture2D DepthSinks[];
SamplerState ColorSinks_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer PostProcessSinkIndexBufferData
cbuffer SinkIndices
{
uint colorRT1;
uint colorRT2;
Expand All @@ -32,5 +32,5 @@ struct PSOutput

void main(in PSInput PSIn, out PSOutput PSOut)
{
PSOut.Color = PostProcessColorSinkBufferData[colorRT1].Sample(PostProcessColorSinkBufferData_sampler, PSIn.UV);;
PSOut.Color = ColorSinks[colorRT1].Sample(ColorSinks_sampler, PSIn.UV);;
}
14 changes: 7 additions & 7 deletions resources/shaders/PPFxaa.psh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Much credit to Timothy Lottes and Simon Rodriguez https://blog.simonrodriguez.fr/articles/2016/07/implementing_fxaa.html

Texture2D PostProcessColorSinkBufferData[];
Texture2D PostProcessDepthSinkBufferData[];
SamplerState PostProcessColorSinkBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D ColorSinks[];
Texture2D DepthSinks[];
SamplerState ColorSinks_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -14,7 +14,7 @@ cbuffer EnvironmentBufferData
float farClip;
};

cbuffer PostProcessSinkIndexBufferData
cbuffer SinkIndices
{
uint colorRT1;
uint colorRT2;
Expand Down Expand Up @@ -49,8 +49,8 @@ static float SubpixelQuality = 0.75f;
void main(in PSInput PSIn, out PSOutput PSOut)
{
// Alias the resource names
SamplerState smplr = PostProcessColorSinkBufferData_sampler;
Texture2D colorTex = PostProcessColorSinkBufferData[colorRT1];
SamplerState smplr = ColorSinks_sampler;
Texture2D colorTex = ColorSinks[colorRT1];
float4 sceneColor = colorTex.Sample(smplr, PSIn.UV);

// Get screen dimensions
Expand Down
20 changes: 10 additions & 10 deletions resources/shaders/PPOutline.psh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Much credit given to: https://roystan.net/articles/outline-shader/

Texture2D PostProcessColorSinkBufferData[];
Texture2D PostProcessDepthSinkBufferData[];
SamplerState PostProcessColorSinkBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D ColorSinks[];
Texture2D DepthSinks[];
SamplerState ColorSinks_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -14,7 +14,7 @@ cbuffer EnvironmentBufferData
float farClip;
};

cbuffer PostProcessSinkIndexBufferData
cbuffer SinkIndices
{
uint colorRT1;
uint colorRT2;
Expand All @@ -26,7 +26,7 @@ cbuffer PostProcessSinkIndexBufferData
uint depthRT4;
};

cbuffer OutlinePassBufferData
cbuffer OutlinePassProperties
{
float3 outlineColor;
float outlineWidth;
Expand Down Expand Up @@ -101,10 +101,10 @@ float OutlineNormals(Texture2D normalsTex, SamplerState smplr, float2 LLUV, floa
void main(in PSInput PSIn, out PSOutput PSOut)
{
// Alias the resource names
SamplerState smplr = PostProcessColorSinkBufferData_sampler;
Texture2D depthTex = PostProcessDepthSinkBufferData[depthRT1];
Texture2D colorTex = PostProcessColorSinkBufferData[colorRT1];
Texture2D normalTex = PostProcessColorSinkBufferData[colorRT2];
SamplerState smplr = ColorSinks_sampler;
Texture2D depthTex = DepthSinks[depthRT1];
Texture2D colorTex = ColorSinks[colorRT1];
Texture2D normalTex = ColorSinks[colorRT2];

// Get screen dimensions
uint screenWidth, screenHeight;
Expand Down
10 changes: 5 additions & 5 deletions resources/shaders/PPWave.psh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# define NonUniformResourceIndex(x) x
#endif

Texture2D PostProcessColorSinkBufferData[];
Texture2D PostProcessDepthSinkBufferData[];
SamplerState PostProcessColorSinkBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D ColorSinks[];
Texture2D DepthSinks[];
SamplerState ColorSinks_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer PostProcessSinkIndexBufferData
cbuffer SinkIndices
{
uint colorRT1;
uint colorRT2;
Expand All @@ -33,7 +33,7 @@ struct PSOutput
void main(in PSInput PSIn, out PSOutput PSOut)
{
float2 DistortedUV = PSIn.UV + float2(sin(PSIn.UV.y * 100) * 0.1 * sin(PSIn.UV.x * 100.0) * 0.05);
float4 Color = PostProcessColorSinkBufferData[colorRT1].Sample(PostProcessColorSinkBufferData_sampler, DistortedUV);
float4 Color = ColorSinks[colorRT1].Sample(ColorSinks_sampler, DistortedUV);

PSOut.Color = Color;
}
6 changes: 3 additions & 3 deletions resources/shaders/Particle.psh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ struct PSOutput
float4 Color : SV_TARGET;
};

Texture2D TextureBufferData[];
SamplerState TextureBufferData_sampler;
Texture2D Textures[];
SamplerState Textures_sampler;

void main(in PSInput PSIn, out PSOutput PSOut)
{
PSOut.Color = TextureBufferData[PSIn.TextureIndex].Sample(TextureBufferData_sampler, PSIn.UV);
PSOut.Color = Textures[PSIn.TextureIndex].Sample(Textures_sampler, PSIn.UV);
}
6 changes: 3 additions & 3 deletions resources/shaders/Particle.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct PSOutput
uint TextureIndex;
};

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -28,11 +28,11 @@ struct ParticleData
uint textureIndex;
};

StructuredBuffer<ParticleData> ParticleBufferData;
StructuredBuffer<ParticleData> Particles;

void main(in VSInput VSIn, uint InstanceID : SV_InstanceID, out PSOutput PSOut)
{
ParticleData particle = ParticleBufferData[InstanceID];
ParticleData particle = Particles[InstanceID];
float4 TransformedPos = mul(float4(VSIn.Pos, 1.0), particle.model);
PSOut.Pos = mul(TransformedPos, cameraViewProjection);
PSOut.UV = VSIn.UV;
Expand Down
16 changes: 8 additions & 8 deletions resources/shaders/Toon.psh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include "Lighting.fxh"

Texture2D TextureBufferData[];
SamplerState TextureBufferData_sampler; // By convention, texture samplers must use the '_sampler' suffix
Texture2D Textures[];
SamplerState Textures_sampler; // By convention, texture samplers must use the '_sampler' suffix

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -30,8 +30,8 @@ struct MaterialData
float padding3;
};

StructuredBuffer<MaterialData> MaterialBufferData : register(t1);
StructuredBuffer<LightData> LightBufferData : register(t2);
StructuredBuffer<MaterialData> Materials : register(t1);
StructuredBuffer<LightData> Lights : register(t2);

struct PSInput
{
Expand Down Expand Up @@ -67,14 +67,14 @@ float LightBand(float lightAmount)
void main(in PSInput PSIn, out PSOutput PSOut)
{
float4 Color;
uint TexIndex = MaterialBufferData[PSIn.MaterialIndex].diffuseTexture;
Color = TextureBufferData[TexIndex].Sample(TextureBufferData_sampler, PSIn.UV);
uint TexIndex = Materials[PSIn.MaterialIndex].diffuseTexture;
Color = Textures[TexIndex].Sample(Textures_sampler, PSIn.UV);
float alpha = Color.a;
float3 finalColor = {0.0f, 0.0f, 0.0f};

for (int i = 0; i < lightCount; i++)
{
LightInfluence influence = LightRadiance(LightBufferData[i], PSIn.WorldPos, cameraPosition, PSIn.Normal);
LightInfluence influence = LightRadiance(Lights[i], PSIn.WorldPos, cameraPosition, PSIn.Normal);
finalColor += influence.color * LightBand(influence.specularAmt + influence.diffuseAmt);
}

Expand Down
14 changes: 7 additions & 7 deletions resources/shaders/Toon.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ struct TransformData
float4x4 model;
};

StructuredBuffer<TransformData> TransformBufferData;
StructuredBuffer<TransformData> Transforms;

struct StaticMeshInstanceData
{
uint transformIndex;
uint materialIndex;
};

StructuredBuffer<StaticMeshInstanceData> StaticInstanceBufferData;
StructuredBuffer<StaticMeshInstanceData> StaticInstances;

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand All @@ -41,12 +41,12 @@ cbuffer EnvironmentBufferData
};
void main(in VSInput VSIn, uint InstanceID : SV_InstanceID, out PSInput PSIn)
{
uint transformIndex = StaticInstanceBufferData[InstanceID].transformIndex;
uint materialIndex = StaticInstanceBufferData[InstanceID].materialIndex;
float4 TransformedPos = mul(float4(VSIn.Pos, 1.0), TransformBufferData[transformIndex].model);
uint transformIndex = StaticInstances[InstanceID].transformIndex;
uint materialIndex = StaticInstances[InstanceID].materialIndex;
float4 TransformedPos = mul(float4(VSIn.Pos, 1.0), Transforms[transformIndex].model);
PSIn.Pos = mul(TransformedPos, cameraViewProjection);
PSIn.UV = VSIn.UV;
PSIn.Normal = normalize(mul(TransformBufferData[transformIndex].model, VSIn.Normal)); // @TODO #805, compute inverse model matrix CPU-side
PSIn.Normal = normalize(mul(Transforms[transformIndex].model, VSIn.Normal)); // @TODO #805, compute inverse model matrix CPU-side
PSIn.WorldPos = TransformedPos.xyz;
PSIn.MaterialIndex = materialIndex;
}
20 changes: 10 additions & 10 deletions resources/shaders/ToonSkinned.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct TransformData
float4x4 modelMatrix;
};

StructuredBuffer<TransformData> TransformBufferData;
StructuredBuffer<TransformData> Transforms;

// todo: #802 Define this at compile time
#define ENABLE_SKINNING 1
Expand All @@ -37,17 +37,17 @@ struct SkinnedMeshInstanceData
uint boneIndex;
};

StructuredBuffer<SkinnedMeshInstanceData> SkinnedInstanceBufferData;
StructuredBuffer<SkinnedMeshInstanceData> SkinnedInstances;

#define INSTANCE_DATA SkinnedMeshInstanceData
#define INSTANCE_BUFFER SkinnedInstanceBufferData
#define INSTANCE_BUFFER SkinnedInstances

struct BoneData
{
float4x4 animatedBoneMatrix;
};

StructuredBuffer<BoneData> BoneBufferData;
StructuredBuffer<BoneData> Bones;

bool IsValidBoneIndex(uint boneIndex)
{
Expand All @@ -70,7 +70,7 @@ float4x4 CombineBoneMatrices(uint base, uint4 boneOffsets, float4 boneWeights)
{
if (boneWeights[i] > 0.0f)
{
boneTransform += BoneBufferData[base + boneOffsets[i]].animatedBoneMatrix * boneWeights[i];
boneTransform += Bones[base + boneOffsets[i]].animatedBoneMatrix * boneWeights[i];
}
}

Expand All @@ -85,14 +85,14 @@ struct StaticMeshInstanceData
uint materialIndex;
};

StructuredBuffer<StaticMeshInstanceData> StaticInstanceBufferData;
StructuredBuffer<StaticMeshInstanceData> StaticInstances;

#define INSTANCE_DATA StaticMeshInstanceData
#define INSTANCE_BUFFER StaticInstanceBufferData
#define INSTANCE_BUFFER StaticInstances

#endif // ENABLE_SKINNING

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
Expand Down Expand Up @@ -121,10 +121,10 @@ void main(in VSInput VSIn, uint InstanceID : SV_InstanceID, out PSInput PSIn)
#endif // ENABLE_SKINNING

uint transformIndex = instance.transformIndex;
float4 worldPos = mul(pos, TransformBufferData[transformIndex].modelMatrix);
float4 worldPos = mul(pos, Transforms[transformIndex].modelMatrix);
PSIn.Pos = mul(worldPos, cameraViewProjection);
PSIn.UV = VSIn.UV;
PSIn.Normal = normalize(mul(TransformBufferData[transformIndex].modelMatrix, normal)); // @TODO #805, compute inverse model matrix CPU-side
PSIn.Normal = normalize(mul(Transforms[transformIndex].modelMatrix, normal)); // @TODO #805, compute inverse model matrix CPU-side
PSIn.WorldPos = worldPos.xyz;
PSIn.MaterialIndex = instance.materialIndex;
}
2 changes: 1 addition & 1 deletion resources/shaders/Wireframe.psh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cbuffer WireframeBufferData
cbuffer WireframeProperties
{
float4x4 wireframeModelMatrix;
float4 wireframeColor;
Expand Down
4 changes: 2 additions & 2 deletions resources/shaders/Wireframe.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ struct PSInput
float4 Pos : SV_POSITION;
};

cbuffer EnvironmentBufferData
cbuffer EnvironmentProperties
{
float4x4 cameraViewProjection;
float4x4 cameraInvProjection;
float3 cameraPosition;
uint lightCount;
};

cbuffer WireframeBufferData
cbuffer WireframeProperties
{
float4x4 wireframeModelMatrix;
float4 wireframeColor;
Expand Down
Loading

0 comments on commit 4f1c447

Please sign in to comment.