Skip to content

Commit

Permalink
Shader fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
luboslenco committed Sep 16, 2024
1 parent 8947a4e commit 6ad8196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions base/sources/make_voxel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function make_voxel_run(data: shader_context_t) {
function make_voxel_source(): string {
let ds: f32 = make_material_get_displace_strength();
///if arm_direct3d11
return "#define vec3 float3 \
return "#define vec3 float3 \n\
uniform float4x4 W; \
uniform float3x3 N; \
Texture2D<float4> texpaint_pack; \
Expand All @@ -82,7 +82,7 @@ function make_voxel_source(): string {
struct SPIRV_Cross_Output { float4 svpos : SV_POSITION; }; \
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input) { \
SPIRV_Cross_Output stage_output; \
" + make_material_voxelgi_half_extents() + ")} \
" + make_material_voxelgi_half_extents() + " \
stage_output.svpos.xyz = mul(float4(stage_input.pos.xyz, 1.0), W).xyz / voxelgi_half_extents.xxx; \
float3 wnormal = normalize(mul(float3(stage_input.nor.xy, stage_input.pos.w), N)); \
float height = texpaint_pack.SampleLevel(_texpaint_pack_sampler, stage_input.tex, 0.0).a; \
Expand All @@ -91,7 +91,7 @@ function make_voxel_source(): string {
return stage_output; \
}";
///else
return "#version 450 \
return "#version 450 \n\
in vec4 pos; \
in vec2 nor; \
in vec2 tex; \
Expand All @@ -100,7 +100,7 @@ function make_voxel_source(): string {
uniform mat3 N; \
uniform sampler2D texpaint_pack; \
void main() { \
" + make_material_voxelgi_half_extents() + ")} \
" + make_material_voxelgi_half_extents() + " \
voxposition_geom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgi_half_extents; \
vec3 wnormal = normalize(N * vec3(nor.xy, pos.w)); \
float height = textureLod(texpaint_pack, tex, 0.0).a; \
Expand Down
6 changes: 3 additions & 3 deletions base/sources/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,11 @@ float ltc_evaluate(vec3 N, vec3 V, float dotnv, vec3 P, mat3 Minv, vec3 points0,

let str_get_pos_from_depth: string = " \
vec3 get_pos_from_depth(vec2 uv, mat4 invVP, textureArg(gbufferD)) { \
#if defined(HLSL) || defined(METAL) || defined(SPIRV) \
#if defined(HLSL) || defined(METAL) || defined(SPIRV) \n\
float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r; \
#else \
#else \n\
float depth = textureLod(gbufferD, uv, 0.0).r; \
#endif \
#endif \n\
vec4 wpos = vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0); \
wpos = mul(wpos, invVP); \
return wpos.xyz / wpos.w; \
Expand Down

0 comments on commit 6ad8196

Please sign in to comment.