diff --git a/samples/Sponza/sponza.json b/samples/Sponza/sponza.json index 04c90a0c..01a8cf39 100644 --- a/samples/Sponza/sponza.json +++ b/samples/Sponza/sponza.json @@ -12,7 +12,7 @@ ], "Material": [ { - "albedo map": 101, + "albedo map": 102, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -64,7 +64,7 @@ ] }, { - "albedo map": 13, + "albedo map": 14, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -78,11 +78,11 @@ "height map": 18446744073709551615, "id": 2, "metallic factor": 1.0, - "metallic map": 11, + "metallic map": 12, "name": "DefaultMaterial", - "normal map": 23, + "normal map": 24, "roughness factor": 1.0, - "roughness map": 16, + "roughness map": 17, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -90,7 +90,7 @@ ] }, { - "albedo map": 20, + "albedo map": 21, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -106,7 +106,7 @@ "metallic factor": 1.0, "metallic map": 18446744073709551615, "name": "Lion Head", - "normal map": 26, + "normal map": 27, "roughness factor": 0.0, "roughness map": 18446744073709551615, "transparency": 1.0, @@ -116,7 +116,7 @@ ] }, { - "albedo map": 22, + "albedo map": 23, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -130,11 +130,11 @@ "height map": 18446744073709551615, "id": 4, "metallic factor": 1.0, - "metallic map": 17, + "metallic map": 18, "name": "DefaultMaterial", - "normal map": 30, + "normal map": 31, "roughness factor": 1.0, - "roughness map": 12, + "roughness map": 13, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -142,7 +142,7 @@ ] }, { - "albedo map": 25, + "albedo map": 26, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -156,11 +156,11 @@ "height map": 18446744073709551615, "id": 5, "metallic factor": 1.0, - "metallic map": 14, + "metallic map": 15, "name": "DefaultMaterial", - "normal map": 33, + "normal map": 34, "roughness factor": 1.0, - "roughness map": 15, + "roughness map": 16, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -168,7 +168,7 @@ ] }, { - "albedo map": 29, + "albedo map": 30, "alpha mode": "MASKED", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -182,11 +182,11 @@ "height map": 18446744073709551615, "id": 6, "metallic factor": 1.0, - "metallic map": 18, + "metallic map": 19, "name": "DefaultMaterial", - "normal map": 28, + "normal map": 29, "roughness factor": 1.0, - "roughness map": 19, + "roughness map": 20, "transparency": 0.5, "uv multipliers": [ 1.0, @@ -194,7 +194,7 @@ ] }, { - "albedo map": 31, + "albedo map": 32, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -208,11 +208,11 @@ "height map": 18446744073709551615, "id": 7, "metallic factor": 1.0, - "metallic map": 27, + "metallic map": 28, "name": "DefaultMaterial", - "normal map": 24, + "normal map": 25, "roughness factor": 1.0, - "roughness map": 21, + "roughness map": 22, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -220,7 +220,7 @@ ] }, { - "albedo map": 40, + "albedo map": 41, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -234,11 +234,11 @@ "height map": 18446744073709551615, "id": 8, "metallic factor": 1.0, - "metallic map": 35, + "metallic map": 36, "name": "DefaultMaterial", - "normal map": 34, + "normal map": 35, "roughness factor": 1.0, - "roughness map": 37, + "roughness map": 38, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -246,7 +246,7 @@ ] }, { - "albedo map": 43, + "albedo map": 44, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -260,11 +260,11 @@ "height map": 18446744073709551615, "id": 9, "metallic factor": 1.0, - "metallic map": 39, + "metallic map": 40, "name": "DefaultMaterial", - "normal map": 38, + "normal map": 39, "roughness factor": 1.0, - "roughness map": 32, + "roughness map": 33, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -272,7 +272,7 @@ ] }, { - "albedo map": 44, + "albedo map": 45, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -286,11 +286,11 @@ "height map": 18446744073709551615, "id": 10, "metallic factor": 1.0, - "metallic map": 42, + "metallic map": 43, "name": "DefaultMaterial", - "normal map": 41, + "normal map": 42, "roughness factor": 1.0, - "roughness map": 36, + "roughness map": 37, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -298,7 +298,7 @@ ] }, { - "albedo map": 45, + "albedo map": 46, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -312,11 +312,11 @@ "height map": 18446744073709551615, "id": 11, "metallic factor": 1.0, - "metallic map": 47, + "metallic map": 48, "name": "DefaultMaterial", - "normal map": 46, + "normal map": 47, "roughness factor": 1.0, - "roughness map": 48, + "roughness map": 49, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -324,7 +324,7 @@ ] }, { - "albedo map": 49, + "albedo map": 50, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -338,11 +338,11 @@ "height map": 18446744073709551615, "id": 12, "metallic factor": 1.0, - "metallic map": 51, + "metallic map": 52, "name": "DefaultMaterial", - "normal map": 50, + "normal map": 51, "roughness factor": 1.0, - "roughness map": 52, + "roughness map": 53, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -350,7 +350,7 @@ ] }, { - "albedo map": 53, + "albedo map": 54, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -364,11 +364,11 @@ "height map": 18446744073709551615, "id": 13, "metallic factor": 1.0, - "metallic map": 55, + "metallic map": 56, "name": "DefaultMaterial", - "normal map": 54, + "normal map": 55, "roughness factor": 1.0, - "roughness map": 56, + "roughness map": 57, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -376,7 +376,7 @@ ] }, { - "albedo map": 60, + "albedo map": 61, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -402,7 +402,7 @@ ] }, { - "albedo map": 57, + "albedo map": 58, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -416,11 +416,11 @@ "height map": 18446744073709551615, "id": 15, "metallic factor": 1.0, - "metallic map": 69, + "metallic map": 70, "name": "DefaultMaterial", - "normal map": 58, + "normal map": 59, "roughness factor": 1.0, - "roughness map": 59, + "roughness map": 60, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -428,7 +428,7 @@ ] }, { - "albedo map": 62, + "albedo map": 63, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -442,11 +442,11 @@ "height map": 18446744073709551615, "id": 16, "metallic factor": 1.0, - "metallic map": 74, + "metallic map": 75, "name": "DefaultMaterial", - "normal map": 63, + "normal map": 64, "roughness factor": 1.0, - "roughness map": 64, + "roughness map": 65, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -454,7 +454,7 @@ ] }, { - "albedo map": 66, + "albedo map": 67, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -468,11 +468,11 @@ "height map": 18446744073709551615, "id": 17, "metallic factor": 1.0, - "metallic map": 78, + "metallic map": 79, "name": "DefaultMaterial", - "normal map": 67, + "normal map": 68, "roughness factor": 1.0, - "roughness map": 61, + "roughness map": 62, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -480,7 +480,7 @@ ] }, { - "albedo map": 73, + "albedo map": 74, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -496,9 +496,9 @@ "metallic factor": 0.25, "metallic map": 18446744073709551615, "name": "Floor", - "normal map": 81, + "normal map": 82, "roughness factor": 1.0, - "roughness map": 65, + "roughness map": 66, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -506,7 +506,7 @@ ] }, { - "albedo map": 77, + "albedo map": 78, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -520,11 +520,11 @@ "height map": 18446744073709551615, "id": 19, "metallic factor": 1.0, - "metallic map": 70, + "metallic map": 71, "name": "DefaultMaterial", - "normal map": 79, + "normal map": 80, "roughness factor": 1.0, - "roughness map": 71, + "roughness map": 72, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -532,7 +532,7 @@ ] }, { - "albedo map": 82, + "albedo map": 83, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -546,11 +546,11 @@ "height map": 18446744073709551615, "id": 20, "metallic factor": 1.0, - "metallic map": 75, + "metallic map": 76, "name": "DefaultMaterial", - "normal map": 76, + "normal map": 77, "roughness factor": 1.0, - "roughness map": 68, + "roughness map": 69, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -558,7 +558,7 @@ ] }, { - "albedo map": 94, + "albedo map": 95, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -572,11 +572,11 @@ "height map": 18446744073709551615, "id": 21, "metallic factor": 1.0, - "metallic map": 72, + "metallic map": 73, "name": "DefaultMaterial", - "normal map": 86, + "normal map": 87, "roughness factor": 1.0, - "roughness map": 80, + "roughness map": 81, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -584,7 +584,7 @@ ] }, { - "albedo map": 89, + "albedo map": 90, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -598,11 +598,11 @@ "height map": 18446744073709551615, "id": 22, "metallic factor": 1.0, - "metallic map": 84, + "metallic map": 85, "name": "DefaultMaterial", - "normal map": 10, + "normal map": 11, "roughness factor": 1.0, - "roughness map": 85, + "roughness map": 86, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -610,7 +610,7 @@ ] }, { - "albedo map": 93, + "albedo map": 94, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -626,7 +626,7 @@ "metallic factor": 1.0, "metallic map": 18446744073709551615, "name": "Lion Head", - "normal map": 9, + "normal map": 10, "roughness factor": 0.0, "roughness map": 18446744073709551615, "transparency": 1.0, @@ -636,7 +636,7 @@ ] }, { - "albedo map": 97, + "albedo map": 98, "alpha mode": "OPAQUE", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -650,11 +650,11 @@ "height map": 18446744073709551615, "id": 24, "metallic factor": 1.0, - "metallic map": 90, + "metallic map": 91, "name": "DefaultMaterial", - "normal map": 99, + "normal map": 100, "roughness factor": 1.0, - "roughness map": 83, + "roughness map": 84, "transparency": 1.0, "uv multipliers": [ 1.0, @@ -662,7 +662,7 @@ ] }, { - "albedo map": 98, + "albedo map": 99, "alpha mode": "MASKED", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -676,11 +676,11 @@ "height map": 18446744073709551615, "id": 25, "metallic factor": 1.0, - "metallic map": 92, + "metallic map": 93, "name": "DefaultMaterial", - "normal map": 91, + "normal map": 92, "roughness factor": 1.0, - "roughness map": 100, + "roughness map": 101, "transparency": 0.5, "uv multipliers": [ 1.0, @@ -688,7 +688,7 @@ ] }, { - "albedo map": 95, + "albedo map": 96, "alpha mode": "MASKED", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -702,11 +702,11 @@ "height map": 18446744073709551615, "id": 26, "metallic factor": 1.0, - "metallic map": 88, + "metallic map": 89, "name": "DefaultMaterial", - "normal map": 87, + "normal map": 88, "roughness factor": 1.0, - "roughness map": 96, + "roughness map": 97, "transparency": 0.5, "uv multipliers": [ 1.0, @@ -714,7 +714,7 @@ ] }, { - "albedo map": 102, + "albedo map": 103, "alpha mode": "TRANSPARENT", "ambient occlusion map": 18446744073709551615, "base color": [ @@ -904,7 +904,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/13982482287905699490.jpg" }, - "id": 9, + "id": 10, "wrap type": "REPEAT" }, { @@ -918,7 +918,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/16299174074766089871.jpg" }, - "id": 10, + "id": 11, "wrap type": "REPEAT" }, { @@ -932,7 +932,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_24.png" }, - "id": 11, + "id": 12, "wrap type": "REPEAT" }, { @@ -946,7 +946,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_22.png" }, - "id": 12, + "id": 13, "wrap type": "REPEAT" }, { @@ -960,7 +960,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/2969916736137545357.jpg" }, - "id": 13, + "id": 14, "wrap type": "REPEAT" }, { @@ -974,7 +974,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_21.png" }, - "id": 14, + "id": 15, "wrap type": "REPEAT" }, { @@ -988,7 +988,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_21.png" }, - "id": 15, + "id": 16, "wrap type": "REPEAT" }, { @@ -1002,7 +1002,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_24.png" }, - "id": 16, + "id": 17, "wrap type": "REPEAT" }, { @@ -1016,7 +1016,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_22.png" }, - "id": 17, + "id": 18, "wrap type": "REPEAT" }, { @@ -1030,7 +1030,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_20.png" }, - "id": 18, + "id": 19, "wrap type": "REPEAT" }, { @@ -1044,7 +1044,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_20.png" }, - "id": 19, + "id": 20, "wrap type": "REPEAT" }, { @@ -1058,7 +1058,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/6772804448157695701.jpg" }, - "id": 20, + "id": 21, "wrap type": "REPEAT" }, { @@ -1072,7 +1072,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_19.png" }, - "id": 21, + "id": 22, "wrap type": "REPEAT" }, { @@ -1086,7 +1086,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/8481240838833932244.jpg" }, - "id": 22, + "id": 23, "wrap type": "REPEAT" }, { @@ -1100,7 +1100,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/14118779221266351425.jpg" }, - "id": 23, + "id": 24, "wrap type": "REPEAT" }, { @@ -1114,7 +1114,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/4910669866631290573.jpg" }, - "id": 24, + "id": 25, "wrap type": "REPEAT" }, { @@ -1128,7 +1128,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/755318871556304029.jpg" }, - "id": 25, + "id": 26, "wrap type": "REPEAT" }, { @@ -1142,7 +1142,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/759203620573749278.jpg" }, - "id": 26, + "id": 27, "wrap type": "REPEAT" }, { @@ -1156,7 +1156,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_19.png" }, - "id": 27, + "id": 28, "wrap type": "REPEAT" }, { @@ -1170,7 +1170,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/14170708867020035030.jpg" }, - "id": 28, + "id": 29, "wrap type": "REPEAT" }, { @@ -1184,7 +1184,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/16275776544635328252.png" }, - "id": 29, + "id": 30, "wrap type": "REPEAT" }, { @@ -1198,7 +1198,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/10381718147657362067.jpg" }, - "id": 30, + "id": 31, "wrap type": "REPEAT" }, { @@ -1212,7 +1212,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/9288698199695299068.jpg" }, - "id": 31, + "id": 32, "wrap type": "REPEAT" }, { @@ -1226,7 +1226,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_17.png" }, - "id": 32, + "id": 33, "wrap type": "REPEAT" }, { @@ -1240,7 +1240,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/3827035219084910048.jpg" }, - "id": 33, + "id": 34, "wrap type": "REPEAT" }, { @@ -1254,7 +1254,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/4601176305987539675.jpg" }, - "id": 34, + "id": 35, "wrap type": "REPEAT" }, { @@ -1268,7 +1268,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_18.png" }, - "id": 35, + "id": 36, "wrap type": "REPEAT" }, { @@ -1282,7 +1282,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_16.png" }, - "id": 36, + "id": 37, "wrap type": "REPEAT" }, { @@ -1296,7 +1296,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_18.png" }, - "id": 37, + "id": 38, "wrap type": "REPEAT" }, { @@ -1310,7 +1310,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/6593109234861095314.jpg" }, - "id": 38, + "id": 39, "wrap type": "REPEAT" }, { @@ -1324,7 +1324,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_17.png" }, - "id": 39, + "id": 40, "wrap type": "REPEAT" }, { @@ -1338,7 +1338,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/11474523244911310074.jpg" }, - "id": 40, + "id": 41, "wrap type": "REPEAT" }, { @@ -1352,7 +1352,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/332936164838540657.jpg" }, - "id": 41, + "id": 42, "wrap type": "REPEAT" }, { @@ -1366,7 +1366,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_16.png" }, - "id": 42, + "id": 43, "wrap type": "REPEAT" }, { @@ -1380,7 +1380,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/17876391417123941155.jpg" }, - "id": 43, + "id": 44, "wrap type": "REPEAT" }, { @@ -1394,7 +1394,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/2185409758123873465.jpg" }, - "id": 44, + "id": 45, "wrap type": "REPEAT" }, { @@ -1408,7 +1408,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/2775690330959970771.jpg" }, - "id": 45, + "id": 46, "wrap type": "REPEAT" }, { @@ -1422,7 +1422,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/2374361008830720677.jpg" }, - "id": 46, + "id": 47, "wrap type": "REPEAT" }, { @@ -1436,7 +1436,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_15.png" }, - "id": 47, + "id": 48, "wrap type": "REPEAT" }, { @@ -1450,7 +1450,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_15.png" }, - "id": 48, + "id": 49, "wrap type": "REPEAT" }, { @@ -1464,7 +1464,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/4675343432951571524.jpg" }, - "id": 49, + "id": 50, "wrap type": "REPEAT" }, { @@ -1478,7 +1478,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/7056944414013900257.jpg" }, - "id": 50, + "id": 51, "wrap type": "REPEAT" }, { @@ -1492,7 +1492,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_14.png" }, - "id": 51, + "id": 52, "wrap type": "REPEAT" }, { @@ -1506,7 +1506,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_14.png" }, - "id": 52, + "id": 53, "wrap type": "REPEAT" }, { @@ -1520,7 +1520,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/4975155472559461469.jpg" }, - "id": 53, + "id": 54, "wrap type": "REPEAT" }, { @@ -1534,7 +1534,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/2299742237651021498.jpg" }, - "id": 54, + "id": 55, "wrap type": "REPEAT" }, { @@ -1548,7 +1548,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_13.png" }, - "id": 55, + "id": 56, "wrap type": "REPEAT" }, { @@ -1562,7 +1562,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_13.png" }, - "id": 56, + "id": 57, "wrap type": "REPEAT" }, { @@ -1576,7 +1576,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/6151467286084645207.jpg" }, - "id": 57, + "id": 58, "wrap type": "REPEAT" }, { @@ -1590,7 +1590,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/7645212358685992005.jpg" }, - "id": 58, + "id": 59, "wrap type": "REPEAT" }, { @@ -1604,7 +1604,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_11.png" }, - "id": 59, + "id": 60, "wrap type": "REPEAT" }, { @@ -1618,7 +1618,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/white.png" }, - "id": 60, + "id": 61, "wrap type": "REPEAT" }, { @@ -1632,7 +1632,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_9.png" }, - "id": 61, + "id": 62, "wrap type": "REPEAT" }, { @@ -1646,7 +1646,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/11490520546946913238.jpg" }, - "id": 62, + "id": 63, "wrap type": "REPEAT" }, { @@ -1660,7 +1660,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/3628158980083700836.jpg" }, - "id": 63, + "id": 64, "wrap type": "REPEAT" }, { @@ -1674,7 +1674,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_10.png" }, - "id": 64, + "id": 65, "wrap type": "REPEAT" }, { @@ -1688,7 +1688,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_8.png" }, - "id": 65, + "id": 66, "wrap type": "REPEAT" }, { @@ -1702,7 +1702,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/7441062115984513793.jpg" }, - "id": 66, + "id": 67, "wrap type": "REPEAT" }, { @@ -1716,7 +1716,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/6667038893015345571.jpg" }, - "id": 67, + "id": 68, "wrap type": "REPEAT" }, { @@ -1730,7 +1730,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_6.png" }, - "id": 68, + "id": 69, "wrap type": "REPEAT" }, { @@ -1744,7 +1744,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_11.png" }, - "id": 69, + "id": 70, "wrap type": "REPEAT" }, { @@ -1758,7 +1758,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_7.png" }, - "id": 70, + "id": 71, "wrap type": "REPEAT" }, { @@ -1772,7 +1772,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_7.png" }, - "id": 71, + "id": 72, "wrap type": "REPEAT" }, { @@ -1786,7 +1786,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_5.png" }, - "id": 72, + "id": 73, "wrap type": "REPEAT" }, { @@ -1800,7 +1800,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/5823059166183034438.jpg" }, - "id": 73, + "id": 74, "wrap type": "REPEAT" }, { @@ -1814,7 +1814,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_10.png" }, - "id": 74, + "id": 75, "wrap type": "REPEAT" }, { @@ -1828,7 +1828,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_6.png" }, - "id": 75, + "id": 76, "wrap type": "REPEAT" }, { @@ -1842,7 +1842,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/10388182081421875623.jpg" }, - "id": 76, + "id": 77, "wrap type": "REPEAT" }, { @@ -1856,7 +1856,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/6047387724914829168.jpg" }, - "id": 77, + "id": 78, "wrap type": "REPEAT" }, { @@ -1870,7 +1870,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_9.png" }, - "id": 78, + "id": 79, "wrap type": "REPEAT" }, { @@ -1884,7 +1884,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/15722799267630235092.jpg" }, - "id": 79, + "id": 80, "wrap type": "REPEAT" }, { @@ -1898,7 +1898,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_5.png" }, - "id": 80, + "id": 81, "wrap type": "REPEAT" }, { @@ -1912,7 +1912,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/14267839433702832875.jpg" }, - "id": 81, + "id": 82, "wrap type": "REPEAT" }, { @@ -1926,7 +1926,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/15295713303328085182.jpg" }, - "id": 82, + "id": 83, "wrap type": "REPEAT" }, { @@ -1940,7 +1940,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_2.png" }, - "id": 83, + "id": 84, "wrap type": "REPEAT" }, { @@ -1954,7 +1954,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_4.png" }, - "id": 84, + "id": 85, "wrap type": "REPEAT" }, { @@ -1968,7 +1968,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_4.png" }, - "id": 85, + "id": 86, "wrap type": "REPEAT" }, { @@ -1982,7 +1982,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/2051777328469649772.jpg" }, - "id": 86, + "id": 87, "wrap type": "REPEAT" }, { @@ -1996,7 +1996,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/8773302468495022225.jpg" }, - "id": 87, + "id": 88, "wrap type": "REPEAT" }, { @@ -2010,7 +2010,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_0.png" }, - "id": 88, + "id": 89, "wrap type": "REPEAT" }, { @@ -2024,7 +2024,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/5792855332885324923.jpg" }, - "id": 89, + "id": 90, "wrap type": "REPEAT" }, { @@ -2038,7 +2038,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_2.png" }, - "id": 90, + "id": 91, "wrap type": "REPEAT" }, { @@ -2052,7 +2052,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/12501374198249454378.jpg" }, - "id": 91, + "id": 92, "wrap type": "REPEAT" }, { @@ -2066,7 +2066,7 @@ "format": "R", "path": "Resources/Sponza/glTF/metallic_1.png" }, - "id": 92, + "id": 93, "wrap type": "REPEAT" }, { @@ -2080,7 +2080,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/8750083169368950601.jpg" }, - "id": 93, + "id": 94, "wrap type": "REPEAT" }, { @@ -2094,7 +2094,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/14650633544276105767.jpg" }, - "id": 94, + "id": 95, "wrap type": "REPEAT" }, { @@ -2108,7 +2108,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/5061699253647017043.png" }, - "id": 95, + "id": 96, "wrap type": "REPEAT" }, { @@ -2122,7 +2122,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_0.png" }, - "id": 96, + "id": 97, "wrap type": "REPEAT" }, { @@ -2136,7 +2136,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/7268504077753552595.jpg" }, - "id": 97, + "id": 98, "wrap type": "REPEAT" }, { @@ -2150,7 +2150,7 @@ "format": "RGBA", "path": "Resources/Sponza/glTF/8006627369776289000.png" }, - "id": 98, + "id": 99, "wrap type": "REPEAT" }, { @@ -2164,7 +2164,7 @@ "format": "RG", "path": "Resources/Sponza/glTF/4477655471536070370.jpg" }, - "id": 99, + "id": 100, "wrap type": "REPEAT" }, { @@ -2178,7 +2178,7 @@ "format": "R", "path": "Resources/Sponza/glTF/roughness_1.png" }, - "id": 100, + "id": 101, "wrap type": "REPEAT" }, { @@ -2192,7 +2192,7 @@ "format": "RGB", "path": "Resources/moon.jpg" }, - "id": 101, + "id": 102, "wrap type": "REPEAT" }, { @@ -2206,7 +2206,7 @@ "format": "RGBA", "path": "Resources/fire.png" }, - "id": 102, + "id": 103, "wrap type": "REPEAT" } ], @@ -2220,7 +2220,7 @@ "paused": false, "physics-step": 1.0, "time-scale": 1.0, - "total-time": 3214.124267578125, + "total-time": 3242.16943359375, "viewport": 0 }, "mxobjects": [ @@ -2228,14 +2228,14 @@ "CameraController": { "camera type": "PERSPECTIVE", "direction": [ - 0.9956035614013672, - -0.0917634665966034, - 0.01878945901989937 + 0.9829415082931519, + -0.06535527855157852, + 0.17191438376903534 ], "forward vector": [ - 0.9998219609260559, + 0.9850475192070007, 0.0, - 0.01886907033622265 + 0.17228271067142487 ], "id": 0, "is listening window resize event": true, @@ -2243,12 +2243,13 @@ "perspective camera": { "aspect ratio": 1.7777777910232544, "fov": 65.0, + "zfar": 100000.0, "znear": 0.10000000149011612 }, "right vector": [ - -0.01886911503970623, + -0.17228275537490845, 0.0, - 0.9998219609260559 + 0.9850475192070007 ], "up vector": [ 0.0, @@ -2262,6 +2263,9 @@ "chromatic aberration distortion": 0.800000011920929, "chromatic aberration intensity": 0.07999999821186066, "chromatic aberration min distance": 0.800000011920929, + "dof bokeh radius": 10.0, + "dof focus distance": 0.0, + "dof focus range": 5.0, "fog color": [ 0.5, 0.6000000238418579, @@ -2273,6 +2277,14 @@ "id": 0, "vignette radius": 0.10000000149011612 }, + "CameraLensFlare": { + "id": 0, + "lens falre halo width": 0.5, + "lens flare bias": -42.0, + "lens flare ghost dispersal": 0.12999999523162842, + "lens flare num of ghosts": 12, + "lens flare scale": 1.0 + }, "CameraSSAO": { "blur iterations": 1, "blur lod": 2, @@ -2360,13 +2372,14 @@ "down key binding": "LEFT_SHIFT", "forward key binding": "W", "id": 0, - "move speed": 10.0, - "rotate speed": 10.0, "is horizontal rotation bound": true, "is vertical rotation bound": true, "left key binding": "A", + "move speed": 10.0, "right key binding": "D", - "up key binding": "SPACE" + "rotate speed": 10.0, + "up key binding": "SPACE", + "use camera style movement": true }, "RigidBody": { "angular air resistance": 0.0, @@ -2403,9 +2416,9 @@ 1.0 ], "linear velocity": [ - 4.5776359911542386e-05, + 4.897639769296802e-07, 5.7220458984375e-06, - 1.2390954395868903e-07 + -1.4539867265739304e-07 ], "mass": 1.0, "push velocity": [ @@ -2424,6 +2437,9 @@ }, "Script": { "_name": "ShootSpheres", + "database": { + "_database": null + }, "id": 0 }, "Skybox": { @@ -2441,9 +2457,9 @@ "name": "Camera", "transform": { "position": [ - -26.250003814697266, + -19.770307540893555, 2.999999523162842, - 0.007744258269667625 + -0.5053378939628601 ], "rotation": [ 0.0, @@ -2465,6 +2481,7 @@ 0.8377978205680847, 0.75 ], + "depth scale": 20.0, "direction": [ 0.0, 1.0, @@ -2473,7 +2490,6 @@ "id": 0, "intensity": 100.0, "is following viewport": true, - "depth scale": 20.0, "projections": [ 4.0, 15.0, @@ -2484,9 +2500,9 @@ "name": "Global Light", "transform": { "position": [ - -26.250003814697266, + -19.770307540893555, 2.999999523162842, - 0.007744258269667625 + -0.5053378939628601 ], "rotation": [ 0.0, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4559191..1b1f9ec8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ set(MXENGINE_SOURCES "Core/Components/Camera/CameraController.cpp" "Core/Components/Camera/CameraEffects.cpp" "Core/Components/Camera/CameraGodRay.cpp" +"Core/Components/Camera/CameraLensFlare.cpp" "Core/Components/Camera/FrustrumCamera.cpp" "Core/Components/Camera/InputController.cpp" "Core/Components/Camera/OrthographicCamera.cpp" diff --git a/src/Core/Components/Camera/CameraController.cpp b/src/Core/Components/Camera/CameraController.cpp index ab0229f9..0f94e7b2 100644 --- a/src/Core/Components/Camera/CameraController.cpp +++ b/src/Core/Components/Camera/CameraController.cpp @@ -445,6 +445,21 @@ namespace MxEngine return this->renderBuffers->SwapHDR2; } + TextureHandle CameraController::GetSwapQuater1() const + { + return this->renderBuffers->SwapQuater1; + } + + TextureHandle CameraController::GetSwapQuater2() const + { + return this->renderBuffers->SwapQuater2; + } + + TextureHandle CameraController::GetSwapQuater3() const + { + return this->renderBuffers->SwapQuater3; + } + TextureHandle CameraController::GetSwapHDRTexture1() const { return this->renderBuffers->SwapHDR1; @@ -461,6 +476,9 @@ namespace MxEngine this->HDR = Factory::Create(); this->SwapHDR1 = Factory::Create(); this->SwapHDR2 = Factory::Create(); + this->SwapQuater1 = Factory::Create(); + this->SwapQuater2 = Factory::Create(); + this->SwapQuater3 = Factory::Create(); this->Resize(width, height); @@ -512,6 +530,18 @@ namespace MxEngine this->SwapHDR2->Load(nullptr, width, height, 3, false, TextureFormat::RGBA16F); this->SwapHDR2->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera swap hdr 2")); this->SwapHDR2->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + + this->SwapQuater1->Load(nullptr, width / 4, height / 4, 3, false, TextureFormat::RGBA16F); + this->SwapQuater1->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera swap quater 1")); + this->SwapQuater1->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + + this->SwapQuater2->Load(nullptr, width / 4, height / 4, 3, false, TextureFormat::RGBA16F); + this->SwapQuater2->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera swap quater 2")); + this->SwapQuater2->SetWrapType(TextureWrap::CLAMP_TO_EDGE); + + this->SwapQuater3->Load(nullptr, width / 4, height / 4, 3, false, TextureFormat::RGBA16F); + this->SwapQuater3->SetInternalEngineTag(MXENGINE_MAKE_INTERNAL_TAG("camera swap quater 3")); + this->SwapQuater3->SetWrapType(TextureWrap::CLAMP_TO_EDGE); } void CameraRender::DeInit() @@ -524,6 +554,9 @@ namespace MxEngine Factory::Destroy(this->HDR); Factory::Destroy(this->SwapHDR1); Factory::Destroy(this->SwapHDR2); + Factory::Destroy(this->SwapQuater1); + Factory::Destroy(this->SwapQuater2); + Factory::Destroy(this->SwapQuater3); } MXENGINE_REFLECT_TYPE diff --git a/src/Core/Components/Camera/CameraController.h b/src/Core/Components/Camera/CameraController.h index 73b885e3..044e0690 100644 --- a/src/Core/Components/Camera/CameraController.h +++ b/src/Core/Components/Camera/CameraController.h @@ -53,6 +53,9 @@ namespace MxEngine TextureHandle HDR; TextureHandle SwapHDR1; TextureHandle SwapHDR2; + TextureHandle SwapQuater1; + TextureHandle SwapQuater2; + TextureHandle SwapQuater3; void Init(int width, int height); void Resize(int width, int height); @@ -135,5 +138,8 @@ namespace MxEngine TextureHandle GetHDRTexture() const; TextureHandle GetSwapHDRTexture1() const; TextureHandle GetSwapHDRTexture2() const; + TextureHandle GetSwapQuater1() const; + TextureHandle GetSwapQuater2() const; + TextureHandle GetSwapQuater3() const; }; } \ No newline at end of file diff --git a/src/Core/Components/Camera/CameraEffects.cpp b/src/Core/Components/Camera/CameraEffects.cpp index 7e446643..a5b03545 100644 --- a/src/Core/Components/Camera/CameraEffects.cpp +++ b/src/Core/Components/Camera/CameraEffects.cpp @@ -185,13 +185,13 @@ namespace MxEngine .property("fog density", &CameraEffects::GetFogDensity, &CameraEffects::SetFogDensity) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range{ 0.0f, 10000.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 10000.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) .property("fog distance", &CameraEffects::GetFogDistance, &CameraEffects::SetFogDistance) ( rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), - rttr::metadata(EditorInfo::EDIT_RANGE, Range{ 0.0f, 1.0f }), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 1.0f }), rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) ) .property("bloom weight", &CameraEffects::GetBloomWeight, &CameraEffects::SetBloomWeight) diff --git a/src/Core/Components/Camera/CameraEffects.h b/src/Core/Components/Camera/CameraEffects.h index 361a9acc..cdfa8b7e 100644 --- a/src/Core/Components/Camera/CameraEffects.h +++ b/src/Core/Components/Camera/CameraEffects.h @@ -56,6 +56,7 @@ namespace MxEngine float bokehRadius = 10.f; float focusRange = 5.f; float focusDistance = 0.f; + public: CameraEffects() = default; diff --git a/src/Core/Components/Camera/CameraGodRay.h b/src/Core/Components/Camera/CameraGodRay.h index 5c48859d..a5d218ee 100644 --- a/src/Core/Components/Camera/CameraGodRay.h +++ b/src/Core/Components/Camera/CameraGodRay.h @@ -22,4 +22,4 @@ namespace MxEngine void SetGodRaySampleStep(float value); void SetGodRayAsymmetry(float value); }; -} \ No newline at end of file +} diff --git a/src/Core/Components/Camera/CameraLensFlare.cpp b/src/Core/Components/Camera/CameraLensFlare.cpp new file mode 100644 index 00000000..32f290e3 --- /dev/null +++ b/src/Core/Components/Camera/CameraLensFlare.cpp @@ -0,0 +1,79 @@ +#include "CameraLensFlare.h" +#include "Utilities/Math/Math.h" +#include "Core/Runtime/Reflection.h" + +namespace MxEngine +{ + float CameraLensFlare::GetIntensity() const + { + return this->intensity; + } + + int CameraLensFlare::GetGhostNumber() const + { + return this->ghostNumber; + } + + float CameraLensFlare::GetGhostDispersal()const + { + return this->ghostDispersal; + } + + float CameraLensFlare::GetHaloWidth()const + { + return this->haloWidth; + } + + void CameraLensFlare::SetIntensity(float scale) + { + this->intensity = Max(scale, 0.0); + } + + void CameraLensFlare::SetGhostNumber(int num) + { + this->ghostNumber = Max(num,0); + } + + void CameraLensFlare::SetGhostDispersal(float dispersal) + { + this->ghostDispersal = dispersal; + } + + void CameraLensFlare::SetHaloWidth(float width) + { + this->haloWidth = width; + } + + MXENGINE_REFLECT_TYPE + { + rttr::registration::class_("CameraLensFlare") + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::CLONE_COPY | MetaInfo::CLONE_INSTANCE) + ) + .constructor<>() + .property("intensity", &CameraLensFlare::GetIntensity, &CameraLensFlare::SetIntensity) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 1.0f }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) + ) + .property("ghost number", &CameraLensFlare::GetGhostNumber, &CameraLensFlare::SetGhostNumber) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 100.0f }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) + ) + .property("ghost dispersal", &CameraLensFlare::GetGhostDispersal, &CameraLensFlare::SetGhostDispersal) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.001f, 1.0f }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) + ) + .property("halo width", &CameraLensFlare::GetHaloWidth, &CameraLensFlare::SetHaloWidth) + ( + rttr::metadata(MetaInfo::FLAGS, MetaInfo::SERIALIZABLE | MetaInfo::EDITABLE), + rttr::metadata(EditorInfo::EDIT_RANGE, Range { 0.0f, 100.0f }), + rttr::metadata(EditorInfo::EDIT_PRECISION, 0.01f) + ); + } +} \ No newline at end of file diff --git a/src/Core/Components/Camera/CameraLensFlare.h b/src/Core/Components/Camera/CameraLensFlare.h new file mode 100644 index 00000000..7a34e320 --- /dev/null +++ b/src/Core/Components/Camera/CameraLensFlare.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Utilities/ECS/Component.h" + + +namespace MxEngine +{ + class CameraLensFlare + { + MAKE_COMPONENT(CameraLensFlare); + private: + float intensity = 0.1; + int ghostNumber = 12; + float ghostDispersal = 0.13f; + float haloWidth = 0.5f; + + public: + CameraLensFlare() = default; + + float GetIntensity() const; + int GetGhostNumber() const; + float GetGhostDispersal() const; + float GetHaloWidth() const; + + void SetIntensity(float); + void SetGhostNumber(int); + void SetGhostDispersal(float); + void SetHaloWidth(float); + }; +} \ No newline at end of file diff --git a/src/Core/Components/Components.cpp b/src/Core/Components/Components.cpp index 2b1ef9d6..a5f632ee 100644 --- a/src/Core/Components/Components.cpp +++ b/src/Core/Components/Components.cpp @@ -86,6 +86,7 @@ namespace MxEngine TEMPLATE_INSTANCIATE_COMPONENT(CameraSSGI ); TEMPLATE_INSTANCIATE_COMPONENT(CameraSSAO ); TEMPLATE_INSTANCIATE_COMPONENT(CameraGodRay ); + TEMPLATE_INSTANCIATE_COMPONENT(CameraLensFlare ); TEMPLATE_INSTANCIATE_COMPONENT(CameraToneMapping ); TEMPLATE_INSTANCIATE_COMPONENT(VRCameraController ); TEMPLATE_INSTANCIATE_COMPONENT(AudioSource ); @@ -124,6 +125,7 @@ namespace MxEngine RegisterComponent(); RegisterComponent(); RegisterComponent(); + RegisterComponent(); RegisterComponent(); RegisterComponent(); RegisterComponent(); diff --git a/src/Core/Components/Components.h b/src/Core/Components/Components.h index f052c005..f73cace6 100644 --- a/src/Core/Components/Components.h +++ b/src/Core/Components/Components.h @@ -45,6 +45,7 @@ #include "Camera/CameraSSGI.h" #include "Camera/CameraSSAO.h" #include "Camera/CameraGodRay.h" +#include "Camera/CameraLensFlare.h" #include "Camera/InputController.h" #include "Camera/VRCameraController.h" #include "Audio/AudioListener.h" diff --git a/src/Core/Rendering/RenderAdaptor.cpp b/src/Core/Rendering/RenderAdaptor.cpp index 78ef8b50..88cbdc99 100644 --- a/src/Core/Rendering/RenderAdaptor.cpp +++ b/src/Core/Rendering/RenderAdaptor.cpp @@ -43,6 +43,7 @@ #include "Core/Components/Camera/CameraSSGI.h" #include "Core/Components/Camera/CameraSSAO.h" #include "Core/Components/Camera/CameraGodRay.h" +#include "Core/Components/Camera/CameraLensFlare.h" #include "Core/Components/Camera/CameraToneMapping.h" #include "Core/Components/Lighting/DirectionalLight.h" #include "Core/Components/Lighting/PointLight.h" @@ -335,6 +336,21 @@ namespace MxEngine shaderFolder / "dof_combine.glsl" ); + environment.Shaders["LensFlare"_id] = AssetManager::LoadShader( + shaderFolder / "rect_vertex.glsl", + shaderFolder / "lens_flare.glsl" + ); + + environment.Shaders["LensFlareGhosts"_id] = AssetManager::LoadShader( + shaderFolder / "rect_vertex.glsl", + shaderFolder / "lens_flare_ghosts.glsl" + ); + + environment.Shaders["LensFlareHalo"_id] = AssetManager::LoadShader( + shaderFolder / "rect_vertex.glsl", + shaderFolder / "lens_flare_halo.glsl" + ); + // compute shaders environment.ComputeShaders["Particle"_id] = AssetManager::LoadComputeShader( shaderFolder / "particle_compute.glsl" @@ -387,7 +403,7 @@ namespace MxEngine for (const auto& camera : cameraView) { auto& object = MxObject::GetByComponent(camera); - auto& transform = object.LocalTransform; + auto transform = &object.LocalTransform; auto skyboxComponent = object.GetComponent(); auto effectsComponent = object.GetComponent(); @@ -396,6 +412,7 @@ namespace MxEngine auto ssgiComponent = object.GetComponent(); auto ssaoComponent = object.GetComponent(); auto godRayComponent = object.GetComponent(); + auto lensFlareComponent= object.GetComponent(); Skybox* skybox = skyboxComponent.IsValid() ? skyboxComponent.GetUnchecked() : nullptr; CameraEffects* effects = effectsComponent.IsValid() ? effectsComponent.GetUnchecked() : nullptr; CameraToneMapping* toneMapping = toneMappingComponent.IsValid() ? toneMappingComponent.GetUnchecked() : nullptr; @@ -403,8 +420,10 @@ namespace MxEngine CameraSSGI* ssgi = ssgiComponent.IsValid() ? ssgiComponent.GetUnchecked() : nullptr; CameraSSAO* ssao = ssaoComponent.IsValid() ? ssaoComponent.GetUnchecked() : nullptr; CameraGodRay* godRay = godRayComponent.IsValid() ? godRayComponent.GetUnchecked() : nullptr; + CameraLensFlare* lensFlare = lensFlareComponent.IsValid() ? lensFlareComponent.GetUnchecked() : nullptr; - this->Renderer.SubmitCamera(camera, transform, skybox, effects, toneMapping, ssr, ssgi, ssao, godRay); + CameraInfo camInfo{ &camera, transform, skybox, effects, toneMapping, ssr, ssgi, ssao, godRay, lensFlare }; + this->Renderer.SubmitCamera(std::move(camInfo)); TrackMainCameraIndex(camera); } } @@ -442,7 +461,7 @@ namespace MxEngine } size_t renderGroupIndex = this->Renderer.SubmitRenderGroup(*mesh, instanceOffset, instanceCount); - for (const auto& submesh : mesh->GetSubMeshes()) + for (const auto& submesh : mesh->GetSubMeshes()) { auto materialId = submesh.GetMaterialId(); if (materialId >= meshRenderer->Materials.size()) continue; diff --git a/src/Core/Rendering/RenderController.cpp b/src/Core/Rendering/RenderController.cpp index 79a0fb3f..fc5b7ae3 100644 --- a/src/Core/Rendering/RenderController.cpp +++ b/src/Core/Rendering/RenderController.cpp @@ -37,6 +37,7 @@ #include "Core/Components/Camera/CameraSSGI.h" #include "Core/Components/Camera/CameraSSAO.h" #include "Core/Components/Camera/CameraGodRay.h" +#include "Core/Components/Camera/CameraLensFlare.h" #include "Core/Components/Lighting/DirectionalLight.h" #include "Core/Components/Lighting/SpotLight.h" #include "Core/Components/Lighting/PointLight.h" @@ -52,7 +53,6 @@ namespace MxEngine constexpr size_t MaxDirLightCount = 4; constexpr size_t ParticleComputeGroupSize = 64; - constexpr int DefaultLinearBlurSampleCount = 5; void RenderController::PrepareShadowMaps() { @@ -358,15 +358,10 @@ namespace MxEngine // generate depth texture mipmaps for post-processing algorithms. Replace later with hierarhical depth map depth->GenerateMipmaps(); } - - TextureHandle RenderController::ComputeAverageWhite(CameraUnit& camera) + + TextureHandle RenderController::ComputeAverageWhite(CameraUnit& camera, float fadingAdaptationSpeed, float adaptationThreshold) { MAKE_RENDER_PASS_SCOPE("RenderController::ComputeAverageWhite()"); - MX_ASSERT(camera.ToneMapping != nullptr); - - float dt = this->Pipeline.Environment.TimeDelta; - float fadingAdaptationSpeed = 1.0f - std::exp(-camera.ToneMapping->GetEyeAdaptationSpeed() * dt); - float adaptationThreshold = camera.ToneMapping->GetEyeAdaptationThreshold(); auto& shader = this->Pipeline.Environment.Shaders["AverageWhite"_id]; auto& output = this->Pipeline.Environment.AverageWhiteTexture; @@ -412,13 +407,28 @@ namespace MxEngine this->ComputeBloomEffect(camera, camera.HDRTexture); this->ApplySSGI(camera, camera.HDRTexture, camera.SwapTexture1, camera.SwapTexture2); + + this->ApplyLensFlare(camera, camera.HDRTexture, camera.SwapQuaterTexture1, camera.SwapQuaterTexture2, camera.SwapQuaterTexture3, camera.SwapTexture1); this->ApplyGodRayEffect(camera, camera.HDRTexture, camera.SwapTexture1); this->ApplyChromaticAbberation(camera, camera.HDRTexture, camera.SwapTexture1); this->ApplyFogEffect(camera, camera.HDRTexture, camera.SwapTexture1); this->ApplyDepthOfFieldEffect(camera, camera.HDRTexture, camera.SwapTexture1, camera.SwapTexture2); - this->ApplyHDRToLDRConversion(camera, camera.HDRTexture, camera.SwapTexture1); + + TextureHandle averageWhite; + if (camera.ToneMapping == nullptr) + { + averageWhite = this->ComputeAverageWhite(camera, 0.0f, 0.0f); + } + else + { + float dt = this->Pipeline.Environment.TimeDelta; + float fadingAdaptationSpeed = 1.0f - std::exp(-camera.ToneMapping->GetEyeAdaptationSpeed() * dt); + float adaptationThreshold = camera.ToneMapping->GetEyeAdaptationThreshold(); + averageWhite = this->ComputeAverageWhite(camera, fadingAdaptationSpeed, adaptationThreshold); + } + this->ApplyHDRToLDRConversion(camera, camera.HDRTexture, camera.SwapTexture1, averageWhite); this->ApplyFXAA(camera, camera.HDRTexture, camera.SwapTexture1); this->ApplyColorGrading(camera, camera.HDRTexture, camera.SwapTexture1); @@ -767,15 +777,74 @@ namespace MxEngine this->RenderToTexture(temporary0, combineShader); std::swap(inputOutput, temporary0); } - void RenderController::ApplyHDRToLDRConversion(CameraUnit& camera, TextureHandle& input, TextureHandle& output) + + void RenderController::ApplyLensFlare(CameraUnit& camera, TextureHandle& input, TextureHandle& temporaryQuater0, TextureHandle& temporaryQuater1, TextureHandle& temporaryQuater2, TextureHandle& temporary1) + { + if (camera.LensFlare == nullptr) + return; + + MAKE_SCOPE_PROFILER("RenderController::ApplyLensFlare()"); + + //TODO(fall2019): support chromatic aberration + //TODO(fall2019): add starbust effect + int ghostNumber = camera.LensFlare->GetGhostNumber(); + float dispersal = camera.LensFlare->GetGhostDispersal(); + float haloWidth = camera.LensFlare->GetHaloWidth(); + float intensity = camera.LensFlare->GetIntensity(); + int mipLevel = 1 + floor(log2(Max(temporaryQuater1->GetWidth(), temporaryQuater1->GetHeight()))); + + input->GenerateMipmaps(); + + //calc ghosts + { + temporaryQuater0->GenerateMipmaps(); + auto& shaderGhost = this->Pipeline.Environment.Shaders["LensFlareGhosts"_id]; + shaderGhost->Bind(); + shaderGhost->SetUniform("uIntensity", intensity); + input->Bind(0); + camera.AverageWhiteTexture->Bind(1); + this->RenderToTextureNoClear(temporaryQuater0, shaderGhost); + this->ApplyGaussianBlur(temporaryQuater0, temporaryQuater1, 3); + temporaryQuater1->GenerateMipmaps(); + } + + //calc halo + { + auto& shaderHalo = this->Pipeline.Environment.Shaders["LensFlareHalo"_id]; + shaderHalo->Bind(); + shaderHalo->SetUniform("uGhostDispersal", dispersal); + shaderHalo->SetUniform("uHaloWidth", haloWidth); + shaderHalo->SetUniform("uMipLevel", mipLevel); + input->Bind(0); + temporaryQuater1->Bind(1); + camera.AverageWhiteTexture->Bind(2); + this->RenderToTextureNoClear(temporaryQuater0, shaderHalo); + this->ApplyGaussianBlur(temporaryQuater0, temporaryQuater2, 1); + } + + //combine + { + auto& lensFlare = this->Pipeline.Environment.Shaders["LensFlare"_id]; + lensFlare->Bind(); + lensFlare->SetUniform("uGhosts", ghostNumber); + lensFlare->SetUniform("uGhostDispersal", dispersal); + temporaryQuater1->Bind(0); + temporaryQuater2->Bind(1); + input->Bind(2); + this->RenderToTextureNoClear(temporary1, lensFlare); + } + + std::swap(input, temporary1); + } + + void RenderController::ApplyHDRToLDRConversion(CameraUnit& camera, TextureHandle& input, TextureHandle& output, TextureHandle& averageWhite) { if (camera.ToneMapping == nullptr) return; MAKE_RENDER_PASS_SCOPE("RenderController::ApplyHDRToLDRConversion()"); - auto& HDRToLDRShader = this->Pipeline.Environment.Shaders["HDRToLDR"_id]; - auto averageWhite = this->ComputeAverageWhite(camera); auto aces = camera.ToneMapping->GetACESCoefficients(); + auto& HDRToLDRShader = this->Pipeline.Environment.Shaders["HDRToLDR"_id]; HDRToLDRShader->Bind(); input->Bind(0); averageWhite->Bind(1); @@ -1442,52 +1511,47 @@ namespace MxEngine baseLightData->Direction = light.GetMaxDistance() * Normalize(light.Direction); } - void RenderController::SubmitCamera( - const CameraController& controller, - const Transform& parentTransform, - const Skybox* skybox, - const CameraEffects* effects, - const CameraToneMapping* toneMapping, - const CameraSSR* ssr, - const CameraSSGI* ssgi, - const CameraSSAO* ssao, - const CameraGodRay* godRay) + void RenderController::SubmitCamera(const CameraInfo& info) { auto& camera = this->Pipeline.Cameras.emplace_back(); - bool isPerspective = controller.GetCameraType() == CameraType::PERSPECTIVE; - bool hasSkybox = skybox != nullptr; - bool hasToneMapping = toneMapping != nullptr; + bool isPerspective = info.controller->GetCameraType() == CameraType::PERSPECTIVE; + bool hasSkybox = info.skybox != nullptr; + bool hasToneMapping = info.toneMapping != nullptr; - camera.ViewportPosition = parentTransform.GetPosition(); - camera.AspectRatio = controller.Camera.GetAspectRatio(); - camera.StaticViewProjectionMatrix = controller.GetMatrix(MakeVector3(0.0f)); - camera.ViewProjectionMatrix = controller.GetMatrix(parentTransform.GetPosition()); + camera.ViewportPosition = info.parentTransform->GetPosition(); + camera.AspectRatio = info.controller->Camera.GetAspectRatio(); + camera.StaticViewProjectionMatrix = info.controller->GetMatrix(MakeVector3(0.0f)); + camera.ViewProjectionMatrix = info.controller->GetMatrix(info.parentTransform->GetPosition()); camera.InverseViewProjMatrix = Inverse(camera.ViewProjectionMatrix); - camera.Culler = controller.GetFrustrumCuller(); - camera.IsPerspective = controller.GetCameraType() == CameraType::PERSPECTIVE; - camera.GBuffer = controller.GetGBuffer(); - camera.AlbedoTexture = controller.GetAlbedoTexture(); - camera.NormalTexture = controller.GetNormalTexture(); - camera.MaterialTexture = controller.GetMaterialTexture(); - camera.DepthTexture = controller.GetDepthTexture(); - camera.AverageWhiteTexture = controller.GetAverageWhiteTexture(); - camera.HDRTexture = controller.GetHDRTexture(); - camera.SwapTexture1 = controller.GetSwapHDRTexture1(); - camera.SwapTexture2 = controller.GetSwapHDRTexture2(); - camera.OutputTexture = controller.GetRenderTexture(); - camera.RenderToTexture = controller.IsRendering(); - camera.SkyboxTexture = hasSkybox && skybox->CubeMap.IsValid() ? skybox->CubeMap : this->Pipeline.Environment.DefaultSkybox; - camera.IrradianceTexture = hasSkybox && skybox->Irradiance.IsValid() ? skybox->Irradiance : camera.SkyboxTexture; - camera.SkyboxIntensity = hasSkybox ? skybox->GetIntensity() : Skybox::DefaultIntensity; - camera.InversedSkyboxRotation = hasSkybox ? Transpose(MakeRotationMatrix(RadiansVec(skybox->GetRotation()))) : Matrix3x3(1.0f); - camera.Gamma = hasToneMapping ? toneMapping->GetGamma() : CameraToneMapping::DefaultGamma; - camera.Effects = effects; - camera.ToneMapping = toneMapping; - camera.SSR = ssr; - camera.SSGI = ssgi; - camera.SSAO = ssao; - camera.GodRay = godRay; + camera.Culler = info.controller->GetFrustrumCuller(); + camera.IsPerspective = info.controller->GetCameraType() == CameraType::PERSPECTIVE; + camera.GBuffer = info.controller->GetGBuffer(); + camera.AlbedoTexture = info.controller->GetAlbedoTexture(); + camera.NormalTexture = info.controller->GetNormalTexture(); + camera.MaterialTexture = info.controller->GetMaterialTexture(); + camera.DepthTexture = info.controller->GetDepthTexture(); + camera.AverageWhiteTexture = info.controller->GetAverageWhiteTexture(); + camera.HDRTexture = info.controller->GetHDRTexture(); + camera.SwapTexture1 = info.controller->GetSwapHDRTexture1(); + camera.SwapTexture2 = info.controller->GetSwapHDRTexture2(); + camera.OutputTexture = info.controller->GetRenderTexture(); + camera.SwapQuaterTexture1 = info.controller->GetSwapQuater1(); + camera.SwapQuaterTexture2 = info.controller->GetSwapQuater2(); + camera.SwapQuaterTexture3 = info.controller->GetSwapQuater3(); + camera.RenderToTexture = info.controller->IsRendering(); + camera.SkyboxTexture = hasSkybox && info.skybox->CubeMap.IsValid() ? info.skybox->CubeMap : this->Pipeline.Environment.DefaultSkybox; + camera.IrradianceTexture = hasSkybox && info.skybox->Irradiance.IsValid() ? info.skybox->Irradiance : camera.SkyboxTexture; + camera.SkyboxIntensity = hasSkybox ? info.skybox->GetIntensity() : Skybox::DefaultIntensity; + camera.InversedSkyboxRotation = hasSkybox ? Transpose(MakeRotationMatrix(RadiansVec(info.skybox->GetRotation()))) : Matrix3x3(1.0f); + camera.Gamma = hasToneMapping ? info.toneMapping->GetGamma() : CameraToneMapping::DefaultGamma; + camera.Effects = info.effects; + camera.ToneMapping = info.toneMapping; + camera.SSR = info.ssr; + camera.SSGI = info.ssgi; + camera.SSAO = info.ssao; + camera.GodRay = info.godRay; + camera.LensFlare = info.lensFlare; } size_t RenderController::SubmitRenderGroup(const Mesh& mesh, size_t instanceOffset, size_t instanceCount) diff --git a/src/Core/Rendering/RenderController.h b/src/Core/Rendering/RenderController.h index 2aa40502..d0640c5f 100644 --- a/src/Core/Rendering/RenderController.h +++ b/src/Core/Rendering/RenderController.h @@ -47,6 +47,20 @@ namespace MxEngine class ParticleSystem; class Transform; + struct CameraInfo + { + const CameraController* controller; + const Transform* parentTransform; + const Skybox* skybox; + const CameraEffects* effects; + const CameraToneMapping* toneMapping; + const CameraSSR* ssr; + const CameraSSGI* ssgi; + const CameraSSAO* ssao; + const CameraGodRay* godRay; + const CameraLensFlare* lensFlare; + }; + class RenderController { Renderer renderer; @@ -61,7 +75,7 @@ namespace MxEngine void DrawDebugBuffer(const CameraUnit& camera); void DrawObject(const RenderUnit& unit, size_t instanceCount, size_t baseInstance, const Shader& shader); void ComputeBloomEffect(CameraUnit& camera, const TextureHandle& output); - TextureHandle ComputeAverageWhite(CameraUnit& camera); + TextureHandle ComputeAverageWhite(CameraUnit& camera, float fadingAdaptationSpeed, float adaptationThreshold); void GenerateDepthPyramid(TextureHandle& depth); void PerformPostProcessing(CameraUnit& camera); void PerformLightPass(CameraUnit& camera); @@ -72,11 +86,12 @@ namespace MxEngine void ApplySSAO(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output); void ApplySSR(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output); void ApplySSGI(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output); - void ApplyHDRToLDRConversion(CameraUnit& camera, TextureHandle& input, TextureHandle& output); + void ApplyHDRToLDRConversion(CameraUnit& camera, TextureHandle& input, TextureHandle& output, TextureHandle& averageWhite); void ApplyFXAA(CameraUnit& camera, TextureHandle& input, TextureHandle& output); void ApplyVignette(CameraUnit& camera, TextureHandle& input, TextureHandle& output); void ApplyColorGrading(CameraUnit& camera, TextureHandle& input, TextureHandle& output); void ApplyDepthOfFieldEffect(CameraUnit& camera, TextureHandle& input, TextureHandle& temporary, TextureHandle& output); + void ApplyLensFlare(CameraUnit& camera, TextureHandle& input, TextureHandle& temporaryQuater0, TextureHandle& temporaryQuater1, TextureHandle& temporaryQuater2, TextureHandle& temporary1); void DrawIBL(CameraUnit& camera, TextureHandle& output); void DrawDirectionalLights(CameraUnit& camera, TextureHandle& output); void DrawShadowedPointLights(CameraUnit& camera, TextureHandle& output); @@ -130,9 +145,7 @@ namespace MxEngine void SubmitLightSource(const DirectionalLight& light, const Transform& parentTransform); void SubmitLightSource(const PointLight& light, const Transform& parentTransform); void SubmitLightSource(const SpotLight& light, const Transform& parentTransform); - void SubmitCamera(const CameraController& controller, const Transform& parentTransform, - const Skybox* skybox, const CameraEffects* effects, const CameraToneMapping* toneMapping, - const CameraSSR* ssr, const CameraSSGI* ssgi, const CameraSSAO* ssao,const CameraGodRay* godRay); + void SubmitCamera(const CameraInfo& info); size_t SubmitRenderGroup(const Mesh& mesh, size_t instanceOffset, size_t instanceCount); void SubmitRenderUnit(size_t renderGroupIndex, const SubMesh& object, const Material& material, const Transform& parentTransform, bool castsShadow, const char* debugName = nullptr); void SubmitImage(const TextureHandle& texture, int lod = 0); diff --git a/src/Core/Rendering/RenderPipeline.h b/src/Core/Rendering/RenderPipeline.h index 8b7b3c70..dd64279e 100644 --- a/src/Core/Rendering/RenderPipeline.h +++ b/src/Core/Rendering/RenderPipeline.h @@ -48,6 +48,7 @@ namespace MxEngine class CameraSSGI; class CameraSSAO; class CameraGodRay; + class CameraLensFlare; struct DebugBufferUnit { @@ -66,6 +67,9 @@ namespace MxEngine TextureHandle HDRTexture; TextureHandle SwapTexture1; TextureHandle SwapTexture2; + TextureHandle SwapQuaterTexture1; + TextureHandle SwapQuaterTexture2; + TextureHandle SwapQuaterTexture3; FrustrumCuller Culler; Matrix4x4 InverseViewProjMatrix; @@ -92,6 +96,7 @@ namespace MxEngine const CameraSSGI* SSGI; const CameraSSAO* SSAO; const CameraGodRay* GodRay; + const CameraLensFlare* LensFlare; }; struct EnvironmentUnit diff --git a/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl index 6606edaa..36f71edf 100644 --- a/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl +++ b/src/Platform/OpenGL/Shaders/Library/fragment_utils.glsl @@ -125,3 +125,10 @@ FragmentInfo getFragmentInfo(vec2 texCoord, sampler2D albedoTexture, sampler2D n return fragment; } + +float calcLuminance(vec3 color) +{ + vec3 weight = vec3(0.2125f, 0.7154f, 0.0721f); + float luminance = dot(weight, color);//Weighted sum + return luminance; +} diff --git a/src/Platform/OpenGL/Shaders/average_white_fragment.glsl b/src/Platform/OpenGL/Shaders/average_white_fragment.glsl index e0031729..bdbe2451 100644 --- a/src/Platform/OpenGL/Shaders/average_white_fragment.glsl +++ b/src/Platform/OpenGL/Shaders/average_white_fragment.glsl @@ -1,3 +1,5 @@ +#include "Library/fragment_utils.glsl" + in vec2 TexCoord; out vec4 OutColor; @@ -6,13 +8,11 @@ uniform sampler2D prevFrameWhite; uniform float adaptSpeed; uniform float adaptThreshold; -vec3 luminance = vec3(0.2125f, 0.7154f, 0.0721f); - void main() { vec3 color = texture(curFrameHDR, TexCoord).rgb; float oldWhite = texture(prevFrameWhite, vec2(0.0f)).r; - float curWhite = dot(luminance, color); + float curWhite = calcLuminance(color); float diff = abs(curWhite - oldWhite) < adaptThreshold ? 0.0f : curWhite - oldWhite; diff --git a/src/Platform/OpenGL/Shaders/lens_flare.glsl b/src/Platform/OpenGL/Shaders/lens_flare.glsl new file mode 100644 index 00000000..a97747eb --- /dev/null +++ b/src/Platform/OpenGL/Shaders/lens_flare.glsl @@ -0,0 +1,36 @@ +#include "Library/fragment_utils.glsl" +layout(binding = 0) uniform sampler2D inputGhost; +layout(binding = 1) uniform sampler2D inputHalo; +layout(binding = 2) uniform sampler2D inputColor; + +uniform int uGhosts; // number of ghost samples +uniform float uGhostDispersal; // dispersion factor + + +in vec2 TexCoord; +out vec4 outColor; + +const float gWeight = 80.0; //relative to pixel pos + +void main() +{ + vec2 texcoord = vec2(1.0) - TexCoord; + // ghost vector to image centre: + vec2 ghostVec = (vec2(0.5) - texcoord) * uGhostDispersal; + + // sample ghosts + vec3 result = vec3(0.0); + for (int i = 0; i < uGhosts; ++i) + { + vec2 offset = fract(texcoord + 0.8 * ghostVec * float(i)); + float weight = length(vec2(0.5) - offset) / length(vec2(0.5)); + weight = pow(1.0 - weight, gWeight); + vec4 px = texture(inputGhost, offset).rgba; + result += px.rgb * weight; + } + + //halo + result += texture(inputHalo, TexCoord).rgb; + + outColor = vec4(result + texture(inputColor, TexCoord).rgb, 1.0); +} \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/lens_flare_ghosts.glsl b/src/Platform/OpenGL/Shaders/lens_flare_ghosts.glsl new file mode 100644 index 00000000..1d151d63 --- /dev/null +++ b/src/Platform/OpenGL/Shaders/lens_flare_ghosts.glsl @@ -0,0 +1,21 @@ +#include "Library/fragment_utils.glsl" + +layout(binding = 0) uniform sampler2D inputColor; +layout(binding = 1) uniform sampler2D averageWhiteTex; + +uniform float uIntensity; // [0, 1] range + +in vec2 TexCoord; + +out vec4 outputColor; + +void main() +{ + vec3 col = texture(inputColor, TexCoord).rgb; + float sceneLum = calcLuminance(col); + + float averageWhite = texture(averageWhiteTex, vec2(0.0)).r; + float lumRatio = sceneLum / averageWhite; + float lum = lumRatio < 1.0 ? 0.0 : pow(lumRatio, uIntensity) - 1.0; + outputColor = vec4(lum * col, averageWhite); +} \ No newline at end of file diff --git a/src/Platform/OpenGL/Shaders/lens_flare_halo.glsl b/src/Platform/OpenGL/Shaders/lens_flare_halo.glsl new file mode 100644 index 00000000..345eb146 --- /dev/null +++ b/src/Platform/OpenGL/Shaders/lens_flare_halo.glsl @@ -0,0 +1,29 @@ +#include "Library/fragment_utils.glsl" + +layout(binding = 0) uniform sampler2D inputColor; +layout(binding = 1) uniform sampler2D inputGhost; +layout(binding = 2) uniform sampler2D inputSceneAverageWhite; + +uniform float uGhostDispersal; // dispersion factor +uniform float uHaloWidth; +uniform int uMipLevel; + +in vec2 TexCoord; +out vec4 outputColor; + +const float gWeight = 80.0f; + +void main() +{ + float ghostAverageWhite = calcLuminance(texture(inputGhost, vec2(0.5), uMipLevel).rgb); + float sceneAverageWhite = texture(inputSceneAverageWhite, vec2(0.0)).r; + float factor = smoothstep(0.0, 1.0, (ghostAverageWhite / sceneAverageWhite * 5.0)); + + vec2 ghostTexcoord = vec2(1.0) - TexCoord; + vec2 haloVec = normalize((vec2(0.5) - ghostTexcoord) * uGhostDispersal) * uHaloWidth; + float weight = length(vec2(0.5) - fract(ghostTexcoord + haloVec)) / length(vec2(0.5)); + weight = pow(1.0 - weight, gWeight); + vec3 haloColor = texture(inputColor, ghostTexcoord + haloVec).rgb * weight; + + outputColor = vec4(haloColor * factor, 1.0f); +} \ No newline at end of file