-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(May either have no performance improvement and/or have possible Shader/Visual artefacts)
- Loading branch information
Showing
6 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/main/resources/assets/vulkanmod/shaders/basic/terrain_direct/terrain_direct.spvasm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Generator: Google Shaderc over Glslang; 11 | ||
; Bound: 72 | ||
; Schema: 0 | ||
OpCapability Shader | ||
%1 = OpExtInstImport "GLSL.std.450" | ||
OpMemoryModel Logical GLSL450 | ||
OpEntryPoint Vertex %4 "main" %gl_InstanceIndex %32 %43 %62 %64 %71 | ||
OpDecorate %gl_InstanceIndex BuiltIn InstanceIndex | ||
OpMemberDecorate %_struct_21 0 Offset 0 | ||
OpDecorate %_struct_21 Block | ||
OpDecorate %32 Location 0 | ||
OpMemberDecorate %_struct_41 0 BuiltIn Position | ||
OpMemberDecorate %_struct_41 1 BuiltIn PointSize | ||
OpMemberDecorate %_struct_41 2 BuiltIn ClipDistance | ||
OpMemberDecorate %_struct_41 3 BuiltIn CullDistance | ||
OpDecorate %_struct_41 Block | ||
OpMemberDecorate %_struct_45 0 ColMajor | ||
OpMemberDecorate %_struct_45 0 Offset 0 | ||
OpMemberDecorate %_struct_45 0 MatrixStride 16 | ||
OpDecorate %_struct_45 Block | ||
OpDecorate %47 DescriptorSet 0 | ||
OpDecorate %47 Binding 0 | ||
OpDecorate %62 Location 1 | ||
OpDecorate %64 Location 2 | ||
OpDecorate %71 Location 0 | ||
%void = OpTypeVoid | ||
%3 = OpTypeFunction %void | ||
%float = OpTypeFloat 32 | ||
%v3float = OpTypeVector %float 3 | ||
%int = OpTypeInt 32 1 | ||
%_ptr_Input_int = OpTypePointer Input %int | ||
%gl_InstanceIndex = OpVariable %_ptr_Input_int Input | ||
%uint = OpTypeInt 32 0 | ||
%v4float = OpTypeVector %float 4 | ||
%float_2032 = OpConstant %float 2032 | ||
%20 = OpConstantComposite %v3float %float_2032 %float_2032 %float_2032 | ||
%_struct_21 = OpTypeStruct %v3float | ||
%_ptr_PushConstant__struct_21 = OpTypePointer PushConstant %_struct_21 | ||
%23 = OpVariable %_ptr_PushConstant__struct_21 PushConstant | ||
%int_0 = OpConstant %int 0 | ||
%_ptr_PushConstant_v3float = OpTypePointer PushConstant %v3float | ||
%v3int = OpTypeVector %int 3 | ||
%_ptr_Input_v3int = OpTypePointer Input %v3int | ||
%32 = OpVariable %_ptr_Input_v3int Input | ||
%float_0_000526315765 = OpConstant %float 0.000526315765 | ||
%36 = OpConstantComposite %v3float %float_0_000526315765 %float_0_000526315765 %float_0_000526315765 | ||
%uint_1 = OpConstant %uint 1 | ||
%_arr_float_uint_1 = OpTypeArray %float %uint_1 | ||
%_struct_41 = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1 | ||
%_ptr_Output__struct_41 = OpTypePointer Output %_struct_41 | ||
%43 = OpVariable %_ptr_Output__struct_41 Output | ||
%mat4v4float = OpTypeMatrix %v4float 4 | ||
%_struct_45 = OpTypeStruct %mat4v4float | ||
%_ptr_Uniform__struct_45 = OpTypePointer Uniform %_struct_45 | ||
%47 = OpVariable %_ptr_Uniform__struct_45 Uniform | ||
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float | ||
%float_1 = OpConstant %float 1 | ||
%_ptr_Output_v4float = OpTypePointer Output %v4float | ||
%v2float = OpTypeVector %float 2 | ||
%_ptr_Output_v2float = OpTypePointer Output %v2float | ||
%62 = OpVariable %_ptr_Output_v2float Output | ||
%_ptr_Input_uint = OpTypePointer Input %uint | ||
%64 = OpVariable %_ptr_Input_uint Input | ||
%71 = OpVariable %_ptr_Output_v4float Output | ||
%4 = OpFunction %void None %3 | ||
%5 = OpLabel | ||
%13 = OpLoad %int %gl_InstanceIndex | ||
%15 = OpBitcast %uint %13 | ||
%17 = OpExtInst %v4float %1 UnpackSnorm4x8 %15 | ||
%18 = OpVectorShuffle %v3float %17 %17 0 1 2 | ||
%26 = OpAccessChain %_ptr_PushConstant_v3float %23 %int_0 | ||
%27 = OpLoad %v3float %26 | ||
%28 = OpExtInst %v3float %1 Fma %18 %20 %27 | ||
%33 = OpLoad %v3int %32 | ||
%34 = OpConvertSToF %v3float %33 | ||
%38 = OpExtInst %v3float %1 Fma %34 %36 %28 | ||
%49 = OpAccessChain %_ptr_Uniform_mat4v4float %47 %int_0 | ||
%50 = OpLoad %mat4v4float %49 | ||
%53 = OpCompositeExtract %float %38 0 | ||
%54 = OpCompositeExtract %float %38 1 | ||
%55 = OpCompositeExtract %float %38 2 | ||
%56 = OpCompositeConstruct %v4float %53 %54 %55 %float_1 | ||
%57 = OpMatrixTimesVector %v4float %50 %56 | ||
%59 = OpAccessChain %_ptr_Output_v4float %43 %int_0 | ||
OpStore %59 %57 | ||
%65 = OpLoad %uint %64 | ||
%66 = OpExtInst %v2float %1 UnpackUnorm2x16 %65 | ||
OpStore %62 %66 | ||
OpReturn | ||
OpFunctionEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 9 additions & 15 deletions
24
src/main/resources/assets/vulkanmod/shaders/include/light.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
//light.glsl | ||
#define MINECRAFT_LIGHT_POWER (0.6) | ||
#define MINECRAFT_AMBIENT_LIGHT (0.4) | ||
//#pragma once | ||
const float MINECRAFT_LIGHT_POWER = (0.6); | ||
const float MINECRAFT_AMBIENT_LIGHT = (0.4); | ||
|
||
vec4 minecraft_mix_light(vec3 lightDir0, vec3 lightDir1, vec3 normal, vec4 color) { | ||
lightDir0 = normalize(lightDir0); | ||
lightDir1 = normalize(lightDir1); | ||
float light0 = max(0.0, dot(lightDir0, normal)); | ||
float light1 = max(0.0, dot(lightDir1, normal)); | ||
float lightAccum = min(1.0, (light0 + light1) * MINECRAFT_LIGHT_POWER + MINECRAFT_AMBIENT_LIGHT); | ||
return vec4(color.rgb * lightAccum, color.a); | ||
float light0 = max(0.0, dot(normalize(lightDir0), normal)); | ||
float light1 = max(0.0, dot(normalize(lightDir1), normal)); | ||
color.rgb *= fma(light0 + light1, MINECRAFT_LIGHT_POWER, MINECRAFT_AMBIENT_LIGHT); //lightAccum | ||
return color; | ||
} | ||
|
||
vec4 minecraft_sample_lightmap(sampler2D lightMap, ivec2 uv) { | ||
return texture(lightMap, clamp(uv / 256.0, vec2(0.5 / 16.0), vec2(15.5 / 16.0))); | ||
return texelFetch(lightMap, bitfieldExtract(uv, 4, 8), 0); //return texture(lightMap, clamp(uv / 256.0, vec2(0.5 / 16.0), vec2(15.5 / 16.0))); | ||
} | ||
|
||
vec4 sample_lightmap(sampler2D lightMap, ivec2 uv) { | ||
return texelFetch(lightMap, bitfieldExtract(uv, 4, 8), 0); | ||
} | ||
|
||
vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { | ||
if (vertexDistance <= fogStart) { | ||
return inColor; | ||
} | ||
|
||
float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; | ||
return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); | ||
return (vertexDistance <= fogStart) ? inColor : mix(inColor, fogColor, min(smoothstep(fogStart, fogEnd, vertexDistance), 1.0) * fogColor.a); | ||
} |