Giter Club home page Giter Club logo

Comments (5)

citruslee avatar citruslee commented on July 30, 2024

I assume you are using a 3d modelling software like blender to achieve such models. If yes, maybe you need to export the mesh with smooth faces. Also, the second problem should be, that you are not interpolating the vertice normals during computing, or you are directly transforming it. Or maybe you don't normalize them. A simple phong shader should do the trick, which can be found anywhere on the internet, so if that doesn't work okay, maybe you are handling normals wrong

from 3denginecpp.

zeyorama avatar zeyorama commented on July 30, 2024

Before we are guessing want's going on, lets first ask some question, so we can better argue.

Are you using the default normal map? If so, all normals are perpendicular to the face.

Are you correctly calculating the normals while generating the terrain mesh? Here is a example from Lighthouse3D (http://www.lighthouse3d.com/opengl/terrain/index.php3?normals (Accessed 02. Feb 2016 12:45)).

Are you using Bennys shader model?

from 3denginecpp.

zpl-zak avatar zpl-zak commented on July 30, 2024

I'm using Benny's shader model. Well, this terrain has to be generated programmatically (the terrain is actually 2D heightmap), Well I use Benny's code for normal generation, but these are face normals (resulting in flat shading look). What I need to do, is to generate normals per vertex. I already looked at lighthouse3d link provided and also implemented such algorithm. Only problem is, it takes too long for vertex normals to be computed. That is due to number of vertices involved in terrain (2048x2048 heightmap). While it is true I could just create terrain inside of Blender and just export it, I prefer to use heightmaps directly inside engine for such purposes. If I'm not mistaken, I need face normals (flat shading) to be able to generate vertex normals from them (I could be wrong).

from 3denginecpp.

zeyorama avatar zeyorama commented on July 30, 2024

Yes 2048x2048 is big indeed, but you only calculate it once on program startup.
For your per Vertex normal, you need all face normals of face, where this vertex is contributed to, sum them up and normilize the result.
If your generation needs to much time, consider some optimization. Store the face normals per face, so you calculate them only once. If you want, you can calculate the normals using the compute shader or OpenCL to improve perfomance drastically.

from 3denginecpp.

zpl-zak avatar zpl-zak commented on July 30, 2024

Okay, thanks. I'll look into it again. I'm just confused about these things.

from 3denginecpp.

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.