Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procedural geometry #65

Open
thenuts opened this issue Nov 24, 2023 · 32 comments
Open

Procedural geometry #65

thenuts opened this issue Nov 24, 2023 · 32 comments
Labels
p3 Medium priority, and does not prevent the core functionality

Comments

@thenuts
Copy link

thenuts commented Nov 24, 2023

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

@VaclavElias
Copy link
Collaborator

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

@VaclavElias
Copy link
Collaborator

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

@thenuts
Copy link
Author

thenuts commented Nov 25, 2023

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
Copy link
Author

thenuts commented Dec 21, 2023

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.

@VaclavElias
Copy link
Collaborator

Is your example on GitHub?

@thenuts
Copy link
Author

thenuts commented Dec 21, 2023

yes, Example05_ProceduralGeometry

@dotlogix
Copy link
Contributor

@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
Copy link
Contributor

dotlogix commented Dec 21, 2023

@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.

@RichardMelito
Copy link

RichardMelito commented Jan 1, 2024

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

@VaclavElias
Copy link
Collaborator

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

@RichardMelito
Copy link

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
Copy link

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

@VaclavElias
Copy link
Collaborator

VaclavElias commented Jan 1, 2024

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

image

@RichardMelito
Copy link

Same thing:
image

@VaclavElias
Copy link
Collaborator

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
Copy link
Collaborator

@Doprez, could it be the Light Probe issue?

@VaclavElias
Copy link
Collaborator

VaclavElias commented Jan 1, 2024

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);
}

@RichardMelito
Copy link

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

@VaclavElias
Copy link
Collaborator

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.

@RichardMelito
Copy link

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.

@VaclavElias
Copy link
Collaborator

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?

@RichardMelito
Copy link

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

@VaclavElias
Copy link
Collaborator

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

@RichardMelito
Copy link

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

@VaclavElias
Copy link
Collaborator

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

image

@RichardMelito
Copy link

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

@VaclavElias
Copy link
Collaborator

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

@RichardMelito
Copy link

Could it be a problem with NVIDIA GPUs?

@VaclavElias
Copy link
Collaborator

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 #65 (comment), 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
  1. Default settings left as it is
image
  1. I added a cube without material
image
  1. And this is the result, all good
image

@RichardMelito
Copy link

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

@thenuts
Copy link
Author

thenuts commented Jan 3, 2024

It works for me also, but I think this is different; how can we create a ComputeVertexStreamColor from the editor?

@VaclavElias VaclavElias added the p3 Medium priority, and does not prevent the core functionality label Feb 18, 2024
@VaclavElias
Copy link
Collaborator

Hello. I hope everyone is good. I also experienced the same issue with my new PC! This time it was resolved with this PR #179. We think it might have been related with this issue.

The NuGet packages are not yet released. But you can use the source code to try it if you would like. Once the NuGet packages are out, I will close this issue as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3 Medium priority, and does not prevent the core functionality
Projects
None yet
Development

No branches or pull requests

4 participants