Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 SandorChickane · Apr 07, 2020 at 09:14 AM · shadersgraphicstexture2drendertextureeffects

All pixels drawn on my RenderTexture with a Sprite Diffuse material are shown as black instead of the intended texture colour

(Sorry, originally asked this in the wrong space)

I'm working on a system for dynamically drawing to a RenderTexture based on certain in-game events, using the world position to draw pixels to the RenderTexture. This part is working fine, and I have applied the RenderTexture to a Sprite Diffuse material and am rendering it onto a quad.

The pixels are all being drawn in the correct place, but are all showing up as black instead of the red texture I'm assigning to them. The texture displays correctly in the RenderTexture preview, and displays correctly in-game if I change the material to an unlit shader (such as Sprite Default) but appears as black on lit shaders like Sprite Diffuse or the standard Surface shader.

This is my code for drawing the points to the RenderTexture:

 RenderTexture.active = rt;
 GL.PushMatrix();
 GL.LoadPixelMatrix(0, width, 0, height);
 
 for (int i = 0; i < pointsToDraw.Count; i++)
 {
     Graphics.DrawTexture(new Rect(pointsToDraw[i].x, pointsToDraw[i].y, 1, 1), drawTexture);
 }
         
 GL.PopMatrix();
 
 pointsToDraw.Clear();
 RenderTexture.active = null;


Below is an example of the in-game appearance of the render texture (the black lines on the geometry), and then what the material preview of the texture looks like (the correct red lines).

In-game appearance: In-game appearance

Material texture preview / desired appearance: Material texture preview appearance



I have no idea why its doing this, and any help at all would be appreciated as I'm very new to shaders / RenderTextures so apologies if this is a dumb question!

Comment
Add comment · Show 1
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
avatar image SandorChickane · Apr 08, 2020 at 07:53 AM 0
Share

I've got it looking right with the sprite default shader, but I really need it to react properly to lighting as the rest of the in-game materials do. Has anyone got any idea of what it might be?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by SandorChickane · Apr 11, 2020 at 05:00 PM

As an answer to my own question (although I'm using a shader now, had the same issue), the scale of the quad displaying the shader was set to 0... Rookie mistake!

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

151 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Graphics.CopyTexture and location fo textures 0 Answers

How can I draw a part of a texture on a another texture with transparency? 2 Answers

Alternative for Graphics.CopyTexture() ? 2 Answers

Making everything black and white except for certain obects? 1 Answer

Shader.SetGlobalTexture not working on Windows 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges