Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411504 Posts in 69373 Topics- by 58429 Members - Latest Member: Alternalo

April 25, 2024, 04:18:52 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)SOLVED! Some Guidance on simple mesh triangle coloring/shading/highlighting
Pages: [1]
Print
Author Topic: SOLVED! Some Guidance on simple mesh triangle coloring/shading/highlighting  (Read 940 times)
Evonik
Level 0
*


View Profile
« on: January 28, 2019, 10:07:05 PM »

Consider the following image:



I'm looking for some ideas to color the faces of the triangle only without the blending/bleed into the other tris
which is caused by the color being set at the vertex in unity's mesh component.

I have tried making a shader to look at the normals but since the normals are calculated to the vertices the same problem occurs and I cannot go much more advanced than that (I know a shader god would be able to do it) since i'm kinda bad at shaders. (I know right, what a shock!)

Im trying to create a flat, non reflective terrain that is low poly along these lines:


notice the nice flat shading on a PER tri face base.
Do I continue looking at vertex colors, or is a shader 100% the direction to look in?

(is this maybe ONLY possible with a fragment shader?)

the only solution i want to avoid is drawing additional seperate trianlges ontop of my exsiting mesh as some
other places on the internet suggests as that seems like a enormous waste of resources.

anything else im open for, whether it's a lighting technique or some shader (have tried many).
Kinda getting desperate.

Thanks TIG.



« Last Edit: January 29, 2019, 10:31:19 AM by Evonik » Logged
nova++
Level 4
****


Real life space alien (not fake)


View Profile
« Reply #1 on: January 28, 2019, 11:29:20 PM »

Wouldn't it be the mesh normals? You can make something flat-shaded in a shader, but taking this to the root would mean ensuring the mesh is flat-shaded to begin with.
Logged

Evonik
Level 0
*


View Profile
« Reply #2 on: January 29, 2019, 12:36:08 AM »

HMM. interesting

I tested some static imported meshes, look at the image:



All objects are running the same shader/material.

The mesh with the red cross is the one I generate manually.
with Uv's the works. I also call the recalculate normals method after assigning the mesh.

Why OH WHY is it shaded like a piece of cloth?! the look I want is on the right
(Well not QUITE) but light years closer, and on the rock in the circle (also imported mesh).

I feel like im now being a dumb asshole, and that there is obvious reasons for this
but I poured over the unity Mesh spec and no luck.

Slap me please! How do I get my dynamic generated mesh to look like the imported ones?

Thanks!

« Last Edit: January 29, 2019, 12:45:02 AM by Evonik » Logged
Daid
Level 3
***



View Profile
« Reply #3 on: January 29, 2019, 01:28:40 AM »

The problem is in your (generated) mesh data, which is created with shared vertices/normals. While the imported mesh has 3 vertices/normals per triangle.
Logged

Software engineer by trade. Game development by hobby.
The Tribute Of Legends Devlog Co-op zelda.
EmptyEpsilon Free Co-op multiplayer spaceship simulator
Evonik
Level 0
*


View Profile
« Reply #4 on: January 29, 2019, 02:01:28 AM »

That makes total sense to me. Thanks!

BUUT, when you run a mesh like that and you want to dynamically manipulate the mesh I assume you
have to keep track of all the vertices stacked at corner where the triangles meet in order to move it as one

Doesn't this break shaders that use vertex colors etc?

Do you have some links to light reading on different approaches to generating a mesh like that?

thanks!
Logged
oahda
Level 10
*****



View Profile
« Reply #5 on: January 29, 2019, 02:34:21 AM »

Good tutorial (the whole video might not be relevant to you but it goes over how to make the tris flat shaded during mesh generation):



Logged

Evonik
Level 0
*


View Profile
« Reply #6 on: January 29, 2019, 10:31:02 AM »

THANK YOU GUYS! your tips and a lot of perseverance paid off!

looky looky:


nice flat low poly shade code generated and I can adjust vertex groups in real time without the whole thing
tearing apart!

SO CHUFFED!

Thank you guys for pointing me in the right direction!
Logged
oahda
Level 10
*****



View Profile
« Reply #7 on: January 29, 2019, 11:26:48 AM »

Well done! Kiss
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic