Bevy Vertex Colored Shader - bevy

I'm a newbie to shaders, and I'm trying to build a vertex colored shader in Bevy. Fortunately one of the bevy examples goes through how to use a custom shader, and creates a vertex colored shader, but unfortunately it doesn't show lighting anymore! Here's the example for reference: https://github.com/bevyengine/bevy/blob/main/examples/shader/mesh_custom_attribute.rs
I want to use the custom attributes as shown in the example, but I still need lighting to work (properly shaded faces). Any help is super appreciated!

Related

Use the sprite normal map to assimilate 3d mesh to use with Unity shaders

sorry if this is a noob question, is there a way to combine Unity shaders made using the Shader Graph with sprites? I would like to use the normal map attached to the texture to assimilate a 3d mesh, so that I can use some more advanced Shader Graph nodes (e.g. Fresnel).
It seems that the 2d shader examples online work only on the dissolve effect, character outline, tint changes, ... and I cannot find anything on using the highlights/lowlights already present in the 2d art to make it behave like 3d. I also have not found any examples of more complex shader effects that work on 2d. Any input would be greatly appreciated.
To give a more specific example, could this shader be adjusted to apply to a sprite?
https://www.youtube.com/watch?v=Cl4wkGjtGgw&list=PLkADxCB_xHGkE3iguVxNOStONQoidH4sr&index=3&t=3s&ab_channel=PabloMakes

Custom skybox shader for tiled skybox

I am new to writing shaders. I want to use a texture for 6-sided skybox in unity and I want that texture to be repeated several times also called tiling.
But the default 6-sided skybox shader in unity doesn't have tiling option. Can anyone write a custom shader for 6-sided skybox in unity which has option to tile textures? I also want an option to apply a color tint on the texture if possible. Thanks in advance.
Tiling can be achieved by multiplying texcoord by the number of tiles you want. Or in Surface shader it's uv_YourTex (likely MainTex) instead of texcoord. Writing from a phone so can't post an example, but it's really just one multiplication.
I don't know your specific scenario, but I needed to get more detailed sky with not very detailed texture and instead of UV I used view direction to sample a texture. It made it look like clouds in the distance are further away + clouds can move as you move . It's in this asset.
View direction sampling will not help if you are trying to make space though, which seams to be the case.
Also IMHO tiling on the skybox might be too visible.

Shader to bevel the edges of a cube?

This question relates to using shaders (probably in the Unity3D milieu, but Metal or OpenGL is fine), to achieve rounded edges on a mesh-minimal cube.
I wish to use only 12-triangle minimalist mesh cubes,
and then via the shader,
Achieve the edges (/corners) of each block being slightly bevelled.
In fact, can this be done with a shader?
I recently finished creating such shader. The only way it can work is by providing 4 normal vectors instead of one for each vertex (smooth, sharp and one for each edge of the triangle for the given vertex). You will also need one float3 to detect edges.
To add such data in a mesh I made a custom mesh editor, comes with Playtime Painter Asset from Unity Asset Store. Will post the shader with the next update. Also will post to public GitHub.
You can see some dark lines, it's because it starts to interpolate to a normal vector which facing away from light source, but since there are no additional triangles, the result is visible on a triangle which is facing the camera.
Update (2/12/2018)
Realised that by clipping pixels that end up having a normal facing away from the camera, it is possible to smooth the outline shape. It wasn't tested for all possible scenarios but works great for simple shapes:
As per request added a comparison cube:
Currently, Playtime Painter has a simplified version of that shader, which interpolates between 2 normal vectors and gives ok results on some edges.
Wrote an article.
In general the Relief Mapping is able to modify the object silhouette like on this picture. You'd need to prepare a heightmap that lowers at the borders and that's it. However I think that using such shader might be an overkill for such a simple effect so maybe it's better to just make it in your geometry.

Unity No Shading "Fullbright"

Is there a way to fullbright your Level in Unity3D?
I just want to remove shading and lights in a surreal project to get a fullbright world where textures are always shown as they are intented to be, not with shadows from other objects, floors, walls and so on.
You may need to provide a custom shader for this purpose, such as the shader prepared here: http://blog.jappie.net/unity3d-fullbright-shader-with-transparency/.

Lighting effect

The following screenshot is taken from a road that consists of several equal parts:
They all belong to a Blender model and have Shading set to Flat.
The scene has just one directional light and the parts of the road are used to bake a light map.
Material is set to use Mobile / Vertex Lit (Only Directional Lights) shader but I tested other shaders like Mobile / Unlit as well.
I don't get this effect when I take a model consisting of 8 road parts using a repeating texture - at least not in the middle. So it's not related to broken tileability of the texture. But it is visible then at the end as well
The texture import settings are:
Question: Is this the regular behaviour of the standard shaders? Can't believe it, but If so how to omit this when writing my own shader?
I would appreciate if someone could shed some light on this ;-)
It's a problem with normals. Easy fix is to make Unity recalculate all the normals (In model import settings switch Normals -> Import to Normals -> Calculate).
hard to know without seeing more context, but if the objects are lightmapped, make sure to check that they are not reusing the same lightmap texture. #jaceck's suggestion about normals is a good one too.
I do not know if it is this you want, but there is also a component called Line Render that draws a line.