-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Make node materials compatible with prepass #14014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
f8ca9f2
wip nme prepass
CraigFeldspar bdf6eea
compilation & update works for prepass + nme
CraigFeldspar ff38831
successful write in prepass
CraigFeldspar 94b41f1
adding prepassTextureBlock
CraigFeldspar 6f6494a
.
CraigFeldspar 25a30dd
added readFrameBuffer - to remove. Instead going for noPrePassDefaultRT
CraigFeldspar c0786f2
prepass texture read OK
CraigFeldspar de60d75
share depth bug
CraigFeldspar 2b76a9d
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js
CraigFeldspar 62790fb
Merge remote-tracking branch 'origin/master'
CraigFeldspar ea4eed9
resize ok
CraigFeldspar 9ac6875
msaa works
CraigFeldspar dcca59f
lint
CraigFeldspar 04fff43
Merge remote-tracking branch 'upstream/master'
CraigFeldspar 5ca262b
cleanup + color => position in prepass block
CraigFeldspar 09cc6f3
lint
CraigFeldspar a085c78
port name for multi input nodes
CraigFeldspar 52b53d2
format
CraigFeldspar 4d7346b
fixing imports
CraigFeldspar 01bf745
fix import #2
CraigFeldspar 2bafc05
fixing imports #3
CraigFeldspar e542019
format
CraigFeldspar c6fb8ed
Merge remote-tracking branch 'upstream/master'
CraigFeldspar 4065f57
bugfix when non prepass material is rendered last
CraigFeldspar 1a7dd85
fixing code so tests pass
CraigFeldspar 0fa4778
fixing bad test using wrong API for prepass
CraigFeldspar cd1f973
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js
CraigFeldspar 15b1214
Merge remote-tracking branch 'origin/master'
CraigFeldspar 831e11b
Update packages/dev/core/src/Engines/WebGL/webGLHardwareTexture.ts
CraigFeldspar 0432d57
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js
CraigFeldspar 34b7bcc
Merge remote-tracking branch 'upstream/master'
CraigFeldspar ee54bae
removing read/write prepass texture from the same pass
CraigFeldspar 8d7f8c8
revert msaa webglrtwrapper code
CraigFeldspar 8e428f2
remove ref increment in setTexture
CraigFeldspar 62c30e3
cleaning ppr
CraigFeldspar 2399651
remove prepass capable from fragment block
CraigFeldspar a8f851f
clean PR code
CraigFeldspar 205e5a6
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js
CraigFeldspar 914b8de
Merge remote-tracking branch 'origin/master'
CraigFeldspar c408c72
removing size forced hack
CraigFeldspar 77129f5
add PrePassOutputBlock
CraigFeldspar 7fe2747
separate prepass output to its own block
CraigFeldspar e3a8de7
fixing exports
CraigFeldspar d7ba8d0
fixing nits
CraigFeldspar 9038a5a
fix prepass required textures
CraigFeldspar a509fd7
removing old code
CraigFeldspar e746a0e
adding clarification comment
CraigFeldspar 71af8e6
fixing postprocess prepass textures
CraigFeldspar 1c4357a
merge with master
CraigFeldspar 0ccf2e2
PR feedback
CraigFeldspar 05848e8
format
CraigFeldspar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
packages/dev/core/src/Materials/Node/Blocks/Fragment/prePassOutputBlock.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { NodeMaterialBlock } from "../../nodeMaterialBlock"; | ||
import { NodeMaterialBlockConnectionPointTypes } from "../../Enums/nodeMaterialBlockConnectionPointTypes"; | ||
import type { NodeMaterialBuildState } from "../../nodeMaterialBuildState"; | ||
import { NodeMaterialBlockTargets } from "../../Enums/nodeMaterialBlockTargets"; | ||
import type { NodeMaterialConnectionPoint } from "../../nodeMaterialBlockConnectionPoint"; | ||
import { RegisterClass } from "../../../../Misc/typeStore"; | ||
|
||
/** | ||
* Block used to output values on the prepass textures | ||
*/ | ||
export class PrePassOutputBlock extends NodeMaterialBlock { | ||
/** | ||
* Create a new PrePassOutputBlock | ||
* @param name defines the block name | ||
*/ | ||
public constructor(name: string) { | ||
super(name, NodeMaterialBlockTargets.Fragment, true); | ||
|
||
this.registerInput("viewDepth", NodeMaterialBlockConnectionPointTypes.Float, true); | ||
this.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.AutoDetect, true); | ||
this.registerInput("viewNormal", NodeMaterialBlockConnectionPointTypes.AutoDetect, true); | ||
|
||
this.inputs[1].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4); | ||
this.inputs[2].addExcludedConnectionPointFromAllowedTypes(NodeMaterialBlockConnectionPointTypes.Vector3 | NodeMaterialBlockConnectionPointTypes.Vector4); | ||
} | ||
|
||
/** | ||
* Gets the current class name | ||
* @returns the class name | ||
*/ | ||
public getClassName() { | ||
return "PrePassOutputBlock"; | ||
} | ||
|
||
/** | ||
* Gets the view depth component | ||
*/ | ||
public get viewDepth(): NodeMaterialConnectionPoint { | ||
return this._inputs[0]; | ||
} | ||
|
||
/** | ||
* Gets the world position component | ||
*/ | ||
public get worldPosition(): NodeMaterialConnectionPoint { | ||
return this._inputs[1]; | ||
} | ||
|
||
/** | ||
* Gets the view normal component | ||
*/ | ||
public get viewNormal(): NodeMaterialConnectionPoint { | ||
return this._inputs[2]; | ||
} | ||
|
||
protected _buildBlock(state: NodeMaterialBuildState) { | ||
super._buildBlock(state); | ||
|
||
const worldPosition = this.worldPosition; | ||
const viewNormal = this.viewNormal; | ||
const viewDepth = this.viewDepth; | ||
|
||
state.sharedData.blocksWithDefines.push(this); | ||
|
||
const comments = `//${this.name}`; | ||
state._emitFunctionFromInclude("helperFunctions", comments); | ||
|
||
state.compilationString += `#if defined(PREPASS)\r\n`; | ||
state.compilationString += `#ifdef PREPASS_DEPTH\r\n`; | ||
if (viewDepth.connectedPoint) { | ||
state.compilationString += ` gl_FragData[PREPASS_DEPTH_INDEX] = vec4(${viewDepth.associatedVariableName}, 0.0, 0.0, 1.0);\r\n`; | ||
} else { | ||
// We have to write something on the viewDepth output or it will raise a gl error | ||
state.compilationString += ` gl_FragData[PREPASS_DEPTH_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r\n`; | ||
} | ||
state.compilationString += `#endif\r\n`; | ||
state.compilationString += `#ifdef PREPASS_POSITION\r\n`; | ||
if (worldPosition.connectedPoint) { | ||
state.compilationString += ` gl_FragData[PREPASS_POSITION_INDEX] = vec4(${worldPosition.associatedVariableName}.rgb, ${ | ||
worldPosition.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? worldPosition.associatedVariableName + ".a" : "1.0" | ||
});\r\n`; | ||
} else { | ||
// We have to write something on the position output or it will raise a gl error | ||
state.compilationString += ` gl_FragData[PREPASS_POSITION_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r\n`; | ||
} | ||
state.compilationString += `#endif\r\n`; | ||
state.compilationString += `#ifdef PREPASS_NORMAL\r\n`; | ||
if (viewNormal.connectedPoint) { | ||
state.compilationString += ` gl_FragData[PREPASS_NORMAL_INDEX] = vec4(${viewNormal.associatedVariableName}.rgb, ${ | ||
viewNormal.connectedPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4 ? viewNormal.associatedVariableName + ".a" : "1.0" | ||
});\r\n`; | ||
} else { | ||
// We have to write something on the normal output or it will raise a gl error | ||
state.compilationString += ` gl_FragData[PREPASS_NORMAL_INDEX] = vec4(0.0, 0.0, 0.0, 0.0);\r\n`; | ||
} | ||
state.compilationString += `#endif\r\n`; | ||
state.compilationString += `#endif\r\n`; | ||
|
||
return this; | ||
} | ||
} | ||
|
||
RegisterClass("BABYLON.PrePassOutputBlock", PrePassOutputBlock); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./inputBlock"; | ||
export * from "./animatedInputBlockTypes"; | ||
export * from "./prePassTextureBlock"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.