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

Colored triangle (using vertex colors) renders white #894

Closed
vchelaru opened this issue Oct 20, 2012 · 10 comments
Closed

Colored triangle (using vertex colors) renders white #894

vchelaru opened this issue Oct 20, 2012 · 10 comments
Labels
Android Android platform OpenGL OpenGL graphics backend Windows

Comments

@vchelaru
Copy link
Contributor

I have a simple-to-reproduce case where a simple triangle does not render properly. Here is the source code which can be pasted into a Game class to reproduce the error:

http://pastebin.com/HbW0PVif

This exact code in XNA 4 (on the PC) results in a triangle with the verts being red/green/yellow. On Android (specifically Motoroal Droid Razr) renders the triangle correctly for 1 frame. The next frame the triangle renders, but it renders white instead of colored. I suspect something is not being preserved in the states frame-to-frame; however in my investigation of the code it looks like we're using pixel shaders, which I'm not as familiar with in open GL - were it fixed function I may have been able to identify the issue.

Anyway, given the relatively easy repro steps I don't think it'll be hard for those more knowledgeable with OGL to figure out what's going on.

@bonesoul
Copy link
Contributor

bonesoul commented Feb 7, 2013

I just tested this with 3.0 stable release, it still exists. Created a test project for it; http://dl.dropbox.com/u/197820/monogame/monogame-3.0-stable-issue894.rar

monogame-3 0-stable-issue-894-test

Also tested develop3d and still it also effects it.

monogame-develop3d-issue894

@vchelaru
Copy link
Contributor Author

vchelaru commented Feb 7, 2013

Thanks for looking into this and reviving the issue. It's currently our main blocking issue on getting FlatRedBall on Android.

@bonesoul
Copy link
Contributor

bonesoul commented Feb 7, 2013

I'll be taking further time to investigate it.

@lazlo-bonin
Copy link

I'm getting the same problem on Windows 8 Desktop (with OpenGL template).
Could you update the label?

@vchelaru
Copy link
Contributor Author

Updated. raistlinthewiz - find anything?

@dbeals
Copy link

dbeals commented Sep 14, 2013

This is being caused by the BasicEffect class recomputing the shader index, which is changing the technique from BasicEffect to BasicEffect_NoFog. If I set the flag FogEnabled to true it works just fine (BasicEffect.OnApply(), BasicEffect.cs:472.)

Sadly I'm not sure how to actually correct this in the code.

@Chaosus
Copy link
Contributor

Chaosus commented Mar 18, 2015

@tomspilman I think this issue should be closed(or revisited). The amount of work that should be done for fixing it is huge. The XNA shares one technique whereas MonoGame shares 32 technique within one BasicEffect. And as you look into
http://pastebin.com/HbW0PVif you could observe

foreach (var pass in _effect.Techniques[0].Passes)

is incorrect, there must be

foreach (var pass in _effect.CurrentTechnique.Passes)

@tomspilman
Copy link
Member

is incorrect

Yeah... does XNA even allow rendering of passes that are outside the current technique? It seems dangerous and unnecessary really. Switch techniques if you need to switch techniques.

@Chaosus
Copy link
Contributor

Chaosus commented Mar 18, 2015

The code above draws colored triangle correctly on XNA, but it is incorrect by nature.

@tomspilman
Copy link
Member

Yeah... I say it is invalid even in XNA. It just happens to work.

alxwest pushed a commit to alxwest/MonoGame that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android platform OpenGL OpenGL graphics backend Windows
Projects
None yet
Development

No branches or pull requests

6 participants