Unity Community


Results 1 to 17 of 17

  1. Location
    USA
    Posts
    3,097

    Vertex Texture Fetch in Unity Free?

    I would like to do a vertex texture fetch in the vertex shader, but I am using Unity Free, not Pro. Is there ANY way to get it to read ANY kind of texture in ANY format, within Unity Free, or does it require a floating-point render texture only available in Unity Pro?
    - ImaginaryHuman -

    NEW Mouse Path Animator - Mouse movement recording/playback - only $15!
    NEW Animated Dissolves for Shader Forge - Starting at $10!
    NEW Refract2D - Realtime refractions, reflections, image-based lighting, image distortions - ON SALE $25!
    Also Gradient Shader Pack - Realtime-generated animatable gradients - $20.
    Also Shader Wizard - CG Shader Generator including photoshop-style multi-texturing - $20.
    Also Texture Helper - procedural texture/pixmap-handling scripts - $10.


  2. Location
    Leeds, UK
    Posts
    2,059
    You could technically bake a texture to the vertex colours of a mesh?

    I'm not sure you can sample textures in the vertex shader in any version of Unity...


  3. Location
    Zürich, Switzerland
    Posts
    26,572
    Yes VTF works, it does not require any render textures. But if I remember right, you can't use surface shaders, you must use standard cg fragment and vertex functions.

    Question naturally is what you want to fetch, if its a RT or something calculated in realtime then Pro is required.

    Also, there is no difference in texture formats available in free or pro. they are at maximum ARGB32 on both ends, there is no A32R32G32B32 support or anything alike in Unity (and as long as OSX is not cut from the support thats not gonna change till 10.6 support is phased out as you simply can't work with them there), its limited to http://unity3d.com/support/documenta...ureFormat.html


  4. Location
    NE Ohio, USA
    Posts
    7,173
    Works fine in GLSL. Which is kind of a problem, because it will run under iOS device emulation, but not work on iOS!


  5. Location
    Zürich, Switzerland
    Posts
    26,572
    Thats funny cause any 3GS+ gpu supports VTF so I would guess it might be related to something else


  6. Location
    NE Ohio, USA
    Posts
    7,173
    Quote Originally Posted by dreamora View Post
    Thats funny cause any 3GS+ gpu supports VTF so I would guess it might be related to something else
    http://stackoverflow.com/questions/4...-vs-ipad-simul


  7. Location
    USA
    Posts
    3,097
    Great, you made my day. So you're saying in a vertex shader you can read one or more textures (up to how many texture units?) and those textures can be any of the supported unity formats including a regular 8-bit per component rgb, rgba, alpha8 etc?

    Also how is the speed compared to reading texture in the fragment shader? I heard its a lot slower (but that on directx 10/shader model 4? It's using the exact same hardware as texture fetch in the fragment shader?)

    Thanks
    Last edited by ImaginaryHuman; 03-03-2012 at 09:46 AM.
    - ImaginaryHuman -

    NEW Mouse Path Animator - Mouse movement recording/playback - only $15!
    NEW Animated Dissolves for Shader Forge - Starting at $10!
    NEW Refract2D - Realtime refractions, reflections, image-based lighting, image distortions - ON SALE $25!
    Also Gradient Shader Pack - Realtime-generated animatable gradients - $20.
    Also Shader Wizard - CG Shader Generator including photoshop-style multi-texturing - $20.
    Also Texture Helper - procedural texture/pixmap-handling scripts - $10.


  8. Location
    NE Ohio, USA
    Posts
    7,173
    I have no idea about the specifics. Try it out for yourself!
    Attached Images  
    Attached Files


  9. Location
    USA
    Posts
    3,097
    Thanks, though this example doesn't seem to be actually accessing the texture, just generating some vertex colors?
    Last edited by ImaginaryHuman; 03-03-2012 at 03:48 PM.
    - ImaginaryHuman -

    NEW Mouse Path Animator - Mouse movement recording/playback - only $15!
    NEW Animated Dissolves for Shader Forge - Starting at $10!
    NEW Refract2D - Realtime refractions, reflections, image-based lighting, image distortions - ON SALE $25!
    Also Gradient Shader Pack - Realtime-generated animatable gradients - $20.
    Also Shader Wizard - CG Shader Generator including photoshop-style multi-texturing - $20.
    Also Texture Helper - procedural texture/pixmap-handling scripts - $10.


  10. Location
    uk
    Posts
    1,157
    Quote Originally Posted by ImaginaryHuman View Post
    Also how is the speed compared to reading texture in the fragment shader? I heard its a lot slower
    No idea, seems fast enough to me though, certainly much faster than manipulating the vertices on the cpu and uploading them.




    Just remember you need to use SM3.0 in your shader.


  11. Location
    NE Ohio, USA
    Posts
    7,173
    Quote Originally Posted by ImaginaryHuman View Post
    Thanks, though this example doesn't seem to be actually accessing the texture, just generating some vertex colors?
    It "generates vertex colors" by accessing the texture. That's what this thread is about! Ask me if you have any questions about what the shader is doing. I tried to make something really simple for illustration. You were asking about multiple texture lookups though, so I included 12.


  12. Location
    USA
    Posts
    3,097
    Oh I see, I'll definitely have to go back and look at it more then. Thanks
    - ImaginaryHuman -

    NEW Mouse Path Animator - Mouse movement recording/playback - only $15!
    NEW Animated Dissolves for Shader Forge - Starting at $10!
    NEW Refract2D - Realtime refractions, reflections, image-based lighting, image distortions - ON SALE $25!
    Also Gradient Shader Pack - Realtime-generated animatable gradients - $20.
    Also Shader Wizard - CG Shader Generator including photoshop-style multi-texturing - $20.
    Also Texture Helper - procedural texture/pixmap-handling scripts - $10.


  13. Location
    Melbourne, Australia
    Posts
    64
    I'm on Windows.

    The following works for me. Unity automatically added the slightly misleading upgrade note.

    The difference between the following two versions is that

    1. the first one has if defined conditioning in the vert program whereas the second one doesn't.
    2. the second one uses #pragma glsl whereas the first one doesn't

    All else is the same.


    On Windows in default DirectX mode:

    Code:  
    1. Shader "Custom/VertDisplace" {
    2.         Properties {
    3.             _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         }
    5.         SubShader {
    6.             Tags { "RenderType"="Opaque" }
    7.             LOD 200
    8.            
    9.             CGPROGRAM
    10. // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
    11. #pragma exclude_renderers gles
    12.  
    13.             #pragma target 3.0
    14.             #pragma vertex vert
    15.             #pragma surface surf BlinnPhong
    16.            
    17.             sampler2D _MainTex;
    18.      
    19.             struct Input {
    20.                 float2 uv_MainTex;
    21.             };
    22.      
    23.             void vert (inout appdata_full v) {
    24.                 #if !defined(SHADER_API_OPENGL)
    25.                 float4 tex = tex2Dlod (_MainTex, float4(v.texcoord.xy,0,0));
    26.                 v.vertex.y += tex.r * 2.0;
    27.                 #endif
    28.             }  
    29.            
    30.             void surf (Input IN, inout SurfaceOutput o) {
    31.                 half4 tex = tex2D(_MainTex, IN.uv_MainTex);
    32.                 o.Albedo = tex.rgb;
    33.                 o.Alpha = tex.a;
    34.             }        
    35.            
    36.             ENDCG
    37.         }
    38.         FallBack "Diffuse"
    39.     }


    On Windows in forced OpenGL mode:

    Code:  
    1. Shader "Custom/VertDisplace" {
    2.         Properties {
    3.             _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         }
    5.         SubShader {
    6.             Tags { "RenderType"="Opaque" }
    7.             LOD 200
    8.            
    9.             CGPROGRAM
    10. // Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
    11. #pragma exclude_renderers gles
    12.             #pragma glsl
    13.             #pragma target 3.0
    14.             #pragma vertex vert
    15.             #pragma surface surf BlinnPhong
    16.            
    17.             sampler2D _MainTex;
    18.      
    19.             struct Input {
    20.                 float2 uv_MainTex;
    21.             };
    22.      
    23.             void vert (inout appdata_full v) {
    24.                 float4 tex = tex2Dlod (_MainTex, float4(v.texcoord.xy,0,0));
    25.                 v.vertex.y += tex.r * 2.0;
    26.             }  
    27.            
    28.             void surf (Input IN, inout SurfaceOutput o) {
    29.                 half4 tex = tex2D(_MainTex, IN.uv_MainTex);
    30.                 o.Albedo = tex.rgb;
    31.                 o.Alpha = tex.a;
    32.             }        
    33.            
    34.             ENDCG
    35.         }
    36.         FallBack "Diffuse"
    37.     }
    Last edited by carllooper; 03-06-2012 at 05:19 PM. Reason: Addendum


  14. Location
    IN
    Posts
    16
    Hello Carllooper...

    I am new in shaders with unity.

    i want to create a shader for texturing my vertex of a cube with a predefined radius...
    can you please tell me how i can do the same.???

    Sorry for my bad english and Thanks in advance

    Thank!
    Niks


  15. Posts
    203
    Hello all,
    How to make bone matrix texture?any example?and How to use R2VB ?it can run in DX9!
    R2VB LINK:
    http://www.lynxengine.com/old-site/ati.htm


  16. Posts
    203
    Since VTF can run on IOS ,So R2VB can too??


  17. Posts
    203
    AnyOne Can help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •