• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ootsby · Mar 06, 2015 at 02:29 AM · rendertexturegl

RenderTexture varying behaviour - Unity 5

I've got some code that uses GL calls to render white triangles on a black background into a RenderTexture. This texture is then used in a shader.

This works in some configurations, but not others:

  • Running in the editor it works, although I had an oddity where the texture would blank on every keypress/release that came and went away with an editor restart.

  • Running it via a windows build produces a texture where the triangles are transparent rather than white.

  • Running it in browser plugin or webGL builds produces an entirely black texture (I've verified that it's being cleared by the GL calls by changing the colour).

So, can anyone shed any light on why I'm seeing these variations? Am I supposed to be setting the RenderTexture to a specific format or something?

Extra Info: The drawing occurs in the update. I've tried moving them to a camera precull/prerender callback but this doesn't seem to work at all. The GL code itself is:

 Graphics.SetRenderTarget(shadowMaskRT);
 GL.PushMatrix();
 GL.LoadPixelMatrix(0, shadowmapSize, 0, shadowmapSize);
 GL.Begin(GL.TRIANGLES);
 GL.Clear(false, true, Color.black);
 GL.Color(Color.white);
 
 for (int i = 0; i < tris.Length; ++i)
 {
     GL.Vertex(new Vector3(verts[tris[i]].x, verts[tris[i]].y, 0.0f));
 }
 GL.End();
 GL.PopMatrix();
 Graphics.SetRenderTarget(null);

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

OnInspectorGUI Custom Drawing? 1 Answer

Rendering with GL.Begin to a RenderTexture does not update it continuously (2019.2) 0 Answers

GL.Quads not correctly displaying color. It's all black 0 Answers

How do I initialize a float texture by script? 1 Answer

Pixel errors when drawing to Render Target with shader 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges