Git Product home page Git Product logo

Comments (12)

Flapperkewiet avatar Flapperkewiet commented on July 30, 2024

DSP No Light

As you can see, the remote player doesn't have a light source. I tried looking, but couldn't find where the light of the player is, as even disabling the player, the light remains. If anyone can find it, let me know.

from nebula.

Baldie-dev avatar Baldie-dev commented on July 30, 2024

It seems that Guiding light is being toggled in UIGameMenu by:
public void OnDfLightButtonClick() { PostEffectController.headlight = !PostEffectController.headlight; }

And then actual light is renedered by shader in PostEffectController:
Vector3 position = mainPlayer.position; Shader.SetGlobalVector("_Global_PointLightPos", new Vector4(position.x, position.y, position.z, 1f));

from nebula.

Baldie-dev avatar Baldie-dev commented on July 30, 2024

But since the light is made by Shader using a global variable, I am not sure how to add a second instance of the light. Maybe a workaround would be attaching a light source above the mech model, but that would not look that nice.

from nebula.

Flapperkewiet avatar Flapperkewiet commented on July 30, 2024

I'm don't know how unity stores shaders, but maybe we can extract the shader code, modify it, and then reassign it? Unless ofcourse only the compiled shader code is stored.

from nebula.

Baldie-dev avatar Baldie-dev commented on July 30, 2024

I believe you would have to somehow duplicate the shader and change the name of the input variable. Shaders need to be compiled beforehand if I am not mistaken.

  • One solution could be to create multiple shaders and just change the input variable to "_Global_PointLightPos2", "_Global_PointLightPos3", etc... and assign it to each player. Bur, I cannot guess how much effort would this take.

Maybe some Guru will have a better idea of how to solve this? :D

from nebula.

hubastard avatar hubastard commented on July 30, 2024

The easiest way would be to try adding a point light gameobject as a child of the remote players and look if it works. If it doesn't, we can add and load custom shader by using asset bundles.

from nebula.

Flapperkewiet avatar Flapperkewiet commented on July 30, 2024

I was able to extract 199 shader files files from the assets, but they are semi-compiled I believe, I found 3698 references to _Global_PointLightPos spread over 44 files. On closer inspection, the header data of the shaders seem to be somewhat intact, but all the actual shader-code is always in a single main function. All of the variable names are also stripped.

So in essence, i have 200 files of each between 1 and 10 thousand lines of:

				    u_xlat11.xyz = u_xlat2.xyz + vec3(-1.0, -1.0, -1.0);
				    u_xlat11.xyz = u_xlat0.xxx * u_xlat11.xyz + vec3(1.0, 1.0, 1.0);
				    u_xlat8.xyz = u_xlat8.xyz * u_xlat11.xyz;
				    u_xlat28.x = u_xlat28.x * u_xlat42 + 0.0318309888;
				    u_xlat8.xyz = u_xlat28.xxx * u_xlat8.xyz;
				    u_xlat11.xyz = u_xlat3.xyz + vec3(u_xlat46);
				    u_xlat8.xyz = u_xlat8.xyz * u_xlat11.xyz;
				    if(u_xlatb44){
				        u_xlat28.x = u_xlat45 + -20.0;
				        u_xlat42 = u_xlat28.x;
				        u_xlat42 = clamp(u_xlat42, 0.0, 1.0);
				        u_xlat42 = u_xlat50 * u_xlat42;
				        u_xlat4.xyz = (-u_xlat4.xyz) * u_xlat28.xxx + _Global_PointLightPos.xyz;
				        u_xlat28.x = dot(u_xlat4.xyz, u_xlat4.xyz);
				        u_xlat28.x = sqrt(u_xlat28.x);
				        u_xlat44 = (-u_xlat28.x) + 40.0;
				        u_xlat44 = u_xlat44 * 0.0250000004;

from nebula.

hubastard avatar hubastard commented on July 30, 2024

I've tested adding Light to the player but there is a big artefact.
Capture

What we could probably do, is create our own shader for remote player lighting and add a custom post effect of this shader on the main camera.

from nebula.

Baldie-dev avatar Baldie-dev commented on July 30, 2024

I have done some digging and I more or less understand how it is done now. The light effect is done by a global variable that is used in all shaders for all materials that receives this light. In this way, they can control how this light will interact with different materials (leaves, water, surface, etc.). Since it is used in 44 shaders in almost 44 different ways, it is not possible to do it in the same way.

I am still trying to find out, what is causing this artifact and if there is some way how to bypass it.

@hubastard: If you attach the shader to the main camera, you can only control the brightness of the pixels around the player right? I am not sure if you would be able to do some projection onto the surface to highlight only the surface. Otherwise, I think you would be also highlighting the pixels that belong to "air", so if players rotate the camera close to the horizon. There will be always a circle of highlighted pixels around the player, right?

from nebula.

hubastard avatar hubastard commented on July 30, 2024

Yeah I think you are right.. I will try to see if I can find a way to get almost the same look somehow..

from nebula.

Baldie-dev avatar Baldie-dev commented on July 30, 2024

Regarding the initial issue, that one player does not receive light from another player. I think it is caused by some issues with the model\shaders on the model. I was checking it, but I am not exactly sure why.

From each player's perspective, his model receives more lights than models of other players so all other players look more darker.

The arrow shows from which player's perspective I have made the screenshot.
light

from nebula.

hubastard avatar hubastard commented on July 30, 2024

Will not fix. Since this would require changing the entire shader code of the game.

from nebula.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.