Download

HLSL Custom Code not working

My code is here


#pragma once

cbuffer cb11 : register(b11)
{
float4 cb11[24];
}

cbuffer cb12 : register(b12)
{
float4 cb12[14];
}




#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main(
float4 v0 : POSITION0,
float2 v1 : TEXCOORD0,
float3 v2 : NORMAL0,
float4 v3 : TANGENT0,
float2 v4 : TEXCOORD2,
out float4 o0 : TEXCOORD0,
out float4 o1 : TEXCOORD1,
out float4 o2 : TEXCOORD2,
out float4 o3 : TEXCOORD3,
out float3 o4 : TEXCOORD4,
out float4 o5 : SV_POSITION0)
{
float4 r0,r1,r2,r3,r4;
uint4 bitmask, uiDest;
float4 fDest;

r0.x = dot(v2.xyz, v2.xyz);
r0.x = rsqrt(r0.x);
r0.xyz = v2.xyz * r0.xxx;
r0.w = v0.w * 32767 + 0.100000001;
r0.w = (uint)r0.w;
r1.xy = mad(int2(3,3), (int2)r0.ww, int2(1,2));
r0.w = (int)r0.w * 3;
r2.z = dot(cb11[r1.y+8].xyz, r0.xyz);
r1.z = saturate(cb11[7].z * r2.z);
o0.w = saturate(cb11[7].w + r1.z);
r2.x = dot(cb11[r0.w+8].xyz, r0.xyz);
r2.y = dot(cb11[r1.x+8].xyz, r0.xyz);
o0.xyz = r2.xyz;
r0.x = dot(cb11[r0.w+8].xyz, v3.xyz);
r0.y = dot(cb11[r1.x+8].xyz, v3.xyz);
r0.z = dot(cb11[r1.y+8].xyz, v3.xyz);
o1.xyz = r0.xyz;
r3.xyz = v0.xyz * cb11[5].www + cb11[5].xyz;
o1.w = r3.z;
r4.xyz = r2.zxy * r0.yzx;
r0.xyz = r2.yzx * r0.zxy + -r4.xyz;
o2.xyz = v3.www * r0.xyz;
r0.xy = v1.xy * cb11[6].xy + cb11[6].zw;
o3.zw = v4.xy * r0.xy;
o3.xy = r0.xy;
r2.w = cb11[r0.w+8].w + -cb12[7].x;
r2.xyz = cb11[r0.w+8].xyz;
r3.w = 1;
r0.x = dot(r2.xyzw, r3.xyzw);
r2.w = cb11[r1.x+8].w + -cb12[7].y;
r2.xyz = cb11[r1.x+8].xyz;
r0.y = dot(r2.xyzw, r3.xyzw);
r2.w = cb11[r1.y+8].w + -cb12[7].z;
r2.xyz = cb11[r1.y+8].xyz;
r0.z = dot(r2.xyzw, r3.xyzw);
o4.xyz = cb12[7].xyz + r0.xyz;
r1.xyzw = cb12[1].xyzw * r0.yyyy;
r1.xyzw = cb12[0].xyzw * r0.xxxx + r1.xyzw;
r0.xyzw = cb12[2].xyzw * r0.zzzz + r1.xyzw;
o5.xyzw = cb12[13].xyzw + r0.xyzw;
return;
}

I’ve tried entering it in the custom code area as well as importing a .usf with this inside but it doesn’t accept it. Are there specific changes necessary for this to work? The HLSL documentation is not great/got removed in the wiki.

The HLSL custom node is made for adding HLSL code to the Unreal shader code in form of a function. You can imagine a single node like a single HLSL function.

You should not use #pragma once and the main().