jPCT-AE - a 3d engine for Android > Support

Obtain normals to adjust vertex controller normals

(1/2) > >>

AeroShark333:
Hello,

Currently I have an Object3D with a vertexcontroller attached to it. (Modify = false mode)
The vertexcontroller only changes the vertices positions of the mesh and doesn't touch the normals.
In the draw method I currently do the following three operations:
1. Apply vertexcontroller
2. Object3D#touch
3. Object3D#calcNormals

Is it possible to obtain the calculated normals so they could be fed into the vertexcontroller immediately? I wish to save calculation costs by not having to calculate the normals every frame.
In a sense I imagine I could pre-compute the normals with Object3D#calcNormals and then save the normals to be reused in the vertexcontroller. I looked at polygonmanager but no luck there...

Thanks in advance!

EgonOlsen:
I'm not sure what you mean exactly...the vertex controller can access the normals already, so you can modify them there. The issue with that is, as the docs state, that this calculation isn't trivial, because vertex normals depend on adjacent polygons as well.

 What do mean by


--- Quote ---Is it possible to obtain the calculated normals so they could be fed into the vertexcontroller immediately?
--- End quote ---

Which calculated normals?

AeroShark333:
Hmmm, I'll try to explain better:

Currently, I have an animation where I deform the mesh (through its vertices).
I can't calculate the normals in the vertexcontroller because they depend on neighboring vertices.
However, if I use Object3D.calcNormals() after applying the vertexcontroller, then I suppose I will have the normals for the deformed mesh.
Is it possible to obtain these normals for future use, so in that case I could feed them into the vertexcontroller instead of having to call calcNormals() again.
Essentially, I am trying to create a cache of normals to avoid having to call calcNormals() during runtime.

I hope this makes sense...

EgonOlsen:
I see. If you call refreshMeshData() on the controller, the newly calculated normals should be updated in the controller and you can obtain them from there.

AeroShark333:

--- Quote from: EgonOlsen on November 27, 2023, 10:57:32 am ---I see. If you call refreshMeshData() on the controller, the newly calculated normals should be updated in the controller and you can obtain them from there.

--- End quote ---
Thank you, works perfectly! :D

Also, this might be a minor bug: I think the 'shininess' value is not seem to be passed to the fragment shader (while the other uniform variables from the default vertex shader seem accessible though in the fragment shader). I don't need this as I can put custom shader code anyway... But I thought it would be nice to know.

Navigation

[0] Message Index

[#] Next page

Go to full version