Skip to content

Commit b5f1b88

Browse files
authored
Added mipmap bloom algorithm (#18725)
1 parent 655e8b9 commit b5f1b88

13 files changed

+810
-260
lines changed

cc.config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@
256256
"dependentScripts": [
257257
"ff9b0199-ce04-4cfe-86cc-6c719f08d6e4",
258258
"de1c2107-70c8-4021-8459-6399f24d01c6",
259-
"cbf30902-517f-40dc-af90-a550bac27cf1"
259+
"cbf30902-517f-40dc-af90-a550bac27cf1",
260+
"5c601d96-e4c7-4698-991b-7ee674b11079"
260261
]
261262
},
262263
"custom-pipeline-post-process": {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"__type__": "cc.Material",
3+
"_name": "",
4+
"_objFlags": 0,
5+
"__editorExtras__": {},
6+
"_native": "",
7+
"_effectAsset": {
8+
"__uuid__": "7ca08c6b-221a-43d5-8ad6-a6dd2ee7852b",
9+
"__expectedType__": "cc.EffectAsset"
10+
},
11+
"_techIdx": 0,
12+
"_defines": [
13+
{},
14+
{},
15+
{},
16+
{}
17+
],
18+
"_states": [
19+
{
20+
"rasterizerState": {},
21+
"depthStencilState": {},
22+
"blendState": {
23+
"targets": [
24+
{}
25+
]
26+
}
27+
},
28+
{
29+
"rasterizerState": {},
30+
"depthStencilState": {},
31+
"blendState": {
32+
"targets": [
33+
{}
34+
]
35+
}
36+
},
37+
{
38+
"rasterizerState": {},
39+
"depthStencilState": {},
40+
"blendState": {
41+
"targets": [
42+
{}
43+
]
44+
}
45+
},
46+
{
47+
"rasterizerState": {},
48+
"depthStencilState": {},
49+
"blendState": {
50+
"targets": [
51+
{}
52+
]
53+
}
54+
}
55+
],
56+
"_props": [
57+
{},
58+
{},
59+
{},
60+
{}
61+
]
62+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ver": "1.0.21",
3+
"importer": "material",
4+
"imported": true,
5+
"uuid": "9c3ea99f-fd05-43ec-9067-14ce54ccf9be",
6+
"files": [
7+
".json"
8+
],
9+
"subMetas": {},
10+
"userData": {}
11+
}

editor/assets/default_renderpipeline/builtin-pipeline-settings.ts

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@
2424

2525
import {
2626
_decorator, Camera, CCBoolean, CCFloat, CCInteger, Component,
27-
Material, rendering, Texture2D,
27+
Material, rendering, Texture2D, visible,
2828
} from 'cc';
2929

3030
import { EDITOR } from 'cc/env';
3131

3232
import {
33-
fillRequiredPipelineSettings, makePipelineSettings, PipelineSettings,
33+
BloomType,
34+
fillRequiredPipelineSettings, getBuiltinBloomMaterial, makePipelineSettings, PipelineSettings,
3435
} from './builtin-pipeline-types';
3536

3637
const { ccclass, disallowMultiple, executeInEditMode, menu, property, requireComponent, type } = _decorator;
@@ -54,7 +55,6 @@ export class BuiltinPipelineSettings extends Component {
5455
const cameraComponent = this.getComponent(Camera)!;
5556
const camera = cameraComponent.camera;
5657
camera.pipelineSettings = this._settings;
57-
5858
if (EDITOR) {
5959
this._tryEnableEditorPreview();
6060
}
@@ -185,21 +185,53 @@ export class BuiltinPipelineSettings extends Component {
185185
return this._settings.bloom.enabled;
186186
}
187187

188+
@type(BloomType)
189+
@property({
190+
group: { id: 'Bloom', name: 'Bloom (PostProcessing)', style: 'section' },
191+
})
192+
set bloomType(value: BloomType) {
193+
this._settings.bloom.type = value;
194+
if (EDITOR) {
195+
this._tryEnableEditorPreview();
196+
}
197+
}
198+
199+
get bloomType(): BloomType {
200+
return this._settings.bloom.type;
201+
}
202+
203+
@property({
204+
group: { id: 'Bloom', name: 'Bloom (PostProcessing)', style: 'section' },
205+
type: Material,
206+
})
207+
set kawaseBloomMaterial(value: Material) {
208+
if (this._settings.bloom.kawaseFilterMaterial === value) {
209+
return;
210+
}
211+
this._settings.bloom.kawaseFilterMaterial = value;
212+
if (EDITOR) {
213+
this._tryEnableEditorPreview();
214+
}
215+
}
216+
get kawaseBloomMaterial(): Material {
217+
return this._settings.bloom.kawaseFilterMaterial!;
218+
}
219+
188220
@property({
189221
group: { id: 'Bloom', name: 'Bloom (PostProcessing)', style: 'section' },
190222
type: Material,
191223
})
192-
set bloomMaterial(value: Material) {
193-
if (this._settings.bloom.material === value) {
224+
set mipmapBloomMaterial(value: Material) {
225+
if (this._settings.bloom.mipmapFilterMaterial === value) {
194226
return;
195227
}
196-
this._settings.bloom.material = value;
228+
this._settings.bloom.mipmapFilterMaterial = value;
197229
if (EDITOR) {
198230
this._tryEnableEditorPreview();
199231
}
200232
}
201-
get bloomMaterial(): Material {
202-
return this._settings.bloom.material!;
233+
get mipmapBloomMaterial(): Material {
234+
return this._settings.bloom.mipmapFilterMaterial!;
203235
}
204236

205237
@property({
@@ -247,8 +279,18 @@ export class BuiltinPipelineSettings extends Component {
247279
return this._settings.bloom.threshold;
248280
}
249281

282+
@type(CCFloat)
283+
@property({
284+
group: { id: 'Bloom', name: 'Bloom (PostProcessing)', style: 'section' },
285+
})
286+
@visible(function(this: BuiltinPipelineSettings) {
287+
return this.bloomType === BloomType.MipmapFilter;
288+
})
250289
set bloomIntensity(value: number) {
251290
this._settings.bloom.intensity = value;
291+
if (EDITOR) {
292+
this._tryEnableEditorPreview();
293+
}
252294
}
253295
get bloomIntensity(): number {
254296
return this._settings.bloom.intensity;
@@ -353,7 +395,6 @@ export class BuiltinPipelineSettings extends Component {
353395
type: CCBoolean,
354396
})
355397
set fsrEnable(value: boolean) {
356-
this._settings.fsr.enabled = value;
357398
if (EDITOR) {
358399
this._tryEnableEditorPreview();
359400
}

editor/assets/default_renderpipeline/builtin-pipeline-types.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* ========================= !DO NOT CHANGE THE FOLLOWING SECTION MANUALLY! =========================
2929
*/
3030
/* eslint-disable max-len */
31-
import { Material, Texture2D, gfx } from 'cc';
31+
import { Material, Texture2D, gfx, ccenum } from 'cc';
3232

3333
const { SampleCount } = gfx;
3434

@@ -96,35 +96,50 @@ export function fillRequiredHBAO(value: HBAO): void {
9696
}
9797
}
9898

99+
export enum BloomType {
100+
MipmapFilter,
101+
KawaseDualFilter,
102+
}
103+
ccenum(BloomType);
99104
export interface Bloom {
100105
enabled: boolean; /* false */
101-
/* refcount */ material: Material | null;
106+
type: BloomType;
107+
/* refcount */ kawaseFilterMaterial: Material | null;
108+
mipmapFilterMaterial: Material | null;
102109
enableAlphaMask: boolean; /* false */
103110
iterations: number; /* 3 */
104111
threshold: number; /* 0.8 */
105-
intensity: number; /* 2.3 */
112+
intensity: number; /* 1 */
106113
[name: string]: unknown;
107114
}
108115

109116
export function makeBloom(): Bloom {
110117
return {
111118
enabled: false,
112-
material: null,
119+
type: BloomType.KawaseDualFilter,
120+
kawaseFilterMaterial: null,
121+
mipmapFilterMaterial: null,
113122
enableAlphaMask: false,
114123
iterations: 3,
115124
threshold: 0.8,
116-
intensity: 2.3,
125+
intensity: 1,
117126
};
118127
}
119128

120129
export function fillRequiredBloom(value: Bloom): void {
121130
if (value.enabled === undefined) {
122131
value.enabled = false;
123132
}
124-
if (value.material === undefined) {
125-
value.material = null;
133+
if (value.type === undefined) {
134+
value.type = BloomType.KawaseDualFilter;
135+
}
136+
if (!value.kawaseFilterMaterial) {
137+
value.kawaseFilterMaterial = null;
138+
}
139+
if (!value.mipmapFilterMaterial) {
140+
value.mipmapFilterMaterial = null;
126141
}
127-
if (value.enableAlphaMask === undefined) {
142+
if (!value.enableAlphaMask) {
128143
value.enableAlphaMask = false;
129144
}
130145
if (value.iterations === undefined) {
@@ -134,7 +149,7 @@ export function fillRequiredBloom(value: Bloom): void {
134149
value.threshold = 0.8;
135150
}
136151
if (value.intensity === undefined) {
137-
value.intensity = 2.3;
152+
value.intensity = 1;
138153
}
139154
}
140155

0 commit comments

Comments
 (0)