Hi there, I have a model that was exported from blender with smooth normals (shade smooth), but shader renders those areas flat, how can i include this information and pass to shader?
var shaderDefinition = {
attributes: {
aPosition: pc.SEMANTIC_POSITION,
aUv0: pc.SEMANTIC_TEXCOORD0
},
vshader: `
attribute vec3 aPosition;
attribute vec2 aUv0;
uniform mat4 matrix_model;
uniform mat4 matrix_viewProjection;
varying vec2 vUv0;
void main(void)
{
vUv0 = aUv0;
gl_Position = matrix_viewProjection * matrix_model * vec4(aPosition, 1.0);
}
`,
Capture shader that does it using Spector JS, perhaps this, and see what the shader does, is my recommendation:
https://playcanvas.github.io/#/graphics/shapes
you’ll find something like this:
I’m not advance enough to understand what’s happening there
However, I’ve reproduced issue in a new playcanvas project:
https://playcanvas.com/project/1166600/overview/shading
appreciate for any help
Can you please describe the issue? I see two rings, one seems to be strangely textured, but what is the actual problem / expected behavior?
It’s the same model
On the left: Shader Material
On the right: Editor Material
The problem is that shader material does not render smooth shaded faces, it renders flat instead
The shader does not do any shading … it seems to use UV coordinates to generate some noise. My guess is that the uv coordinates are not continuous along it … but have many small parts in it. Could be something else, but that’d need more investigation. Try to apply some diffuse texture on it using PlayCanvas material - is that texture mapped well?
Indeed, it was due to UV, and i was scratching my head around faces shading…
Thanks
1 Like