Skip to content
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

Node: add analyze() to optimization and validation #23475

Merged
merged 6 commits into from
Feb 14, 2022
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Feb 12, 2022

Related issue: #23350 (comment)

Description

Not create temp variables that are used only once.

I add a example bellow before and after the analize.

Before

// Three.js r138dev - NodeMaterial System


// uniforms
@group( 0 ) @binding( 1 ) var nodeUniform6_sampler : sampler; @group( 0 ) @binding( 2 ) var nodeUniform6 : texture_2d<f32>; 
struct NodeUniformsStruct {

	nodeUniform0 : vec3<f32>;
	nodeUniform1 : f32;
	nodeUniform2 : f32;
	nodeUniform3 : f32;
	nodeUniform7 : vec3<f32>;
	nodeUniform8 : vec3<f32>;
	nodeUniform9 : vec3<f32>;
	nodeUniform10 : f32;
	nodeUniform11 : f32;
	nodeUniform12 : vec3<f32>;
	nodeUniform13 : vec3<f32>;
	nodeUniform14 : f32;
	nodeUniform15 : f32;
	nodeUniform16 : vec3<f32>;
	nodeUniform17 : vec3<f32>;
	nodeUniform18 : f32;
	nodeUniform19 : f32;
	nodeUniform20 : vec3<f32>;
	nodeUniform21 : vec3<f32>;
	nodeUniform22 : f32;
	nodeUniform23 : f32;
	nodeUniform24 : vec3<f32>;

};
@binding( 3 ) @group( 0 )
var<uniform> NodeUniforms : NodeUniformsStruct;

// codes

fn inversesqrt( x : f32 ) -> f32 {

	return 1.0 / sqrt( x );

}



@stage( fragment )
fn main( 
	@location( 0 ) nodeVary0 : vec3<f32>,
	@location( 1 ) nodeVary1 : vec4<f32>,
	@location( 2 ) nodeVary2 : vec3<f32>,
	@location( 3 ) nodeVary3 : vec3<f32>,
	@location( 4 ) nodeVary4 : vec3<f32>,
	@location( 5 ) nodeVary5 : vec2<f32>,
	@location( 6 ) nodeVary6 : vec3<f32>,
	@location( 7 ) nodeVary7 : vec4<f32>
 ) -> @location( 0 ) vec4<f32> {

	// vars
	var Color : vec4<f32>; var DiffuseColor : vec4<f32>; var nodeVar2 : f32; var OPACITY : f32; var Metalness : f32; var nodeVar5 : f32; var nodeVar6 : vec3<f32>; var nodeVar7 : vec3<f32>; var nodeVar8 : vec3<f32>; var nodeVar9 : vec3<f32>; var nodeVar10 : vec3<f32>; var nodeVar11 : f32; var nodeVar12 : f32; var nodeVar13 : f32; var nodeVar14 : f32; var Roughness : f32; var nodeVar16 : vec3<f32>; var SpecularColor : vec3<f32>; var nodeVar18 : vec3<f32>; var nodeVar19 : vec3<f32>; var nodeVar20 : vec3<f32>; var nodeVar21 : vec2<f32>; var nodeVar22 : vec3<f32>; var nodeVar23 : vec3<f32>; var nodeVar24 : vec3<f32>; var nodeVar25 : vec2<f32>; var nodeVar26 : vec3<f32>; var nodeVar27 : vec3<f32>; var nodeVar28 : vec4<f32>; var nodeVar29 : vec4<f32>; var nodeVar30 : f32; var nodeVar31 : f32; var nodeVar32 : vec3<f32>; var nodeVar33 : vec3<f32>; var nodeVar34 : vec3<f32>; var nodeVar35 : f32; var nodeVar36 : f32; var nodeVar37 : bool; var nodeVar38 : f32; var nodeVar39 : vec3<f32>; var nodeVar40 : f32; var nodeVar41 : vec3<f32>; var nodeVar42 : vec3<f32>; var nodeVar43 : vec3<f32>; var nodeVar44 : vec3<f32>; var nodeVar45 : vec3<f32>; var nodeVar46 : vec3<f32>; var TransformedNormalView : vec3<f32>; var nodeVar48 : vec3<f32>; var nodeVar49 : vec3<f32>; var nodeVar50 : f32; var nodeVar51 : f32; var nodeVar52 : f32; var nodeVar53 : bool; var nodeVar54 : bool; var nodeVar55 : bool; var nodeVar56 : vec3<f32>; var nodeVar57 : vec3<f32>; var nodeVar58 : vec3<f32>; var nodeVar59 : vec3<f32>; var nodeVar60 : vec3<f32>; var nodeVar61 : vec3<f32>; var nodeVar62 : vec3<f32>; var nodeVar63 : vec3<f32>; var nodeVar64 : f32; var nodeVar65 : f32; var nodeVar66 : f32; var nodeVar67 : bool; var nodeVar68 : bool; var nodeVar69 : bool; var nodeVar70 : vec3<f32>; var nodeVar71 : vec3<f32>; var nodeVar72 : vec3<f32>; var nodeVar73 : vec3<f32>; var nodeVar74 : vec3<f32>; var nodeVar75 : vec3<f32>; var nodeVar76 : vec3<f32>; var nodeVar77 : vec3<f32>; var nodeVar78 : f32; var nodeVar79 : f32; var nodeVar80 : f32; var nodeVar81 : bool; var nodeVar82 : bool; var nodeVar83 : bool; var nodeVar84 : vec3<f32>; var nodeVar85 : vec3<f32>; var nodeVar86 : vec3<f32>; var nodeVar87 : vec3<f32>; var nodeVar88 : vec3<f32>; var nodeVar89 : vec3<f32>; var nodeVar90 : vec3<f32>; var nodeVar91 : vec3<f32>; var nodeVar92 : f32; var nodeVar93 : f32; var nodeVar94 : f32; var nodeVar95 : bool; var nodeVar96 : bool; var nodeVar97 : bool; var nodeVar98 : vec3<f32>; var nodeVar99 : vec3<f32>; var nodeVar100 : vec3<f32>; var nodeVar101 : vec3<f32>; var nodeVar102 : vec3<f32>; var nodeVar103 : vec3<f32>; var DirectDiffuse : vec3<f32>; var nodeVar105 : vec3<f32>; var nodeVar106 : vec3<f32>; var nodeVar107 : vec3<f32>; var nodeVar108 : vec3<f32>; var nodeVar109 : f32; var nodeVar110 : f32; var nodeVar111 : f32; var nodeVar112 : f32; var nodeVar113 : f32; var nodeVar114 : f32; var nodeVar115 : f32; var nodeVar116 : vec3<f32>; var nodeVar117 : f32; var nodeVar118 : vec3<f32>; var nodeVar119 : f32; var nodeVar120 : f32; var nodeVar121 : f32; var nodeVar122 : f32; var nodeVar123 : f32; var nodeVar124 : f32; var nodeVar125 : f32; var nodeVar126 : f32; var nodeVar127 : f32; var nodeVar128 : f32; var nodeVar129 : f32; var nodeVar130 : f32; var nodeVar131 : f32; var nodeVar132 : f32; var nodeVar133 : f32; var nodeVar134 : f32; var nodeVar135 : f32; var nodeVar136 : f32; var nodeVar137 : f32; var nodeVar138 : f32; var nodeVar139 : f32; var nodeVar140 : f32; var nodeVar141 : f32; var nodeVar142 : f32; var nodeVar143 : f32; var nodeVar144 : f32; var nodeVar145 : f32; var nodeVar146 : f32; var nodeVar147 : f32; var nodeVar148 : f32; var nodeVar149 : f32; var nodeVar150 : f32; var nodeVar151 : vec3<f32>; var nodeVar152 : vec3<f32>; var nodeVar153 : vec3<f32>; var nodeVar154 : vec3<f32>; var nodeVar155 : vec3<f32>; var nodeVar156 : vec3<f32>; var nodeVar157 : f32; var nodeVar158 : f32; var nodeVar159 : f32; var nodeVar160 : f32; var nodeVar161 : f32; var nodeVar162 : f32; var nodeVar163 : f32; var nodeVar164 : vec3<f32>; var nodeVar165 : f32; var nodeVar166 : vec3<f32>; var nodeVar167 : f32; var nodeVar168 : f32; var nodeVar169 : f32; var nodeVar170 : f32; var nodeVar171 : f32; var nodeVar172 : f32; var nodeVar173 : f32; var nodeVar174 : f32; var nodeVar175 : f32; var nodeVar176 : f32; var nodeVar177 : f32; var nodeVar178 : f32; var nodeVar179 : f32; var nodeVar180 : f32; var nodeVar181 : f32; var nodeVar182 : f32; var nodeVar183 : f32; var nodeVar184 : f32; var nodeVar185 : f32; var nodeVar186 : f32; var nodeVar187 : f32; var nodeVar188 : f32; var nodeVar189 : f32; var nodeVar190 : f32; var nodeVar191 : f32; var nodeVar192 : f32; var nodeVar193 : f32; var nodeVar194 : f32; var nodeVar195 : f32; var nodeVar196 : f32; var nodeVar197 : f32; var nodeVar198 : f32; var nodeVar199 : vec3<f32>; var nodeVar200 : vec3<f32>; var nodeVar201 : vec3<f32>; var nodeVar202 : vec3<f32>; var nodeVar203 : vec3<f32>; var nodeVar204 : vec3<f32>; var nodeVar205 : f32; var nodeVar206 : f32; var nodeVar207 : f32; var nodeVar208 : f32; var nodeVar209 : f32; var nodeVar210 : f32; var nodeVar211 : f32; var nodeVar212 : vec3<f32>; var nodeVar213 : f32; var nodeVar214 : vec3<f32>; var nodeVar215 : f32; var nodeVar216 : f32; var nodeVar217 : f32; var nodeVar218 : f32; var nodeVar219 : f32; var nodeVar220 : f32; var nodeVar221 : f32; var nodeVar222 : f32; var nodeVar223 : f32; var nodeVar224 : f32; var nodeVar225 : f32; var nodeVar226 : f32; var nodeVar227 : f32; var nodeVar228 : f32; var nodeVar229 : f32; var nodeVar230 : f32; var nodeVar231 : f32; var nodeVar232 : f32; var nodeVar233 : f32; var nodeVar234 : f32; var nodeVar235 : f32; var nodeVar236 : f32; var nodeVar237 : f32; var nodeVar238 : f32; var nodeVar239 : f32; var nodeVar240 : f32; var nodeVar241 : f32; var nodeVar242 : f32; var nodeVar243 : f32; var nodeVar244 : f32; var nodeVar245 : f32; var nodeVar246 : f32; var nodeVar247 : vec3<f32>; var nodeVar248 : vec3<f32>; var nodeVar249 : vec3<f32>; var nodeVar250 : vec3<f32>; var nodeVar251 : vec3<f32>; var nodeVar252 : vec3<f32>; var nodeVar253 : f32; var nodeVar254 : f32; var nodeVar255 : f32; var nodeVar256 : f32; var nodeVar257 : f32; var nodeVar258 : f32; var nodeVar259 : f32; var nodeVar260 : vec3<f32>; var nodeVar261 : f32; var nodeVar262 : vec3<f32>; var nodeVar263 : f32; var nodeVar264 : f32; var nodeVar265 : f32; var nodeVar266 : f32; var nodeVar267 : f32; var nodeVar268 : f32; var nodeVar269 : f32; var nodeVar270 : f32; var nodeVar271 : f32; var nodeVar272 : f32; var nodeVar273 : f32; var nodeVar274 : f32; var nodeVar275 : f32; var nodeVar276 : f32; var nodeVar277 : f32; var nodeVar278 : f32; var nodeVar279 : f32; var nodeVar280 : f32; var nodeVar281 : f32; var nodeVar282 : f32; var nodeVar283 : f32; var nodeVar284 : f32; var nodeVar285 : f32; var nodeVar286 : f32; var nodeVar287 : f32; var nodeVar288 : f32; var nodeVar289 : f32; var nodeVar290 : f32; var nodeVar291 : f32; var nodeVar292 : f32; var nodeVar293 : f32; var nodeVar294 : f32; var nodeVar295 : vec3<f32>; var nodeVar296 : vec3<f32>; var nodeVar297 : vec3<f32>; var DirectSpecular : vec3<f32>; var nodeVar299 : vec3<f32>; var Light : vec3<f32>; var Output : vec4<f32>; 

	// flow
	// code
	

	// FLOW -> Color
	Color = vec4<f32>( NodeUniforms.nodeUniform0, 1.0 );
	
	
	// FLOW -> DiffuseColor
	DiffuseColor = Color;
	
	
	// FLOW -> OPACITY
	nodeVar2 = NodeUniforms.nodeUniform1;
	OPACITY = nodeVar2;
	
	DiffuseColor.a = DiffuseColor.a * OPACITY;
	
	
	// FLOW -> Metalness
	Metalness = NodeUniforms.nodeUniform2;
	
	DiffuseColor = vec4<f32>( DiffuseColor.rgb * ( 1.0 - Metalness ), DiffuseColor.a );
	
	
	// FLOW -> Roughness
	nodeVar5 = max( NodeUniforms.nodeUniform3, 0.0525 );
	nodeVar6 = dpdx( nodeVary0 );
	nodeVar7 = abs( nodeVar6 );
	nodeVar8 = dpdy( nodeVary0 );
	nodeVar9 = abs( nodeVar8 );
	nodeVar10 = max( nodeVar7, nodeVar9 );
	nodeVar11 = max( nodeVar10.x, nodeVar10.y );
	nodeVar12 = max( nodeVar11, nodeVar10.z );
	nodeVar13 = ( nodeVar5 + nodeVar12 );
	nodeVar14 = min( nodeVar13, 1.0 );
	Roughness = nodeVar14;
	
	
	// FLOW -> SpecularColor
	nodeVar16 = ( mix( vec3<f32>( 0.04 ), Color.rgb, Metalness ) );
	SpecularColor = nodeVar16;
	
	
	// FLOW -> TransformedNormalView
	nodeVar18 = dpdy( nodeVary1.xyz.xyz );
	nodeVar19 = normalize( nodeVary3 );
	nodeVar20 = cross( nodeVar18, nodeVar19 );
	nodeVar21 = dpdx( nodeVary5.xy );
	nodeVar22 = ( nodeVar20 * vec3<f32>( nodeVar21.x ) );
	nodeVar23 = dpdx( nodeVary1.xyz.xyz );
	nodeVar24 = cross( nodeVar19, nodeVar23 );
	nodeVar25 = dpdy( nodeVary5.xy );
	nodeVar26 = ( nodeVar24 * vec3<f32>( nodeVar25.x ) );
	nodeVar27 = ( nodeVar22 + nodeVar26 );
	nodeVar28 = ( textureSample( nodeUniform6, nodeUniform6_sampler, nodeVary5 ) * vec4<f32>( vec3<f32>( 2.0 ), 1.0 ) );
	nodeVar29 = ( nodeVar28 - vec4<f32>( vec3<f32>( 1.0 ), 1.0 ) );
	nodeVar31 = dot( nodeVar27, nodeVar27 );
	nodeVar32 = ( nodeVar20 * vec3<f32>( nodeVar21.y ) );
	nodeVar33 = ( nodeVar24 * vec3<f32>( nodeVar25.y ) );
	nodeVar34 = ( nodeVar32 + nodeVar33 );
	nodeVar35 = dot( nodeVar34, nodeVar34 );
	nodeVar36 = max( nodeVar31, nodeVar35 );
	nodeVar37 = ( nodeVar36 == 0.0 );
	if ( nodeVar37 ) {

		nodeVar30 = 0.0;

	} else {

		nodeVar30 = ( 1.0 * inversesqrt( max( dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), nodeVar19 ) * vec3<f32>( nodeVar21.x ) ) + ( cross( nodeVar19, dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( nodeVar25.x ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), nodeVar19 ) * vec3<f32>( nodeVar21.x ) ) + ( cross( nodeVar19, dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( nodeVar25.x ) ) ) ), dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), nodeVar19 ) * vec3<f32>( nodeVar21.y ) ) + ( cross( nodeVar19, dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( nodeVar25.y ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), nodeVar19 ) * vec3<f32>( nodeVar21.y ) ) + ( cross( nodeVar19, dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( nodeVar25.y ) ) ) ) ) ) );

	};
	nodeVar38 = ( nodeVar29.x * nodeVar30 );
	nodeVar39 = ( nodeVar27 * vec3<f32>( nodeVar38 ) );
	nodeVar40 = ( nodeVar29.y * nodeVar30 );
	nodeVar41 = ( nodeVar34 * vec3<f32>( nodeVar40 ) );
	nodeVar42 = ( nodeVar19 * vec3<f32>( nodeVar29.z ) );
	nodeVar43 = ( nodeVar41 + nodeVar42 );
	nodeVar44 = ( nodeVar39 + nodeVar43 );
	nodeVar45 = normalize( nodeVar44 );
	nodeVar46 = nodeVar45;
	TransformedNormalView = nodeVar46;
	
	
	// FLOW -> Light
	nodeVar48 = ( NodeUniforms.nodeUniform8 - nodeVary1.xyz );
	nodeVar49 = normalize( nodeVar48 );
	nodeVar50 = dot( TransformedNormalView, nodeVar49 );
	nodeVar51 = clamp( nodeVar50, 0.0, 1.0 );
	nodeVar53 = ( NodeUniforms.nodeUniform10 > 0.0 );
	nodeVar54 = ( NodeUniforms.nodeUniform11 > 0.0 );
	nodeVar55 = ( nodeVar53 && nodeVar54 );
	if ( nodeVar55 ) {

		nodeVar52 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform10 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform11 );

	} else {

		nodeVar52 = 1.0;

	};
	nodeVar56 = ( NodeUniforms.nodeUniform9 * vec3<f32>( nodeVar52 ) );
	nodeVar57 = ( vec3<f32>( nodeVar51 ) * nodeVar56 );
	nodeVar58 = ( nodeVar57 * vec3<f32>( 3.141592653589793 ) );
	nodeVar59 = ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz );
	nodeVar60 = ( nodeVar58 * nodeVar59 );
	nodeVar61 = ( NodeUniforms.nodeUniform7 + nodeVar60 );
	nodeVar62 = ( NodeUniforms.nodeUniform12 - nodeVary1.xyz );
	nodeVar63 = normalize( nodeVar62 );
	nodeVar64 = dot( TransformedNormalView, nodeVar63 );
	nodeVar65 = clamp( nodeVar64, 0.0, 1.0 );
	nodeVar67 = ( NodeUniforms.nodeUniform14 > 0.0 );
	nodeVar68 = ( NodeUniforms.nodeUniform15 > 0.0 );
	nodeVar69 = ( nodeVar67 && nodeVar68 );
	if ( nodeVar69 ) {

		nodeVar66 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform14 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform15 );

	} else {

		nodeVar66 = 1.0;

	};
	nodeVar70 = ( NodeUniforms.nodeUniform13 * vec3<f32>( nodeVar66 ) );
	nodeVar71 = ( vec3<f32>( nodeVar65 ) * nodeVar70 );
	nodeVar72 = ( nodeVar71 * vec3<f32>( 3.141592653589793 ) );
	nodeVar73 = ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz );
	nodeVar74 = ( nodeVar72 * nodeVar73 );
	nodeVar75 = ( nodeVar61 + nodeVar74 );
	nodeVar76 = ( NodeUniforms.nodeUniform16 - nodeVary1.xyz );
	nodeVar77 = normalize( nodeVar76 );
	nodeVar78 = dot( TransformedNormalView, nodeVar77 );
	nodeVar79 = clamp( nodeVar78, 0.0, 1.0 );
	nodeVar81 = ( NodeUniforms.nodeUniform18 > 0.0 );
	nodeVar82 = ( NodeUniforms.nodeUniform19 > 0.0 );
	nodeVar83 = ( nodeVar81 && nodeVar82 );
	if ( nodeVar83 ) {

		nodeVar80 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform18 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform19 );

	} else {

		nodeVar80 = 1.0;

	};
	nodeVar84 = ( NodeUniforms.nodeUniform17 * vec3<f32>( nodeVar80 ) );
	nodeVar85 = ( vec3<f32>( nodeVar79 ) * nodeVar84 );
	nodeVar86 = ( nodeVar85 * vec3<f32>( 3.141592653589793 ) );
	nodeVar87 = ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz );
	nodeVar88 = ( nodeVar86 * nodeVar87 );
	nodeVar89 = ( nodeVar75 + nodeVar88 );
	nodeVar90 = ( NodeUniforms.nodeUniform20 - nodeVary1.xyz );
	nodeVar91 = normalize( nodeVar90 );
	nodeVar92 = dot( TransformedNormalView, nodeVar91 );
	nodeVar93 = clamp( nodeVar92, 0.0, 1.0 );
	nodeVar95 = ( NodeUniforms.nodeUniform22 > 0.0 );
	nodeVar96 = ( NodeUniforms.nodeUniform23 > 0.0 );
	nodeVar97 = ( nodeVar95 && nodeVar96 );
	if ( nodeVar97 ) {

		nodeVar94 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform22 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform23 );

	} else {

		nodeVar94 = 1.0;

	};
	nodeVar98 = ( NodeUniforms.nodeUniform21 * vec3<f32>( nodeVar94 ) );
	nodeVar99 = ( vec3<f32>( nodeVar93 ) * nodeVar98 );
	nodeVar100 = ( nodeVar99 * vec3<f32>( 3.141592653589793 ) );
	nodeVar101 = ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz );
	nodeVar102 = ( nodeVar100 * nodeVar101 );
	nodeVar103 = ( nodeVar89 + nodeVar102 );
	DirectDiffuse = nodeVar103;
	nodeVar105 = normalize( nodeVary6 );
	nodeVar106 = nodeVar49;
	nodeVar107 = ( nodeVar106 + nodeVar105 );
	nodeVar108 = normalize( nodeVar107 );
	nodeVar109 = dot( nodeVar105, nodeVar108 );
	nodeVar110 = clamp( nodeVar109, 0.0, 1.0 );
	nodeVar111 = ( -5.55473 * nodeVar110 );
	nodeVar112 = ( nodeVar111 - 6.98316 );
	nodeVar113 = ( nodeVar112 * nodeVar110 );
	nodeVar114 = exp2( nodeVar113 );
	nodeVar115 = ( 1.0 - nodeVar114 );
	nodeVar116 = ( SpecularColor * vec3<f32>( nodeVar115 ) );
	nodeVar117 = ( 1.0 * nodeVar114 );
	nodeVar118 = ( nodeVar116 + vec3<f32>( nodeVar117 ) );
	nodeVar119 = dot( TransformedNormalView, nodeVar106 );
	nodeVar120 = clamp( nodeVar119, 0.0, 1.0 );
	nodeVar121 = pow( Roughness, 2.0 );
	nodeVar122 = pow( nodeVar121, 2.0 );
	nodeVar123 = ( 1.0 - nodeVar122 );
	nodeVar124 = dot( TransformedNormalView, nodeVar105 );
	nodeVar125 = clamp( nodeVar124, 0.0, 1.0 );
	nodeVar126 = pow( nodeVar125, 2.0 );
	nodeVar127 = ( nodeVar123 * nodeVar126 );
	nodeVar128 = ( nodeVar122 + nodeVar127 );
	nodeVar129 = sqrt( nodeVar128 );
	nodeVar130 = ( nodeVar120 * nodeVar129 );
	nodeVar131 = ( 1.0 - nodeVar122 );
	nodeVar132 = pow( nodeVar120, 2.0 );
	nodeVar133 = ( nodeVar131 * nodeVar132 );
	nodeVar134 = ( nodeVar122 + nodeVar133 );
	nodeVar135 = sqrt( nodeVar134 );
	nodeVar136 = ( nodeVar125 * nodeVar135 );
	nodeVar137 = ( nodeVar130 + nodeVar136 );
	nodeVar138 = max( nodeVar137, 0.000001 );
	nodeVar139 = ( 0.5 / nodeVar138 );
	nodeVar140 = pow( nodeVar121, 2.0 );
	nodeVar141 = dot( TransformedNormalView, nodeVar108 );
	nodeVar142 = clamp( nodeVar141, 0.0, 1.0 );
	nodeVar143 = pow( nodeVar142, 2.0 );
	nodeVar144 = ( nodeVar140 - 1.0 );
	nodeVar145 = ( nodeVar143 * nodeVar144 );
	nodeVar146 = ( nodeVar145 + 1.0 );
	nodeVar147 = pow( nodeVar146, 2.0 );
	nodeVar148 = ( nodeVar140 / nodeVar147 );
	nodeVar149 = ( 0.3183098861837907 * nodeVar148 );
	nodeVar150 = ( nodeVar139 * nodeVar149 );
	nodeVar151 = ( nodeVar118 * vec3<f32>( nodeVar150 ) );
	nodeVar152 = ( nodeVar58 * nodeVar151 );
	nodeVar153 = ( NodeUniforms.nodeUniform24 + nodeVar152 );
	nodeVar154 = nodeVar63;
	nodeVar155 = ( nodeVar154 + nodeVar105 );
	nodeVar156 = normalize( nodeVar155 );
	nodeVar157 = dot( nodeVar105, nodeVar156 );
	nodeVar158 = clamp( nodeVar157, 0.0, 1.0 );
	nodeVar159 = ( -5.55473 * nodeVar158 );
	nodeVar160 = ( nodeVar159 - 6.98316 );
	nodeVar161 = ( nodeVar160 * nodeVar158 );
	nodeVar162 = exp2( nodeVar161 );
	nodeVar163 = ( 1.0 - nodeVar162 );
	nodeVar164 = ( SpecularColor * vec3<f32>( nodeVar163 ) );
	nodeVar165 = ( 1.0 * nodeVar162 );
	nodeVar166 = ( nodeVar164 + vec3<f32>( nodeVar165 ) );
	nodeVar167 = dot( TransformedNormalView, nodeVar154 );
	nodeVar168 = clamp( nodeVar167, 0.0, 1.0 );
	nodeVar169 = pow( Roughness, 2.0 );
	nodeVar170 = pow( nodeVar169, 2.0 );
	nodeVar171 = ( 1.0 - nodeVar170 );
	nodeVar172 = dot( TransformedNormalView, nodeVar105 );
	nodeVar173 = clamp( nodeVar172, 0.0, 1.0 );
	nodeVar174 = pow( nodeVar173, 2.0 );
	nodeVar175 = ( nodeVar171 * nodeVar174 );
	nodeVar176 = ( nodeVar170 + nodeVar175 );
	nodeVar177 = sqrt( nodeVar176 );
	nodeVar178 = ( nodeVar168 * nodeVar177 );
	nodeVar179 = ( 1.0 - nodeVar170 );
	nodeVar180 = pow( nodeVar168, 2.0 );
	nodeVar181 = ( nodeVar179 * nodeVar180 );
	nodeVar182 = ( nodeVar170 + nodeVar181 );
	nodeVar183 = sqrt( nodeVar182 );
	nodeVar184 = ( nodeVar173 * nodeVar183 );
	nodeVar185 = ( nodeVar178 + nodeVar184 );
	nodeVar186 = max( nodeVar185, 0.000001 );
	nodeVar187 = ( 0.5 / nodeVar186 );
	nodeVar188 = pow( nodeVar169, 2.0 );
	nodeVar189 = dot( TransformedNormalView, nodeVar156 );
	nodeVar190 = clamp( nodeVar189, 0.0, 1.0 );
	nodeVar191 = pow( nodeVar190, 2.0 );
	nodeVar192 = ( nodeVar188 - 1.0 );
	nodeVar193 = ( nodeVar191 * nodeVar192 );
	nodeVar194 = ( nodeVar193 + 1.0 );
	nodeVar195 = pow( nodeVar194, 2.0 );
	nodeVar196 = ( nodeVar188 / nodeVar195 );
	nodeVar197 = ( 0.3183098861837907 * nodeVar196 );
	nodeVar198 = ( nodeVar187 * nodeVar197 );
	nodeVar199 = ( nodeVar166 * vec3<f32>( nodeVar198 ) );
	nodeVar200 = ( nodeVar72 * nodeVar199 );
	nodeVar201 = ( nodeVar153 + nodeVar200 );
	nodeVar202 = nodeVar77;
	nodeVar203 = ( nodeVar202 + nodeVar105 );
	nodeVar204 = normalize( nodeVar203 );
	nodeVar205 = dot( nodeVar105, nodeVar204 );
	nodeVar206 = clamp( nodeVar205, 0.0, 1.0 );
	nodeVar207 = ( -5.55473 * nodeVar206 );
	nodeVar208 = ( nodeVar207 - 6.98316 );
	nodeVar209 = ( nodeVar208 * nodeVar206 );
	nodeVar210 = exp2( nodeVar209 );
	nodeVar211 = ( 1.0 - nodeVar210 );
	nodeVar212 = ( SpecularColor * vec3<f32>( nodeVar211 ) );
	nodeVar213 = ( 1.0 * nodeVar210 );
	nodeVar214 = ( nodeVar212 + vec3<f32>( nodeVar213 ) );
	nodeVar215 = dot( TransformedNormalView, nodeVar202 );
	nodeVar216 = clamp( nodeVar215, 0.0, 1.0 );
	nodeVar217 = pow( Roughness, 2.0 );
	nodeVar218 = pow( nodeVar217, 2.0 );
	nodeVar219 = ( 1.0 - nodeVar218 );
	nodeVar220 = dot( TransformedNormalView, nodeVar105 );
	nodeVar221 = clamp( nodeVar220, 0.0, 1.0 );
	nodeVar222 = pow( nodeVar221, 2.0 );
	nodeVar223 = ( nodeVar219 * nodeVar222 );
	nodeVar224 = ( nodeVar218 + nodeVar223 );
	nodeVar225 = sqrt( nodeVar224 );
	nodeVar226 = ( nodeVar216 * nodeVar225 );
	nodeVar227 = ( 1.0 - nodeVar218 );
	nodeVar228 = pow( nodeVar216, 2.0 );
	nodeVar229 = ( nodeVar227 * nodeVar228 );
	nodeVar230 = ( nodeVar218 + nodeVar229 );
	nodeVar231 = sqrt( nodeVar230 );
	nodeVar232 = ( nodeVar221 * nodeVar231 );
	nodeVar233 = ( nodeVar226 + nodeVar232 );
	nodeVar234 = max( nodeVar233, 0.000001 );
	nodeVar235 = ( 0.5 / nodeVar234 );
	nodeVar236 = pow( nodeVar217, 2.0 );
	nodeVar237 = dot( TransformedNormalView, nodeVar204 );
	nodeVar238 = clamp( nodeVar237, 0.0, 1.0 );
	nodeVar239 = pow( nodeVar238, 2.0 );
	nodeVar240 = ( nodeVar236 - 1.0 );
	nodeVar241 = ( nodeVar239 * nodeVar240 );
	nodeVar242 = ( nodeVar241 + 1.0 );
	nodeVar243 = pow( nodeVar242, 2.0 );
	nodeVar244 = ( nodeVar236 / nodeVar243 );
	nodeVar245 = ( 0.3183098861837907 * nodeVar244 );
	nodeVar246 = ( nodeVar235 * nodeVar245 );
	nodeVar247 = ( nodeVar214 * vec3<f32>( nodeVar246 ) );
	nodeVar248 = ( nodeVar86 * nodeVar247 );
	nodeVar249 = ( nodeVar201 + nodeVar248 );
	nodeVar250 = nodeVar91;
	nodeVar251 = ( nodeVar250 + nodeVar105 );
	nodeVar252 = normalize( nodeVar251 );
	nodeVar253 = dot( nodeVar105, nodeVar252 );
	nodeVar254 = clamp( nodeVar253, 0.0, 1.0 );
	nodeVar255 = ( -5.55473 * nodeVar254 );
	nodeVar256 = ( nodeVar255 - 6.98316 );
	nodeVar257 = ( nodeVar256 * nodeVar254 );
	nodeVar258 = exp2( nodeVar257 );
	nodeVar259 = ( 1.0 - nodeVar258 );
	nodeVar260 = ( SpecularColor * vec3<f32>( nodeVar259 ) );
	nodeVar261 = ( 1.0 * nodeVar258 );
	nodeVar262 = ( nodeVar260 + vec3<f32>( nodeVar261 ) );
	nodeVar263 = dot( TransformedNormalView, nodeVar250 );
	nodeVar264 = clamp( nodeVar263, 0.0, 1.0 );
	nodeVar265 = pow( Roughness, 2.0 );
	nodeVar266 = pow( nodeVar265, 2.0 );
	nodeVar267 = ( 1.0 - nodeVar266 );
	nodeVar268 = dot( TransformedNormalView, nodeVar105 );
	nodeVar269 = clamp( nodeVar268, 0.0, 1.0 );
	nodeVar270 = pow( nodeVar269, 2.0 );
	nodeVar271 = ( nodeVar267 * nodeVar270 );
	nodeVar272 = ( nodeVar266 + nodeVar271 );
	nodeVar273 = sqrt( nodeVar272 );
	nodeVar274 = ( nodeVar264 * nodeVar273 );
	nodeVar275 = ( 1.0 - nodeVar266 );
	nodeVar276 = pow( nodeVar264, 2.0 );
	nodeVar277 = ( nodeVar275 * nodeVar276 );
	nodeVar278 = ( nodeVar266 + nodeVar277 );
	nodeVar279 = sqrt( nodeVar278 );
	nodeVar280 = ( nodeVar269 * nodeVar279 );
	nodeVar281 = ( nodeVar274 + nodeVar280 );
	nodeVar282 = max( nodeVar281, 0.000001 );
	nodeVar283 = ( 0.5 / nodeVar282 );
	nodeVar284 = pow( nodeVar265, 2.0 );
	nodeVar285 = dot( TransformedNormalView, nodeVar252 );
	nodeVar286 = clamp( nodeVar285, 0.0, 1.0 );
	nodeVar287 = pow( nodeVar286, 2.0 );
	nodeVar288 = ( nodeVar284 - 1.0 );
	nodeVar289 = ( nodeVar287 * nodeVar288 );
	nodeVar290 = ( nodeVar289 + 1.0 );
	nodeVar291 = pow( nodeVar290, 2.0 );
	nodeVar292 = ( nodeVar284 / nodeVar291 );
	nodeVar293 = ( 0.3183098861837907 * nodeVar292 );
	nodeVar294 = ( nodeVar283 * nodeVar293 );
	nodeVar295 = ( nodeVar262 * vec3<f32>( nodeVar294 ) );
	nodeVar296 = ( nodeVar100 * nodeVar295 );
	nodeVar297 = ( nodeVar249 + nodeVar296 );
	DirectSpecular = nodeVar297;
	nodeVar299 = ( DirectDiffuse + DirectSpecular );
	Light = nodeVar299;
	
	
	// FLOW -> Output
	Output = vec4<f32>( Light.xyz.xyz, DiffuseColor.w );
	
	// FLOW RESULT
	return Output;

}

After

// Three.js r138dev - NodeMaterial System


// uniforms
@group( 0 ) @binding( 1 ) var nodeUniform6_sampler : sampler; @group( 0 ) @binding( 2 ) var nodeUniform6 : texture_2d<f32>; 
struct NodeUniformsStruct {

	nodeUniform0 : vec3<f32>;
	nodeUniform1 : f32;
	nodeUniform2 : f32;
	nodeUniform3 : f32;
	nodeUniform7 : vec3<f32>;
	nodeUniform8 : vec3<f32>;
	nodeUniform9 : vec3<f32>;
	nodeUniform10 : f32;
	nodeUniform11 : f32;
	nodeUniform12 : vec3<f32>;
	nodeUniform13 : vec3<f32>;
	nodeUniform14 : f32;
	nodeUniform15 : f32;
	nodeUniform16 : vec3<f32>;
	nodeUniform17 : vec3<f32>;
	nodeUniform18 : f32;
	nodeUniform19 : f32;
	nodeUniform20 : vec3<f32>;
	nodeUniform21 : vec3<f32>;
	nodeUniform22 : f32;
	nodeUniform23 : f32;
	nodeUniform24 : vec3<f32>;

};
@binding( 3 ) @group( 0 )
var<uniform> NodeUniforms : NodeUniformsStruct;

// codes

fn inversesqrt( x : f32 ) -> f32 {

	return 1.0 / sqrt( x );

}



@stage( fragment )
fn main( 
	@location( 0 ) nodeVary0 : vec3<f32>,
	@location( 1 ) nodeVary1 : vec4<f32>,
	@location( 2 ) nodeVary2 : vec3<f32>,
	@location( 3 ) nodeVary3 : vec3<f32>,
	@location( 4 ) nodeVary4 : vec3<f32>,
	@location( 5 ) nodeVary5 : vec2<f32>,
	@location( 6 ) nodeVary6 : vec3<f32>,
	@location( 7 ) nodeVary7 : vec4<f32>
 ) -> @location( 0 ) vec4<f32> {

	// vars
	var Color : vec4<f32>; var DiffuseColor : vec4<f32>; var nodeVar2 : f32; var OPACITY : f32; var Metalness : f32; var nodeVar5 : vec3<f32>; var nodeVar6 : vec3<f32>; var nodeVar7 : vec3<f32>; var nodeVar8 : vec3<f32>; var nodeVar9 : vec3<f32>; var Roughness : f32; var SpecularColor : vec3<f32>; var nodeVar12 : f32; var TransformedNormalView : vec3<f32>; var nodeVar14 : f32; var nodeVar15 : f32; var nodeVar16 : f32; var nodeVar17 : f32; var DirectDiffuse : vec3<f32>; var DirectSpecular : vec3<f32>; var Light : vec3<f32>; var Output : vec4<f32>; 

	// flow
	// code
	

	// FLOW -> Color
	Color = vec4<f32>( NodeUniforms.nodeUniform0, 1.0 );
	
	
	// FLOW -> DiffuseColor
	DiffuseColor = Color;
	
	
	// FLOW -> OPACITY
	nodeVar2 = NodeUniforms.nodeUniform1;
	OPACITY = nodeVar2;
	
	DiffuseColor.a = DiffuseColor.a * OPACITY;
	
	
	// FLOW -> Metalness
	Metalness = NodeUniforms.nodeUniform2;
	
	DiffuseColor = vec4<f32>( DiffuseColor.rgb * ( 1.0 - Metalness ), DiffuseColor.a );
	
	
	// FLOW -> Roughness
	nodeVar5 = dpdx( nodeVary0 );
	nodeVar6 = abs( nodeVar5 );
	nodeVar7 = dpdy( nodeVary0 );
	nodeVar8 = abs( nodeVar7 );
	nodeVar9 = max( nodeVar6, nodeVar8 );
	Roughness = min( ( max( NodeUniforms.nodeUniform3, 0.0525 ) + max( max( nodeVar9.x, nodeVar9.y ), nodeVar9.z ) ), 1.0 );
	
	
	// FLOW -> SpecularColor
	SpecularColor = ( mix( vec3<f32>( 0.04 ), Color.rgb, Metalness ) );
	
	
	// FLOW -> TransformedNormalView
	if ( ( max( dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).x ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).x ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).x ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).x ) ) ) ), dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).y ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).y ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).y ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).y ) ) ) ) ) == 0.0 ) ) {

		nodeVar12 = 0.0;

	} else {

		nodeVar12 = ( 1.0 * inversesqrt( max( dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).x ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).x ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).x ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).x ) ) ) ), dot( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).y ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).y ) ) ), ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).y ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).y ) ) ) ) ) ) );

	};
	TransformedNormalView = normalize( ( ( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).x ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).x ) ) ) * ( ( ( textureSample( nodeUniform6, nodeUniform6_sampler, nodeVary5 ) * vec4<f32>( vec3<f32>( 2.0 ), 1.0 ) ) - vec4<f32>( vec3<f32>( 1.0 ), 1.0 ) ).x * nodeVar12 ) ) + ( ( ( ( cross( dpdy( nodeVary1.xyz.xyz ), normalize( nodeVary3 ) ) * vec3<f32>( dpdx( nodeVary5.xy ).y ) ) + ( cross( normalize( nodeVary3 ), dpdx( nodeVary1.xyz.xyz ) ) * vec3<f32>( dpdy( nodeVary5.xy ).y ) ) ) * ( ( ( textureSample( nodeUniform6, nodeUniform6_sampler, nodeVary5 ) * vec4<f32>( vec3<f32>( 2.0 ), 1.0 ) ) - vec4<f32>( vec3<f32>( 1.0 ), 1.0 ) ).y * nodeVar12 ) ) + ( normalize( nodeVary3 ) * vec3<f32>( ( ( textureSample( nodeUniform6, nodeUniform6_sampler, nodeVary5 ) * vec4<f32>( vec3<f32>( 2.0 ), 1.0 ) ) - vec4<f32>( vec3<f32>( 1.0 ), 1.0 ) ).z ) ) ) ) );
	
	
	// FLOW -> Light
	if ( ( ( NodeUniforms.nodeUniform10 > 0.0 ) && ( NodeUniforms.nodeUniform11 > 0.0 ) ) ) {

		nodeVar14 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform10 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform11 );

	} else {

		nodeVar14 = 1.0;

	};
	if ( ( ( NodeUniforms.nodeUniform14 > 0.0 ) && ( NodeUniforms.nodeUniform15 > 0.0 ) ) ) {

		nodeVar15 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform14 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform15 );

	} else {

		nodeVar15 = 1.0;

	};
	if ( ( ( NodeUniforms.nodeUniform18 > 0.0 ) && ( NodeUniforms.nodeUniform19 > 0.0 ) ) ) {

		nodeVar16 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform18 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform19 );

	} else {

		nodeVar16 = 1.0;

	};
	if ( ( ( NodeUniforms.nodeUniform22 > 0.0 ) && ( NodeUniforms.nodeUniform23 > 0.0 ) ) ) {

		nodeVar17 = pow( clamp( ( ( ( -length( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ) / NodeUniforms.nodeUniform22 ) + 1.0 ), 0.0, 1.0 ), NodeUniforms.nodeUniform23 );

	} else {

		nodeVar17 = 1.0;

	};
	DirectDiffuse = ( ( ( ( NodeUniforms.nodeUniform7 + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform9 * vec3<f32>( nodeVar14 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform13 * vec3<f32>( nodeVar15 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform17 * vec3<f32>( nodeVar16 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform21 * vec3<f32>( nodeVar17 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( vec3<f32>( 0.3183098861837907 ) * DiffuseColor.xyz ) ) );
	DirectSpecular = ( ( ( ( NodeUniforms.nodeUniform24 + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform9 * vec3<f32>( nodeVar14 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( ( ( SpecularColor * ( 1.0 - exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) + ( 1.0 * exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) * ( ( 0.5 / max( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) + ( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) ), 0.000001 ) ) * ( 0.3183098861837907 * ( pow( pow( Roughness, 2.0 ), 2.0 ) / pow( ( ( pow( clamp( dot( TransformedNormalView, normalize( ( normalize( ( NodeUniforms.nodeUniform8 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ), 2.0 ) * ( pow( pow( Roughness, 2.0 ), 2.0 ) - 1.0 ) ) + 1.0 ), 2.0 ) ) ) ) ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform13 * vec3<f32>( nodeVar15 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( ( ( SpecularColor * ( 1.0 - exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) + ( 1.0 * exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) * ( ( 0.5 / max( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) + ( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) ), 0.000001 ) ) * ( 0.3183098861837907 * ( pow( pow( Roughness, 2.0 ), 2.0 ) / pow( ( ( pow( clamp( dot( TransformedNormalView, normalize( ( normalize( ( NodeUniforms.nodeUniform12 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ), 2.0 ) * ( pow( pow( Roughness, 2.0 ), 2.0 ) - 1.0 ) ) + 1.0 ), 2.0 ) ) ) ) ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform17 * vec3<f32>( nodeVar16 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( ( ( SpecularColor * ( 1.0 - exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) + ( 1.0 * exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) * ( ( 0.5 / max( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) + ( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) ), 0.000001 ) ) * ( 0.3183098861837907 * ( pow( pow( Roughness, 2.0 ), 2.0 ) / pow( ( ( pow( clamp( dot( TransformedNormalView, normalize( ( normalize( ( NodeUniforms.nodeUniform16 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ), 2.0 ) * ( pow( pow( Roughness, 2.0 ), 2.0 ) - 1.0 ) ) + 1.0 ), 2.0 ) ) ) ) ) ) ) + ( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * ( NodeUniforms.nodeUniform21 * vec3<f32>( nodeVar17 ) ) ) * vec3<f32>( 3.141592653589793 ) ) * ( ( ( SpecularColor * ( 1.0 - exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) + ( 1.0 * exp2( ( ( ( -5.55473 * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) - 6.98316 ) * clamp( dot( normalize( nodeVary6 ), normalize( ( normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ) ) ) ) ) * ( ( 0.5 / max( ( ( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) + ( clamp( dot( TransformedNormalView, normalize( nodeVary6 ) ), 0.0, 1.0 ) * sqrt( ( pow( pow( Roughness, 2.0 ), 2.0 ) + ( ( 1.0 - pow( pow( Roughness, 2.0 ), 2.0 ) ) * pow( clamp( dot( TransformedNormalView, normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) ), 0.0, 1.0 ), 2.0 ) ) ) ) ) ), 0.000001 ) ) * ( 0.3183098861837907 * ( pow( pow( Roughness, 2.0 ), 2.0 ) / pow( ( ( pow( clamp( dot( TransformedNormalView, normalize( ( normalize( ( NodeUniforms.nodeUniform20 - nodeVary1.xyz ) ) + normalize( nodeVary6 ) ) ) ), 0.0, 1.0 ), 2.0 ) * ( pow( pow( Roughness, 2.0 ), 2.0 ) - 1.0 ) ) + 1.0 ), 2.0 ) ) ) ) ) ) );
	Light = ( DirectDiffuse + DirectSpecular );
	
	
	// FLOW -> Output
	Output = vec4<f32>( Light.xyz.xyz, DiffuseColor.w );
	
	// FLOW RESULT
	return Output;

}

This contribution is funded by Google via Igalia.

@sunag sunag added this to the r138 milestone Feb 12, 2022
@mrdoob mrdoob merged commit d9c4c8e into mrdoob:dev Feb 14, 2022
@mrdoob
Copy link
Owner

mrdoob commented Feb 14, 2022

Thanks!

donmccurdy pushed a commit to donmccurdy/three.js that referenced this pull request Mar 10, 2022
* ShaderNode: fix use of swizzle in some nodes

* cleanup

* prevent use of vec4

* fix conversion format

* add Node.analyze()

* TempNode: not created var if it's is used only once
@sunag sunag deleted the dev-analyze branch November 17, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants