@@ -51,6 +51,12 @@ export class GBufferConfig extends EventDispatcher<BaseEventMap> {
51
51
52
52
readonly gDataStructInitialization : Map < GData | string , string > ;
53
53
54
+ /**
55
+ * A collection that describes {@link GData} cross-dependencies.
56
+ */
57
+
58
+ readonly gDataDependencies : Map < GData | string , Set < GData | string > > ;
59
+
54
60
/**
55
61
* Constructs new a new G-Buffer config.
56
62
*/
@@ -81,6 +87,7 @@ export class GBufferConfig extends EventDispatcher<BaseEventMap> {
81
87
[ GData . COLOR , "vec4 color;" ] ,
82
88
[ GData . DEPTH , "float depth;" ] ,
83
89
[ GData . NORMAL , "vec3 normal;" ] ,
90
+ [ GData . POSITION , "vec3 position;" ] ,
84
91
[ GData . ORM , "vec3 orm;" ] ,
85
92
[ GData . EMISSION , "vec3 emission;" ] ,
86
93
[ GData . LUMINANCE , "float luminance;" ]
@@ -90,11 +97,16 @@ export class GBufferConfig extends EventDispatcher<BaseEventMap> {
90
97
[ GData . COLOR , "gData.color = texture(gBuffer.color, UV);" ] ,
91
98
[ GData . DEPTH , "gData.depth = texture(gBuffer.depth, UV).r;" ] ,
92
99
[ GData . NORMAL , "gData.normal = texture(gBuffer.normal, UV).xyz;" ] ,
100
+ [ GData . POSITION , "gData.position = getViewPosition(UV, gData.depth);" ] ,
93
101
[ GData . ORM , "gData.orm = texture(gBuffer.orm, UV).xyz;" ] ,
94
102
[ GData . EMISSION , "gData.emission = texture(gBuffer.emission, UV).rgb;" ] ,
95
103
[ GData . LUMINANCE , "gData.luminance = luminance(gData.color.rgb);" ]
96
104
] ) ;
97
105
106
+ const gDataDependencies = new ObservableMap < GData | string , Set < GData | string > > ( [
107
+ [ GData . POSITION , new Set < GData > ( [ GData . DEPTH ] ) ]
108
+ ] ) ;
109
+
98
110
const listener = ( ) => this . dispatchEvent ( { type : GBufferConfig . EVENT_CHANGE } ) ;
99
111
textureConfigs . addEventListener ( ObservableMap . EVENT_CHANGE , listener ) ;
100
112
gBufferStructFields . addEventListener ( ObservableMap . EVENT_CHANGE , listener ) ;
@@ -107,6 +119,7 @@ export class GBufferConfig extends EventDispatcher<BaseEventMap> {
107
119
this . gBufferStructDeclaration = gBufferStructDeclaration ;
108
120
this . gDataStructDeclaration = gDataStructDeclaration ;
109
121
this . gDataStructInitialization = gDataStructInitialization ;
122
+ this . gDataDependencies = gDataDependencies ;
110
123
111
124
}
112
125
0 commit comments