Add shader-side handheld lights

This commit is contained in:
Xonk 2023-06-15 19:42:22 -04:00
parent 35ee91b5d0
commit e8d5d92bf8
6 changed files with 37 additions and 7 deletions

View File

@ -708,6 +708,7 @@ void LabEmission(
#include "lib/PhotonGTAO.glsl"
//////////////////////////////VOID MAIN//////////////////////////////

View File

@ -81,6 +81,7 @@ in vec3 velocity;
flat varying float blockID;
flat varying float EMISSIVE;
flat varying int LIGHTNING;
flat varying float HELD_ITEM_BRIGHTNESS;
#ifdef ENTITIES
#define ENTITY_PHYSICSMOD_SNOW 829925
@ -238,7 +239,12 @@ vec3 blackbody2(float Temp)
/* RENDERTARGETS: 1,7,8,15 */
void main() {
vec3 normal = normalMat.xyz;
#ifdef MC_NORMAL_MAP
@ -253,9 +259,16 @@ void main() {
vec3 fragpos = toScreenSpace(gl_FragCoord.xyz*vec3(texelSize/RENDER_SCALE,1.0)-vec3(vec2(tempOffset)*texelSize*0.5,0.0));
vec3 worldpos = mat3(gbufferModelViewInverse) * fragpos + gbufferModelViewInverse[3].xyz + cameraPosition;
float torchlightmap = lmtexcoord.z;
#ifdef Hand_Held_lights
if(HELD_ITEM_BRIGHTNESS > 0.0) torchlightmap = mix(torchlightmap, HELD_ITEM_BRIGHTNESS, clamp( max(1.0-length(fragpos)/10,0.0) * 0.7 ,0.0,1.0));
#endif
float lightmap = clamp( (lmtexcoord.w-0.8) * 10.0,0.,1.);
float rainfall = rainStrength ;
float Puddle_shape = 0.;
@ -441,7 +454,7 @@ void main() {
if(SpecularTex.g < 229.5/255.0) Albedo.rgb = mix(Albedo.rgb, vec3(0), Puddle_shape*porosity);
#endif
vec4 data1 = clamp(encode(viewToWorld(normal), lmtexcoord.zw),0.,1.0);
vec4 data1 = clamp(encode(viewToWorld(normal), vec2(torchlightmap,lmtexcoord.w)),0.,1.0);
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x),encodeVec2(Albedo.y,data1.y),encodeVec2(Albedo.z,data1.z),encodeVec2(data1.w,Albedo.w));
gl_FragData[1].a = 0.0;
@ -584,7 +597,9 @@ void main() {
//////////////////////////////// FINALIZE
////////////////////////////////
vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + lmtexcoord.zw), 0.0, 1.0);
// vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + lmtexcoord.zw), 0.0, 1.0);
vec4 data1 = clamp( encode(viewToWorld(normal), (blueNoise()*lmtexcoord.zw/30.0) + vec2(torchlightmap,lmtexcoord.w)), 0.0, 1.0);
gl_FragData[0] = vec4(encodeVec2(Albedo.x,data1.x), encodeVec2(Albedo.y,data1.y), encodeVec2(Albedo.z,data1.z), encodeVec2(data1.w,Albedo.w));
gl_FragData[1].a = 0.0;

View File

@ -46,6 +46,9 @@ attribute vec4 mc_Entity;
uniform int blockEntityId;
uniform int entityId;
uniform int heldItemId;
uniform int heldItemId2;
flat varying float HELD_ITEM_BRIGHTNESS;
flat varying float blockID;
flat varying int LIGHTNING;
@ -185,11 +188,13 @@ void main() {
vtexcoord.xy = sign(texcoordminusmid)*0.5+0.5;
#endif
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol
vec2 lmcoord = gl_MultiTexCoord1.xy / 255.0; // is this even correct? lol'
lmtexcoord.zw = lmcoord;
#ifdef MC_NORMAL_MAP
tangent = vec4(normalize(gl_NormalMatrix *at_tangent.rgb),at_tangent.w);
#endif
@ -216,7 +221,7 @@ void main() {
EMISSIVE = 0.0;
// normal block lightsources
if(mc_Entity.x == 10005) EMISSIVE = 0.5;
if(mc_Entity.x == 10005) EMISSIVE = 0.3;
// special cases light lightning and beacon beams...
#ifdef ENTITIES
@ -226,6 +231,14 @@ void main() {
/////// ----- SSS STUFF ----- ///////
SSSAMOUNT = 0.0;
HELD_ITEM_BRIGHTNESS = 0.0;
#ifdef Hand_Held_lights
if(heldItemId == 100 || heldItemId2 == 100) HELD_ITEM_BRIGHTNESS = 1.0;
#endif
#ifdef WORLD
/////// ----- SSS ON BLOCKS ----- ///////

1
shaders/item.properties Normal file
View File

@ -0,0 +1 @@
item.100 = glow_berries soul_lantern soul_torch conduit beacon sea_pickle sea_lantern glowstone torch redstone_torch jack_o_lantern magma_block lantern shroomlight end_rod lava_bucket

View File

@ -402,7 +402,7 @@ const float shadowDistanceRenderMul = -1.0; //[-1.0 1.0] THIS WILL BREAK SUBSURF
// -- RANDOM SHIT ---
#define Hand_Held_lights
// #define WhiteWorld // THIS IS A DEBUG VIEW. uses to see AO easier. used to see fake GI better (green light)
// #define Compositing_Sky // make the sky some color to make compositing a sky in some photoediting software easier.

View File

@ -69,7 +69,7 @@ screen = [Direct_Light] [World] [Ambient_light] [Fog] [Post_Processing] [Clouds]
### AMBIENT LIGHT
screen.Ambient_light.columns=1
screen.Ambient_light = [Torch_Colors] [Ambient_Colors] <skip> Ambient_SSS indirect_effect AO_Strength GI_Strength ambientOcclusionLevel HQ_SSGI ambientsss_brightness
screen.Ambient_light = [Torch_Colors] [Ambient_Colors] <skip> Ambient_SSS indirect_effect AO_Strength GI_Strength ambientOcclusionLevel HQ_SSGI ambientsss_brightness Hand_Held_lights
screen.Torch_Colors.columns=1
screen.Torch_Colors = TORCH_AMOUNT Emissive_Brightness Emissive_Curve <skip> TORCH_R TORCH_G TORCH_B