Giter VIP home page Giter VIP logo

Comments (4)

jv4779 avatar jv4779 commented on May 12, 2024

Lighting is all vertex normals, but I don't see anything obviously wrong in that code.

from space-nerds-in-space.

smcameron avatar smcameron commented on May 12, 2024

Interesting. This change makes lighting work again:

diff --git a/snis_client.c b/snis_client.c
index a2b157b..4f57090 100644
--- a/snis_client.c
+++ b/snis_client.c
@@ -1324,7 +1324,7 @@ static int update_planet(uint32_t id, double x, double y, double z, uint8_t gove
                m = k % NPLANET_MATERIALS;
                scale = planet_scale[s];
                e = add_entity(ecx, sphere_mesh, x, y, z, PLANET_COLOR);
-               update_entity_scale(e, scale); 
+               //update_entity_scale(e, scale); 
                if (r) {
                        /* FIXME: attach rings to planets somehow so when a planet is moved
                         * on the demon screen, the rings do not get left behind.
@@ -12248,6 +12248,7 @@ static void init_meshes()
        }

        sphere_mesh = mesh_unit_icosphere(4);
+       mesh_scale(sphere_mesh, 700);
        planetary_ring_mesh = mesh_fabricate_planetary_ring(2.0, 3.0);
        for (i = 0; i < NPLANET_SCALES; i++)
                planet_scale[i] = mtwist_int(mt, 400) + 300.0;  

So, I thought maybe something about update_entity_scale is broken, so I tried this change, on top of the one above:

diff --git a/snis_client.c b/snis_client.c
index 4f57090..d06ff9a 100644
--- a/snis_client.c
+++ b/snis_client.c
@@ -1324,7 +1324,7 @@ static int update_planet(uint32_t id, double x, double y, double z, uint8_t gove
                m = k % NPLANET_MATERIALS;
                scale = planet_scale[s];
                e = add_entity(ecx, sphere_mesh, x, y, z, PLANET_COLOR);
-               //update_entity_scale(e, scale); 
+               update_entity_scale(e, 1.0); 
                if (r) {
                        /* FIXME: attach rings to planets somehow so when a planet is moved
                         * on the demon screen, the rings do not get left behind.

Lighting still works. So update_entity_scale does not intrinsically break lighting.

This change, on top of the previous two, breaks lighting again:

diff --git a/snis_client.c b/snis_client.c
index d06ff9a..079d8cc 100644
--- a/snis_client.c
+++ b/snis_client.c
@@ -1324,7 +1324,7 @@ static int update_planet(uint32_t id, double x, double y, double z, uint8_t gove
                m = k % NPLANET_MATERIALS;
                scale = planet_scale[s];
                e = add_entity(ecx, sphere_mesh, x, y, z, PLANET_COLOR);
-               update_entity_scale(e, 1.0); 
+               update_entity_scale(e, 700.0); 
                if (r) {
                        /* FIXME: attach rings to planets somehow so when a planet is moved
                         * on the demon screen, the rings do not get left behind.
@@ -12248,7 +12248,7 @@ static void init_meshes()
        }

        sphere_mesh = mesh_unit_icosphere(4);
-       mesh_scale(sphere_mesh, 700);
+       mesh_scale(sphere_mesh, 0.5);
        planetary_ring_mesh = mesh_fabricate_planetary_ring(2.0, 3.0);
        for (i = 0; i < NPLANET_SCALES; i++)
                planet_scale[i] = mtwist_int(mt, 400) + 300.0;  

Could the triangles be too small, and so the normal calculations get screwed up?

-- steve

from space-nerds-in-space.

jv4779 avatar jv4779 commented on May 12, 2024

I think the problem is in the cubemap lit vertex shader where the normal vector isn't renormalized after getting transformed by the normal matrix. Can't try it at the moment.

from space-nerds-in-space.

smcameron avatar smcameron commented on May 12, 2024

Thanks, that fixed it.

-- steve

from space-nerds-in-space.

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.