lygia
/lighting
/raymarch
/render
)Default raymarching renderer
Dependencies:
lygia
/lighting
/raymarch
/cast
.glsl
lygia
/lighting
/raymarch
/ao
.glsl
lygia
/lighting
/raymarch
/normal
.glsl
lygia
/lighting
/raymarch
/shading
.glsl
lygia
/lighting
/raymarch
/fog
.glsl
Use:
<vec4> raymarchDefaultRender( in <vec3> rayOriging, in <vec3> rayDirection, in <vec3> cameraForward)
<vec4> raymarchDefaultRender( in <vec3> rayOriging, in <vec3> rayDirection, in <vec3> cameraForward, out <float> eyeDepth )
<vec4> raymarchDefaultRender( in <vec3> rayOriging, in <vec3> rayDirection, in <vec3> cameraForward, out <float> eyeDepth, out <Material> res )
<vec4> raymarchDefaultRender( in <vec3> rayOriging, in <vec3> rayDirection, in <vec3> cameraForward, out <vec3> eyeDepth, out <vec3> worldPosition, out <vec3> worldNormal )
#ifndef RAYMARCH_BACKGROUND
#define RAYMARCH_BACKGROUND vec3(0.0, 0.0, 0.0)
#endif
#ifndef FNC_RAYMARCH_DEFAULT
#define FNC_RAYMARCH_DEFAULT
vec4 raymarchDefaultRender( in vec3 rayOrigin, in vec3 rayDirection, vec3 cameraForward,
out float dist ,out float eyeDepth, out Material res) {
res = raymarchCast(rayOrigin, rayDirection);
float t = res.sdf;
vec3 worldPos = rayOrigin + t * rayDirection;
vec3 worldNormal = raymarchNormal( worldPos );
vec4 color = vec4(RAYMARCH_BACKGROUND, 0.0);
if (res.valid) {
res.position = worldPos;
res.normal = worldNormal;
res.ambientOcclusion = raymarchAO(res.position, res.normal);
ShadingData shadingData = shadingDataNew();
shadingData.V = -rayDirection;
color = RAYMARCH_SHADING_FNC(res, shadingData);
dist = t;
} else {
dist = RAYMARCH_MAX_DIST;
}
color.rgb = raymarchFog(color.rgb, t, rayOrigin, rayDirection);
#if defined(RAYMARCH_AOV)
// Eye-space depth. See https://www.shadertoy.com/view/4tByz3
eyeDepth = t * dot(rayDirection, cameraForward);
#else
eyeDepth = 0.0;
#endif
return color;
}
#endif
Dependencies:
lygia
/lighting
/raymarch
/cast
.glsl
lygia
/lighting
/raymarch
/ao
.glsl
lygia
/lighting
/raymarch
/normal
.glsl
lygia
/lighting
/raymarch
/shading
.glsl
lygia
/lighting
/raymarch
/fog
.glsl
Use:
<float4> raymarchDefaultRender( in <float3> rayOriging, in <float3> rayDirection, in <float3> cameraForward)
<float4> raymarchDefaultRender( in <float3> rayOriging, in <float3> rayDirection, in <float3> cameraForward, out <float> eyeDepth )
<float4> raymarchDefaultRender( in <float3> rayOriging, in <float3> rayDirection, in <float3> cameraForward, out <float> eyeDepth, out <Material> res )
<float4> raymarchDefaultRender( in <float3> rayOriging, in <float3> rayDirection, in <float3> cameraForward, out <float3> eyeDepth, out <float3> worldPosition, out <float3> worldNormal )
#ifndef RAYMARCH_BACKGROUND
#define RAYMARCH_BACKGROUND float3(0.0, 0.0, 0.0)
#endif
#ifndef FNC_RAYMARCH_DEFAULT
#define FNC_RAYMARCH_DEFAULT
float4 raymarchDefaultRender(in float3 rayOrigin, in float3 rayDirection, float3 cameraForward,
out float dist, out float eyeDepth, out Material res) {
res = raymarchCast(rayOrigin, rayDirection);
float t = res.sdf;
float3 worldPos = rayOrigin + t * rayDirection;
float3 worldNormal = raymarchNormal( worldPos );
float4 color = float4(RAYMARCH_BACKGROUND, 0.0);
if (res.valid) {
res.position = worldPos;
res.normal = worldNormal;
res.ambientOcclusion = raymarchAO(res.position, res.normal);
ShadingData shadingData = shadingDataNew();
shadingData.V = -rayDirection;
color = RAYMARCH_SHADING_FNC(res, shadingData);
dist = t;
}
else {
dist = RAYMARCH_MAX_DIST;
}
color.rgb = raymarchFog(color.rgb, t, rayOrigin, rayDirection);
#if defined(RAYMARCH_AOV)
// Eye-space depth. See https://www.shadertoy.com/view/4tByz3
eyeDepth = t * dot(rayDirection, cameraForward);
#else
eyeDepth = 0.0;
#endif
return color;
}
#endif
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository