Skip to content

Commit 087be28

Browse files
committed
WIP: repeating now works
- Scene looks better
1 parent 88dab26 commit 087be28

10 files changed

Lines changed: 39 additions & 32 deletions

File tree

Core/Source/Lux/Renderer/Image.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ namespace Lux {
436436
{
437437
const auto desc = nvrhi::SamplerDesc()
438438
.setMipBias(m_Specification.MipBias)
439+
.setMaxAnisotropy(m_Specification.MaxAnisotropy)
439440
.setAllAddressModes(m_Specification.AddressMode)
440441
.setMinFilter(m_Specification.MinFilter)
441442
.setMagFilter(m_Specification.MagFilter)

Core/Source/Lux/Renderer/Image.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ namespace Lux {
388388
{
389389
float MipBias = 0.0f;
390390
nvrhi::SamplerAddressMode AddressMode = nvrhi::SamplerAddressMode::Clamp;
391+
float MaxAnisotropy = 1.0f;
391392
bool MinFilter = true;
392393
bool MagFilter = true;
393394
bool MipFilter = true;

Core/Source/Lux/Renderer/Renderer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ namespace Lux {
252252
// Default samplers
253253
Ref<Sampler> SamplerClamp = nullptr;
254254
Ref<Sampler> SamplerPoint = nullptr;
255+
Ref<Sampler> SamplerRepeat = nullptr;
255256

256257
int32_t DrawCallCount = 0;
257258
int32_t DrawInstanceCount = 0;
@@ -1676,6 +1677,19 @@ namespace Lux {
16761677
return s_RendererData->SamplerPoint;
16771678
}
16781679

1680+
Ref<Sampler> Renderer::GetRepeatSampler()
1681+
{
1682+
if (!s_RendererData->SamplerRepeat)
1683+
{
1684+
SamplerSpecification spec;
1685+
spec.AddressMode = nvrhi::SamplerAddressMode::Repeat;
1686+
spec.MaxAnisotropy = 16.0f;
1687+
s_RendererData->SamplerRepeat = Sampler::Create(spec);
1688+
}
1689+
1690+
return s_RendererData->SamplerRepeat;
1691+
}
1692+
16791693
int Renderer::GetDrawcallCount()
16801694
{
16811695
return s_Data->DrawCallCount;

Core/Source/Lux/Renderer/Renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ namespace Lux {
206206

207207
static Ref<Sampler> GetClampSampler();
208208
static Ref<Sampler> GetPointSampler();
209+
static Ref<Sampler> GetRepeatSampler();
209210
static Ref<Sampler> GetDefaultSampler() { return GetClampSampler(); }
210211

211212
static int GetDrawcallCount();

Core/Source/Lux/Renderer/SceneRenderer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ namespace Lux {
517517
m_GeometryPass->SetInput("u_EnvRadianceTex", Renderer::GetBlackCubeTexture());
518518
m_GeometryPass->SetInput("u_EnvIrradianceTex", Renderer::GetBlackCubeTexture());
519519
m_GeometryPass->SetInput("u_BRDFLUTTexture", Renderer::GetBRDFLutTexture());
520+
m_GeometryPass->SetInput("r_MaterialSampler", Renderer::GetRepeatSampler());
520521
// Shadow map output from the shadow pass above
521522
m_GeometryPass->SetInput("u_ShadowMapTexture", m_ShadowMapPass->GetDepthOutput());
522523
m_GeometryPass->SetInput("u_SpotShadowTexture", m_SpotShadowMapImage);
@@ -543,6 +544,7 @@ namespace Lux {
543544
m_GeometryPassTransparent->SetInput("u_EnvRadianceTex", Renderer::GetBlackCubeTexture());
544545
m_GeometryPassTransparent->SetInput("u_EnvIrradianceTex", Renderer::GetBlackCubeTexture());
545546
m_GeometryPassTransparent->SetInput("u_BRDFLUTTexture", Renderer::GetBRDFLutTexture());
547+
m_GeometryPassTransparent->SetInput("r_MaterialSampler", Renderer::GetRepeatSampler());
546548
// Shadow map output from the shadow pass above
547549
m_GeometryPassTransparent->SetInput("u_ShadowMapTexture", m_ShadowMapPass->GetDepthOutput());
548550
m_GeometryPassTransparent->SetInput("u_SpotShadowTexture", m_SpotShadowMapImage);

Editor/Resources/Shaders/Include/GLSL/Samplers.glslh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
layout (set = 3, binding = 0) uniform sampler r_DefaultSampler;
44
layout (set = 3, binding = 1) uniform sampler r_PointSampler;
55
layout (set = 3, binding = 2) uniform sampler r_LinearSampler;
6+
layout (set = 3, binding = 3) uniform sampler r_MaterialSampler;
67

78
vec4 SampleDefault(texture2D tex, vec2 texCoord)
89
{
@@ -14,6 +15,11 @@ vec4 SampleLinear(texture2D tex, vec2 texCoord)
1415
return texture(sampler2D(tex, r_LinearSampler), texCoord);
1516
}
1617

18+
vec4 SampleMaterial(texture2D tex, vec2 texCoord)
19+
{
20+
return texture(sampler2D(tex, r_MaterialSampler), texCoord);
21+
}
22+
1723
vec4 SampleLinear(texture2DArray tex, vec3 texCoord)
1824
{
1925
return texture(sampler2DArray(tex, r_LinearSampler), texCoord);

Editor/Resources/Shaders/LuxPBR_Static.glsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,19 @@ vec3 GetGradient(float value)
169169

170170
void main()
171171
{
172-
vec4 albedoTexColor = SampleLinear(u_AlbedoTexture, Input.TexCoord);
172+
vec4 albedoTexColor = SampleMaterial(u_AlbedoTexture, Input.TexCoord);
173173
m_Params.Albedo = albedoTexColor.rgb * ToLinear(vec4(u_MaterialUniforms.AlbedoColor, 1.0)).rgb;
174174
float alpha = albedoTexColor.a;
175175

176-
m_Params.Metalness = SampleLinear(u_MetalnessTexture, Input.TexCoord).b * u_MaterialUniforms.Metalness;
177-
m_Params.Roughness = SampleLinear(u_RoughnessTexture, Input.TexCoord).g * u_MaterialUniforms.Roughness;
176+
m_Params.Metalness = SampleMaterial(u_MetalnessTexture, Input.TexCoord).b * u_MaterialUniforms.Metalness;
177+
m_Params.Roughness = SampleMaterial(u_RoughnessTexture, Input.TexCoord).g * u_MaterialUniforms.Roughness;
178178
o_MetalnessRoughness = vec4(m_Params.Metalness, m_Params.Roughness, 0.f, 1.f);
179179
m_Params.Roughness = max(m_Params.Roughness, 0.05);
180180

181181
m_Params.Normal = normalize(Input.Normal);
182182
if (u_MaterialUniforms.UseNormalMap)
183183
{
184-
m_Params.Normal = normalize(SampleLinear(u_NormalTexture, Input.TexCoord).rgb * 2.0f - 1.0f);
184+
m_Params.Normal = normalize(SampleMaterial(u_NormalTexture, Input.TexCoord).rgb * 2.0f - 1.0f);
185185
m_Params.Normal = normalize(Input.WorldNormals * m_Params.Normal);
186186
}
187187

Editor/Resources/Shaders/LuxPBR_Transparent.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ vec3 GetGradient(float value)
167167

168168
void main()
169169
{
170-
vec4 albedoTexColor = SampleLinear(u_AlbedoTexture, Input.TexCoord);
170+
vec4 albedoTexColor = SampleMaterial(u_AlbedoTexture, Input.TexCoord);
171171
m_Params.Albedo = albedoTexColor.rgb * ToLinear(vec4(u_MaterialUniforms.AlbedoColor, 1.0)).rgb;
172172

173173
m_Params.Metalness = 0.0f;
@@ -177,7 +177,7 @@ void main()
177177
m_Params.Normal = normalize(Input.Normal);
178178
if (u_MaterialUniforms.UseNormalMap)
179179
{
180-
m_Params.Normal = normalize(SampleLinear(u_NormalTexture, Input.TexCoord).rgb * 2.0f - 1.0f);
180+
m_Params.Normal = normalize(SampleMaterial(u_NormalTexture, Input.TexCoord).rgb * 2.0f - 1.0f);
181181
m_Params.Normal = normalize(Input.WorldNormals * m_Params.Normal);
182182
}
183183

Editor/SandboxProject/Assets/Scenes/NewSceneSystem.luxscene

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,11 @@ Entities:
66
Parent: 0
77
Children:
88
- Handle: 12726918091783066847
9-
- Handle: 8322387861642138170
109
- Handle: 8091695794772928150
1110
TransformComponent:
1211
Position: [0, 0, 0]
1312
Rotation: [0, 0, 0]
1413
Scale: [1, 1, 1]
15-
- Entity: 8322387861642138170
16-
TagComponent:
17-
Tag: Directional Light
18-
Parent: 7022982668959240531
19-
Children:
20-
[]
21-
TransformComponent:
22-
Position: [-0.397086352, 3.4798944, 0.385443866]
23-
Rotation: [1.93881643, 0.971345544, 0.202807263]
24-
Scale: [0.999996483, 0.999957502, 0.999996901]
25-
DirectionalLightComponent:
26-
Intensity: 1
27-
Radiance: [1, 1, 1]
28-
CastShadows: false
29-
SoftShadows: true
30-
LightSize: 1.67999995
31-
ShadowAmount: 1
3214
- Entity: 12726918091783066847
3315
TagComponent:
3416
Tag: Sky Light
@@ -41,7 +23,7 @@ Entities:
4123
Scale: [1, 1, 1]
4224
SkyLightComponent:
4325
EnvironmentMap: 10933720561759477118
44-
Intensity: 1
26+
Intensity: 0.5
4527
Lod: 0
4628
DynamicSky: false
4729
- Entity: 16805889847351497941
@@ -87,8 +69,8 @@ Entities:
8769
Children:
8870
[]
8971
TransformComponent:
90-
Position: [-7.49999952, 1, -0.0974102318]
91-
Rotation: [0, -1.57045102, 0]
72+
Position: [-9.69999981, 0.400000006, 0.902999997]
73+
Rotation: [0.164060935, -1.30515718, 0]
9274
Scale: [0.999999881, 1, 0.999999881]
9375
CameraComponent:
9476
Camera:

Editor/imgui.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ DockId=0x00000002,0
2828

2929
[Window][Scene Hierarchy]
3030
Pos=3339,57
31-
Size=501,1556
31+
Size=501,850
3232
Collapsed=0
3333
DockId=0x00000005,0
3434

3535
[Window][Properties]
36-
Pos=3339,1615
37-
Size=501,473
36+
Pos=3339,909
37+
Size=501,1179
3838
Collapsed=0
3939
DockId=0x00000006,0
4040

@@ -176,6 +176,6 @@ DockSpace ID=0x370560FF Window=0xC4B82F3D Pos=0,57 Size=3840,2031 Spli
176176
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=3852,1526 CentralNode=1 Selected=0xC450F867
177177
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=3852,503 Selected=0x3DF3100E
178178
DockNode ID=0x00000004 Parent=0x00000008 SizeRef=501,2084 Split=Y Selected=0xB8729153
179-
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=363,1399 Selected=0xB8729153
180-
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=363,425 Selected=0x8C72BEA8
179+
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=363,850 Selected=0xB8729153
180+
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=363,1179 Selected=0x8C72BEA8
181181

0 commit comments

Comments
 (0)