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

more hlsl fixes for unity. got through the lighting examples #107

Merged
merged 4 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generative/random.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ examples:
#define RANDOM_SCALE float4(443.897, 441.423, 0.0973, 0.1099)
#endif
#endif
#ifndef RANDOM_SCALE_4
#define RANDOM_SCALE_4 float4(443.897, 441.423, .0973, 1.6334)
#endif

#ifndef FNC_RANDOM
#define FNC_RANDOM
Expand Down
2 changes: 1 addition & 1 deletion lighting/envMap.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ float3 envMap(float3 _normal, float _roughness, float _metallic) {
float3 envMap(float3 _normal, float _roughness) {
return envMap(_normal, _roughness, 1.0);
}
#endif
#endif
3 changes: 2 additions & 1 deletion lighting/fresnelReflection.hlsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fresnel.hlsl"
#include "fakeCube.hlsl"
#include "sphericalHarmonics.hlsl"
#include "envMap.hlsl"

/*
original_author: Patricio Gonzalez Vivo
Expand Down Expand Up @@ -37,4 +38,4 @@ float3 fresnelReflection(float3 R, float3 f0, float NoV) {
return reflectColor * frsnl;
}

#endif
#endif
3 changes: 2 additions & 1 deletion lighting/pbr.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "reflection.hlsl"
#include "common/specularAO.hlsl"
#include "common/envBRDFApprox.hlsl"
#include "envMap.hlsl"

/*
original_author: Patricio Gonzalez Vivo
Expand Down Expand Up @@ -122,4 +123,4 @@ float4 pbr(const Material _mat) {

return color;
}
#endif
#endif
4 changes: 2 additions & 2 deletions lighting/pbrClearCoat.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "fresnelReflection.hlsl"
#include "light/point.hlsl"
#include "light/directional.hlsl"
#include "envMap.hlsl"

#include "ior/2f0.hlsl"

Expand All @@ -10,7 +11,6 @@
#include "common/kelemen.hlsl"
#include "common/specularAO.hlsl"
#include "common/envBRDFApprox.hlsl"

/*
original_author: Patricio Gonzalez Vivo
description: simple PBR shading model
Expand Down Expand Up @@ -196,4 +196,4 @@ float4 pbrClearCoat(const Material _mat) {

return color;
}
#endif
#endif
4 changes: 2 additions & 2 deletions sdf/circleSDF.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ options:
CIRCLESDF_LENGHT_FNC(POS_UV) : function used to calculate the SDF, defaults to GLSL length function, use lengthSq for a different slope
*/

#ifndef CIRCLESDF_LENGHT_FNC
#define CIRCLESDF_LENGHT_FNC(POS_UV) length(POS_UV)
#ifndef CIRCLESDF_FNC
#define CIRCLESDF_FNC(POS_UV) length(POS_UV)
#endif

#ifndef FNC_CIRCLESDF
Expand Down
4 changes: 2 additions & 2 deletions sdf/starSDF.hlsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../math/const.hlsl"

#include "../space/scale.hlsl"
/*
original_author: Patricio Gonzalez Vivo
description: Returns a star-shaped sdf with V branches
Expand All @@ -18,7 +18,7 @@ float starSDF(in float2 st, in int V, in float s) {
float a = atan2(st.y, st.x) / TAU;
float seg = a * float(V);
a = ((floor(seg) + 0.5) / float(V) +
mix(s, -s, step(0.5, frac(seg))))
lerp(s, -s, step(0.5, frac(seg))))
* TAU;
return abs(dot(float2(cos(a), sin(a)),
st));
Expand Down
4 changes: 2 additions & 2 deletions sdf/superShapeSDF.hlsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include ../space/cart2polar.hlsl
#include "../space/cart2polar.hlsl"

/*
original_author: Kathy McGuiness
Expand Down Expand Up @@ -40,4 +40,4 @@ float superShapeSDF( in float2 st, in float s, in float a, in float b, in float
return superShapeSDF( st, float2(0.5, 0.5), s, a, b, n1, n2, n3, m );
#endif
}
#endif
#endif
2 changes: 1 addition & 1 deletion sdf/triSDF.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use: triSDF(<float2> st)

#ifndef FNC_TRISDF
#define FNC_TRISDF
float triSDF(in vec2 st) {
float triSDF(in float2 st) {
#ifdef CENTER_2D
st -= CENTER_2D;
st *= 5.0;
Expand Down
6 changes: 3 additions & 3 deletions space/brickTile.hlsl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "sqTile.glsl"

#include "sqTile.hlsl"
#include "../math/mod.hlsl"
/*
original_author: Patricio Gonzalez Vivo
description: brick a pattern
Expand All @@ -25,4 +25,4 @@ float4 brickTile(float4 tile) {
tile.x = frac(tile.x);
return tile;
}
#endif
#endif
6 changes: 3 additions & 3 deletions space/cart2polar.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ float2 cart2polar(in float2 st) {

float3 cart2polar( in float3 st) {
float r = length(st);
float theta = atan( length(st.xy), st.z);
float phi = atan(st.y, st.x);
float theta = atan2( length(st.xy), st.z);
float phi = atan2(st.y, st.x);
return float3(r, theta, phi);
}
#endif
#endif