Quantcast
Channel: Latest Questions by PokeJoe
Viewing all articles
Browse latest Browse all 20

How can I get a texture to render in object space?

$
0
0
I want to make a shader that is 1) completely emissive with no albedo component, 2) uses a UV-mapped texture with transparency based on the texture's alpha, and 3) uses a second texture in object space without regard to UV coordinates for additional transparency. So far I have got everything working, except for the texture in part 3), I got it working in both screen space and in world space, but I don't know how to get it into object space. Here's my shader so far. Shader "Custom/ExtraTransp" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _ScreenAlpha ("Base (RGB) Trans (A)", 2D) = "white" {} } SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 200 CGPROGRAM #pragma surface surf Lambert alpha sampler2D _MainTex; fixed4 _Color; sampler2D _ScreenAlpha; struct Input { float2 uv_MainTex; float2 worldPos; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; fixed4 sa = tex2D(_ScreenAlpha, IN.worldPos); o.Emission = c.rgb; o.Alpha = c.a * sa.a; } ENDCG } Fallback "Transparent/Diffuse" } What do I need to change to get this texture to move with the object's position?

Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>