Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 scarecrow77 · Jan 27, 2013 at 01:52 AM · shadertexture3dvolumetric

Unity 4 Texture3D problems

I'm using Unity 4 and wondering why this code I've adapted from code posted here doesn't work. My cube which I have applied my script and shader to ends up black. I've found someone here with the same problem but no answer.

My C# script to generate the Texture3D:

 using UnityEngine;
 using System.Collections;
 
 public class Create3DTex : MonoBehaviour {
     
     private Texture3D tex;
     public int size = 16;
     
     void Update ()
     {
         tex = new Texture3D(size, size, size, TextureFormat.ARGB32, true);
         Color[] cols = new Color[size*size*size];
         
         int colourCount = 0;
 
         for (int z = 0; z < size; z++)
         {
             for (int y = 0; y < size; y++)
             {
                 for (int x = 0; x < size; x++)
                 {
                     cols[colourCount] = new Color(1,0,0,1);
                     colourCount++;
                 }
             }
         }
         
         tex.SetPixels (cols);
         tex.Apply ();
 
         renderer.material.SetTexture ("_MyTex", tex);
     }
     
 }


My Shader code:

 Shader "Custom/VolumeShader" {
     Properties {
         _MyTex ("Some Texture",3D) = "white" {}
     }
     SubShader {
         Blend SrcAlpha OneMinusSrcAlpha
         Cull Off
         Pass {
 
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #include "UnityCG.cginc"
             
             sampler3D _MyTex;
             
             struct v2f {
                 float4 pos : SV_POSITION;
                 float3 uv : TEXCOORD;
             };
 
             v2f vert (appdata_base v)
             {
                 v2f o;
                 o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                 o.uv = v.vertex.xyz*0.5+0.5;
                 return o;
             }
             
             float4 frag (v2f i) : COLOR
             {
                 float4 outColor = tex3D (_MyTex, i.uv);
                 return outColor;
             }
             
             ENDCG
             
         }
     }
     FallBack "VertexLit"
 }

Thank you!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by soncio · Oct 09, 2013 at 10:17 AM

http://forum.unity3d.com/threads/148605-Unity-4-3D-Textures-(Volumes)

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
avatar image
0

Answer by PaulUsul · Jan 21, 2014 at 06:47 PM

Try instead of calling your uvs uv instead volUv/vol_uv or something not starting with uv. I have had a few problems with that

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

12 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

Related Questions

Alpha Texture Deserves a Separate File? 1 Answer

Making Unity textures/materials look as good as they did in Blender 2 Answers

tex3d lookup yields black mesh - why?? 1 Answer

Unity - Simple Water 3 Answers

How can i get my quad to only render my texture without stretching it? 1 Answer


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