i need a transperent refraction shader based on a normal map.
i would like to use it for a particle system to create “heat”.
already searched for it but the projects i found were made before unity 3 so i get scripting errors in the console.
do you have any working “heat” shaders ?
and yes i have unity pro 3.1.0
I didn’t find a way to get the particle system to supply normal/tangent information in the vertex stream, so unless I missed something (which is entirely possible), you’ll have to wait for Unity to fix it.
possible. search forums… already used it
I’d appreciate a link to solution/thread. Was trying to do particle lighting with normal maps and my searching was fruitless. Thanks.
Package contain such a sader… Play with sorting of particles and prepare good normalmap
http://forum.unity3d.com/threads/66771-Gravity-Gun-Physx-Sample?highlight=gravity+gun
While I couldn’t get the package to load properly, I’m not sure it does what I need, but might be sufficient for Daimon’s needs (was only able to see vid). If just doing billboarded, non-rotated particles, you can get away with not having the correct information and just hardcode directionality into shader, but that’s insufficient for my purposes.
i get this problem :
any ideas ? a bug ? wrong shader ? please help
What is the problem in that image? Is that not what your normal map looks like?
if i use a any normal map for that shader i get bumped corners instead of just a bumped cycle.
it seems like unity 3 bumps the edges/ corners too even if they are not affected by the normal map.
is there any way to fix this ?
It’s really hard to know what you’re talking about when I don’t know what objects you are rendering, what shader you are using, and exactly what results you expect.
im using this shader: http://forum.unity3d.com/threads/66771-Gravity-Gun-Physx-Sample?highlight=gravity+gun
on a material for a particle system.
it should look like this:

but instead of only bumped circles
i get this blocky looking edges like here:
can somebody tell me why the shader is acting weird ?
Can you post the shader, or at least the part that does the normal lookup? Perhaps it expects old-style normal maps.
shader:
// Upgrade NOTE: replaced 'samplerRECT' with 'sampler2D'
// Upgrade NOTE: replaced 'texRECTproj' with 'tex2Dproj'
// Per pixel bumped refraction.
// Uses a normal map to distort the image behind, and
// an additional texture to tint the color.
Shader "HeatDistort" {
Properties {
_BumpAmt ("Distortion", range (0,128)) = 10
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
_BumpMap ("Bumpmap (RGB)", 2D) = "bump" {}
}
Category {
// We must be transparent, so other objects are drawn before this one.
Tags { "Queue" = "Transparent" }
// ------------------------------------------------------------------
// ARB fragment program
SubShader {
// This pass grabs the screen behind the object into a texture.
// We can access the result in the next pass as _GrabTexture
GrabPass {
Name "BASE"
Tags { "LightMode" = "Always" }
}
// Main pass: Take the texture grabbed above and use the bumpmap to perturb it
// on to the screen
Pass {
Name "BASE"
Tags { "LightMode" = "Always" }
CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#pragma fragmentoption ARB_fog_exp2
sampler2D _GrabTexture : register(s0);
float4 _GrabTexture_TexelSize;
sampler2D _BumpMap : register(s1);
sampler2D _MainTex : register(s2);
struct v2f {
float4 uvgrab : TEXCOORD0;
float2 uvbump : TEXCOORD1;
float2 uvmain : TEXCOORD2;
};
uniform float _BumpAmt;
half4 frag( v2f i ) : COLOR
{
// calculate perturbed coordinates
half2 bump = tex2D( _BumpMap, i.uvbump ).rg * 2 - 1;
float2 offset = bump * _BumpAmt;
#ifdef SHADER_API_D3D9
offset *= _GrabTexture_TexelSize.xy;
#endif
i.uvgrab.xy = offset * i.uvgrab.z + i.uvgrab.xy;
half4 col = tex2Dproj( _GrabTexture, i.uvgrab.xyw );
half4 tint = tex2D( _MainTex, i.uvmain );
return col * tint;
}
ENDCG
// Set up the textures for this pass
SetTexture [_GrabTexture] {} // Texture we grabbed in the pass above
SetTexture [_BumpMap] {} // Perturbation bumpmap
SetTexture [_MainTex] {} // Color tint
}
}
// ------------------------------------------------------------------
// Radeon 9000
#warning Upgrade NOTE: SubShader commented out because of manual shader assembly
/*SubShader {
GrabPass {
Name "BASE"
Tags { "LightMode" = "Always" }
}
Pass {
Name "BASE"
Tags { "LightMode" = "Always" }
Program "" {
SubProgram {
Local 0, ([_BumpAmt],0,0,0.001)
"!!ATIfs1.0
StartConstants;
CONSTANT c0 = program.local[0];
EndConstants;
StartPrelimPass;
PassTexCoord r0, t0.stq_dq; # refraction position
SampleMap r1, t1.str; # bumpmap
MAD r0, r1.2x.bias, c0.r, r0;
EndPass;
StartOutputPass;
SampleMap r0, r0.str; # sample modified refraction texture
SampleMap r2, t2.str; # Get main color texture
MUL r0, r0, r2;
EndPass;
"
}
}
SetTexture [_GrabTexture] {}
SetTexture [_BumpMap] {}
SetTexture [_MainTex] {}
}
}*/
// ------------------------------------------------------------------
// Fallback for older cards and Unity non-Pro
SubShader {
Blend DstColor Zero
Pass {
Name "BASE"
SetTexture [_MainTex] { combine texture }
}
}
}
}
bumpmap:
Yeah, it looks like it’s expecting old-style normal maps. Either generate your normal map externally and import it as a regular texture, or try replacing this line in the shader:
half2 bump = tex2D( _BumpMap, i.uvbump ).rg * 2 - 1;
with this:
half2 bump = tex2D( _BumpMap, i.uvbump ).[B]a[/B]g * 2 - 1;