Skip to content

Commit d2fa2b5

Browse files
gabrieldelacruzGitHub Enterprise
authored andcommitted
[VFX] Add frontface semantic to vfx using shader graph materials (#257)
* Add frontface semantic to vfx using shader graph materials * Update changelog
1 parent 9d6e6d0 commit d2fa2b5

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/IsFrontFaceNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public override void UpdateNodeAfterDeserialization()
2525

2626
public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode)
2727
{
28-
sb.AppendLine(string.Format("$precision {0} = max(0, IN.{1});", GetVariableNameForSlot(OutputSlotId), ShaderGeneratorNames.FaceSign));
28+
sb.AppendLine(string.Format("$precision {0} = max(0, IN.{1}.x);", GetVariableNameForSlot(OutputSlotId), ShaderGeneratorNames.FaceSign));
2929
}
3030

3131
public bool RequiresFaceSign(ShaderStageCapability stageCapability = ShaderStageCapability.Fragment)

com.unity.visualeffectgraph/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6767
- Enabled an optimization for motion vectors, storing projected positions for vertices instead of the transform matrix
6868
- Compilation issue when normal is used in shadergraph for opacity with unlit output
6969
- Fix Exception on trying to invert a degenerate TRS matrix [Case 1307068](https://issuetracker.unity3d.com/product/unity/issues/guid/1307068/)
70+
- Fix IsFrontFace shader graph node for VFX.
7071

7172
## [11.0.0] - 2020-10-21
7273
### Added

com.unity.visualeffectgraph/Editor/ShaderGraph/VFXShaderGraphParticleOutput.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,11 @@ public override IEnumerable<KeyValuePair<string, VFXShaderWriter>> additionalRep
804804
callSG.builder.AppendLine("INSG.TimeParameters = _TimeParameters.xyz;");
805805
}
806806

807+
if (graphCode.requirements.requiresFaceSign)
808+
{
809+
callSG.builder.AppendLine("INSG.FaceSign = frontFace ? 1.0f : -1.0f;");
810+
}
811+
807812
if (taskType == VFXTaskType.ParticleMeshOutput)
808813
{
809814
for (UVChannel uv = UVChannel.UV1; uv <= UVChannel.UV3; ++uv)

com.unity.visualeffectgraph/Shaders/ParticlePlanarPrimitives/PassForwardCommon.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct ps_input
4242
#if SHADERGRAPH_NEEDS_TANGENT_FORWARD
4343
float3 tangent : TEXCOORD7;
4444
#endif
45-
45+
4646
${VFXAdditionalInterpolantsDeclaration}
4747

4848
UNITY_VERTEX_OUTPUT_STEREO
@@ -91,7 +91,8 @@ ${SHADERGRAPH_PIXEL_CODE_FORWARD}
9191
#endif
9292

9393
#pragma fragment frag
94-
ps_output frag(ps_input i)
94+
ps_output frag(ps_input i,
95+
bool frontFace : SV_IsFrontFace)
9596
{
9697
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
9798
ps_output o = (ps_output)0;

0 commit comments

Comments
 (0)