Author Topic: Being silly...  (Read 2191 times)

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
Being silly...
« on: May 09, 2006, 05:52:49 am »
I was reading on a cellshading tutorial and was wondering how bad is it for me to try to implement that with JPCT? I noticed that JPCT was nice enough to handle some of the mathematical stuff like normalize and dot products, but does not seem to have a way to disable lighting (or maybe not?).

Basic Rendering
-Disable lighting.
-Disable blending.
-Draw the colored vertexes.

Basic Lighting
-Create the Sharp Lighting map.
-If using a light radius, do a point-in-sphere check to see if the point is within range.
-Get the vector from the light position to the vertex and normalize it.
-Get the dot product of the new vector and the vertex normal.
-Repeat 2-4 for every vertex.
-Render as usual.

Outlines and Highlighting
-Draw the object as normal.
-Switch face orientation.
-Set the color to 100% black.
-Change to wireframe mode.
-Draw the mesh again, but only specifying the vertex positions.
-Restore the original modes.

Basic Texturing
-Load the Sharp Lighting map from file and store in an array (remember to convert values to a range of 0-1).
-Calculate the lighting as normal, but multiply the dot product by the width of the texture - 1 (remember 0-15), and cast it to an integer.
-When drawing, lookup the color to use in the Sharp Lighting map array, using the lighting value as the index.
-Use this value for the red, green and blue values of the vertex color.
-Render the object like you would normally, but remember to update the color for each vertex. Don't forget to disable lighting, etc.
-Draw the highlights (same as before).

Oh well.. That reminds me~!! I have not experimented it yet but can JPCT use alpha channel textures for opacity? I was trying to make a model with lovely anime hair and desperately need alpha channels for that to look right, if its not possible then that is where the cellshading tutorial came in~! Thanks again for reading this thread~!!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
Being silly...
« Reply #1 on: May 09, 2006, 07:02:21 pm »
You can use alpha textures. Texture has some constructors for it. They are used on transparent objects only. You may have to play around with the transparency settings of the object as well as with Config.glTransparencyOffset and Config.glTransparencyMul to get the desired effect.

About the cellshading: I doubt that you'll succeed doing this with jPCT because it hides too much of the rendering pipeline from the user.

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
Being silly...
« Reply #2 on: May 10, 2006, 08:32:20 pm »
Thanks as always~! And again, I am not tooo worried about cell shading anyway~! I rather more game than more fancy effects... Errr... I mean... game first, effects later!! Something like that... Hee hee... Thanks again though!