stride-community-toolkit icon indicating copy to clipboard operation
stride-community-toolkit copied to clipboard

Procedural geometry

Open thenuts opened this issue 2 years ago • 32 comments

The Procedural geometry code example on my computer doesn't render color, just black geometry

thenuts avatar Nov 24 '23 23:11 thenuts

Could you tell us about your PC spec? What graphic card do you have?

VaclavElias avatar Nov 25 '23 11:11 VaclavElias

@dotlogix, would you have any ideas why is that?

VaclavElias avatar Nov 25 '23 11:11 VaclavElias

I am learning the internals of stride and trying to debug for more tips, but I am not very optimistic about my skill to do it. Processor 12th Gen Intel(R) Core(TM) i7-12700 2.10 GHz Installed RAM 32.0 GB (31.7 GB usable) NVIDIA GeForce RTX 4060 Ti

thenuts avatar Nov 25 '23 22:11 thenuts

Any help on how can I verify what's is wrong here. I really want to work with Stride as a code-only solution for a simple game.

thenuts avatar Dec 21 '23 14:12 thenuts

Is your example on GitHub?

VaclavElias avatar Dec 21 '23 15:12 VaclavElias

@VaclavElias sorry for the late response I was pretty busy in the last month and couldn't take a look. Unfortunately, I am not able to reproduce this issue on my machine, both the Debug and Release versions work fine.

Could it be an issue with the backend? Not sure what graphics pipeline Nvidia uses by default as I am using an AMD 6700XT

dotlogix avatar Dec 21 '23 16:12 dotlogix

@thenuts could you try as an experiment to change the IndexType from IndexingType.Int16 to IndexingType.Int32 ? Maybe Nvidia does not like 16bit ints as indices, although it might be sth else if the geometry shows up correctly for you.

Maybe play around a bit with the data types for vertex colors.

Or another idea would be to try to explicitly set the color vertex stream in the material like so:

new MaterialInstance {
  Material = Material.New(graphicsDevice, new MaterialDescriptor {
      Attributes = new MaterialAttributes {
          DiffuseModel = new MaterialDiffuseLambertModelFeature(),
          Diffuse = new MaterialDiffuseMapFeature {
              DiffuseMap = new ComputeVertexStreamColor
              {
                  Stream = new ColorVertexStreamDefinition(0)
              }
          },
      }
  })
}

If nothing of this helps I am pretty much out of ideas as it seems to be a Stride issue then I guess.

dotlogix avatar Dec 21 '23 16:12 dotlogix

I'm seeing the same problem. A few things to note:

  1. Built with .NET SDK 8.0.100
  2. Switching to IndexingType.Int32 did not help.
  3. The shapes are only visible from one side. Moving the camera to see their backsides makes them disappear, but their shadows are still present.
  4. Running it produced these warnings:
EXEC : warning 1.880s: [AssetCompiler] Could not find game settings asset at location [GameSettings]. Use a Default One
 [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\Example05_Proced
uralGeometry.csproj]
Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionRawAOEffect_0cc465504e487e664337c636d7346293.hlsl(222,11-59): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionRawAOEffect_0cc465504e487e664337c636d7346293.hlsl(222,11-59): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_e1ec59d32a8276ef3e5580b114564ebb.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_e1ec59d32a8276ef3e5580b114564ebb.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_0a3ade3eec873ffbb3eb696a546a7ec1.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_0a3ade3eec873ffbb3eb696a546a7ec1.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_SSLRCombinePass_408b7839b3d48902227979aa949fb79a.hlsl(248,5-15): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example05_ProceduralGeometry\bin\Debug\net8.0\log\shader_SSLRCombinePass_408b7839b3d48902227979aa949fb79a.hlsl(248,5-15): warning X3206: implicit truncation of vector type

System info: OS: Windows 11 Pro version 10.0.22621 Build 22621 CPU: AMD Ryzen 5800X GPU: NVIDIA RTX 3080 Ti Graphics driver: Driver version 546.33

RichardMelito avatar Jan 01 '24 19:01 RichardMelito

The shapes are only visible from one side. Moving the camera to see their backsides makes them disappear, but their shadows are still present.

That is probably normal behaviour. It does behave, even when you create your Mesh in Stride independently from this example. It behaves like that also on my example below..

Running it produced these warnings:

Are these showed only on the first run?

I am now experimenting with the library as you can see here and the Meshes are working..

https://github.com/stride3d/stride-community-toolkit/tree/main/examples/code-only/Example01_Basic2DScene

image

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

Running it produced these warnings:

Are these showed only on the first run?

The EXEC warning is shown each time. The others are only shown on the first run.

I am now experimenting with the library as you can see here and the Meshes are working..

This is how Example01 looks to me. Notice the black 2D squares.

image

RichardMelito avatar Jan 01 '24 20:01 RichardMelito

Oh also, running Example01 produced these warnings.

C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\Program.cs(171,13): warning CS8321: The local function 'AddSpriteBatchRenderer' is declared but never used [C:\Users\binar\source\repos\stride-community-toolkit\examples\
code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(46,26): warning CS8602: Dereference of a possibly null reference. [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example0
1_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(61,9): warning CS8602: Dereference of a possibly null reference. [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01
_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(63,19): warning CS8602: Dereference of a possibly null reference. [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example0
1_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(49,13): warning CS0219: The variable 'textScale' is assigned but its value is never used [C:\Users\binar\source\repos\stride-community-toolkit\exam
ples\code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(16,35): warning CS8618: Non-nullable field '_sceneRenderer' must contain a non-null value when exiting constructor. Consider declaring the field as
 nullable. [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(17,31): warning CS8618: Non-nullable field '_ctx' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
 [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(13,22): warning CS0169: The field 'SpriteBatchRenderer._texture' is never used [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-
only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\SpriteBatchRenderer.cs(14,19): warning CS0414: The field 'SpriteBatchRenderer._fontSize' is assigned but its value is never used [C:\Users\binar\source\repos\stride-commu
nity-toolkit\examples\code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
EXEC : warning 1.594s: [AssetCompiler] Could not find game settings asset at location [GameSettings]. Use a Default One [C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\Example01_Basic2DScene.csproj]
Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionRawAOEffect_0cc465504e487e664337c636d7346293.hlsl(222,11-59): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionRawAOEffect_0cc465504e487e664337c636d7346293.hlsl(222,11-59): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_e1ec59d32a8276ef3e5580b114564ebb.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_e1ec59d32a8276ef3e5580b114564ebb.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_0a3ade3eec873ffbb3eb696a546a7ec1.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_AmbientOcclusionBlurEffect_0a3ade3eec873ffbb3eb696a546a7ec1.hlsl(223,19-130): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_SSLRCombinePass_408b7839b3d48902227979aa949fb79a.hlsl(248,5-15): warning X3206: implicit truncation of vector type

Warning: C:\Users\binar\source\repos\stride-community-toolkit\examples\code-only\Example01_Basic2DScene\bin\Debug\net8.0\log\shader_SSLRCombinePass_408b7839b3d48902227979aa949fb79a.hlsl(248,5-15): warning X3206: implicit truncation of vector type

RichardMelito avatar Jan 01 '24 20:01 RichardMelito

Interesting, as it affects also your 3D, what about Example2?

image

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

Same thing: image

RichardMelito avatar Jan 01 '24 20:01 RichardMelito

I see. We can ignore the warnings, as most likely they are not causing an issue. Also, the Mesh is most likely ok, as you have the problem generally. Not sure if there is not some issue with lighting, because you have some lights ok but the lights from the dark side are not working..

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

@Doprez, could it be the Light Probe issue?

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

This is now facing up, where the light is could you try that?

image

I changed some of these..

void GiveMeAPlane(MeshBuilder meshBuilder)
{
    meshBuilder.WithIndexType(IndexingType.Int16);
    meshBuilder.WithPrimitiveType(PrimitiveType.TriangleList);

    var position = meshBuilder.WithPosition<Vector3>();
    var color = meshBuilder.WithColor<Color>();

    meshBuilder.AddVertex();
    meshBuilder.SetElement(position, new Vector3(0, 1, 0));
    meshBuilder.SetElement(color, Color.Red);

    meshBuilder.AddVertex();
    meshBuilder.SetElement(position, new Vector3(1, 1, 0));
    meshBuilder.SetElement(color, Color.Green);

    meshBuilder.AddVertex();
    meshBuilder.SetElement(position, new Vector3(1, 1, 1));
    meshBuilder.SetElement(color, Color.Blue);

    meshBuilder.AddVertex();
    meshBuilder.SetElement(position, new Vector3(0, 1, 1));
    meshBuilder.SetElement(color, Color.Yellow);

    meshBuilder.AddIndex(0);
    meshBuilder.AddIndex(1);
    meshBuilder.AddIndex(2);

    meshBuilder.AddIndex(0);
    meshBuilder.AddIndex(2);
    meshBuilder.AddIndex(3);
}

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

No change, except for the direction that the plane is pointing. image

RichardMelito avatar Jan 01 '24 20:01 RichardMelito

Thanks for a screenshot. Hmm, I would need some more experienced dev to step in. Are you exploring only code-only or you are also using Stride Game studio. I wonder if you would have the same issue also there, or is it related only to code-only issue.

VaclavElias avatar Jan 01 '24 20:01 VaclavElias

This seems to be happening both with code-only and with game studio. I copy-pasted some of the procedural geometry code into my game studio project and noticed that the plane it made was totally black. I then ran the original code-only example from GitHub and saw that everything was still black.

RichardMelito avatar Jan 01 '24 21:01 RichardMelito

What about if you just drop a box to Game Studio, or run some existing Game Studio tutorials (https://doc.stride3d.net/latest/en/tutorials/csharpintermediate/index.html)? Are you having the same issue there? If yes, could you screenshot for us?

VaclavElias avatar Jan 01 '24 21:01 VaclavElias

I have only seen the issue when using the community toolkit code.

Here is a screenshot from the PhysicsSample. You can see the cubes that come with it, plus 2 capsules that I dragged and dropped. One has no material, and the other has the built-in Materials/CubeMat material. image

RichardMelito avatar Jan 01 '24 21:01 RichardMelito

And do you use toolkit's NuGet or directly toolkit source code?

VaclavElias avatar Jan 01 '24 21:01 VaclavElias

Both:

I copy-pasted some of the procedural geometry code into my game studio project and noticed that the plane it made was totally black.

The toolkit was definitely referenced as a NuGet package when I tried integrating it into my existing project.

I then ran the original code-only example from GitHub and saw that everything was still black.

The GitHub examples reference the Stride.CommunityToolkit project directly, but that in turn references the engine's NuGet packages. Not sure if that's relevant but just wanted to point it out. image

RichardMelito avatar Jan 01 '24 22:01 RichardMelito

We are referencing the same packages. I was wondering if some updates were made..

image

VaclavElias avatar Jan 01 '24 22:01 VaclavElias

For what it's worth, I cannot reproduce the problem on my laptop. Its specs are: OS: Windows 11 Home version 10.0.22631 Build 22631 CPU: Intel i7-1065G7 GPU: Intel Iris Plus Graphics Graphics driver: Driver version 31.0.101.2125

RichardMelito avatar Jan 01 '24 22:01 RichardMelito

That is really a mystery!!🤦‍♂️Let's see if we can get some input from others.

VaclavElias avatar Jan 01 '24 23:01 VaclavElias

Could it be a problem with NVIDIA GPUs?

RichardMelito avatar Jan 01 '24 23:01 RichardMelito

It would be good to find out, if the issue is only happening when you are using the toolkit. The reason for that is that toolkit is in preview and I am trying to figure out the correct settings for the GraphicCompositor which might be affected by GPU.

This example https://github.com/stride3d/stride-community-toolkit/issues/65#issuecomment-1873467282, if you do it through Stride Studio, without any reference to the toolkit, does it also lose colours.

These are my steps I did through Stride Studio. If you can get the same result, it means the issue is in the toolkit. If not, then I don't know.

  1. Create new project - New game template image

  2. Default settings left as it is image

  3. I added a cube without material image

  4. And this is the result, all good image

VaclavElias avatar Jan 02 '24 23:01 VaclavElias

That works, so it seems like it's something in the community toolkit. image

RichardMelito avatar Jan 03 '24 03:01 RichardMelito