public SetVector ( int nameID, Vector4 val ) : void | ||
nameID | int | Property name ID, use Shader.PropertyToID to get it. |
val | Vector4 | Value to set. |
return | void |
public void SetConstants(ComputeShader compute, float dt) { compute.SetFloat(ShaderConst.PROP_DELTA_TIME, dt); compute.SetFloat(ShaderConst.PROP_ELASTICS, _data.elastics); compute.SetFloat(ShaderConst.PROP_PARTICLE_RADIUS, _data.radius); compute.SetVector(ShaderConst.PROP_BOUNDS, _data.bounds); }
static public int SetVector(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Vector4))) { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Vector4))) { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function SetVector to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
// // GPU STUFF // private static void SetShaderVars(UnityEngine.ComputeShader shader, UnityEngine.Vector2 noiseOffset, bool normalize, float noiseScale) { shader.SetInt("octaves", octaves); shader.SetFloat("falloff", falloff); shader.SetInt("normalize", System.Convert.ToInt32(normalize)); shader.SetFloat("noiseScale", noiseScale); shader.SetVector("offset", noiseOffset); }
public void SetConstants(ComputeShader compute, float dt) { CheckDragCoeffs (); compute.SetFloat(ShaderConst.PROP_DELTA_TIME, dt); compute.SetFloat(ShaderConst.PROP_ELASTICS, _data.elastics); compute.SetFloat(ShaderConst.PROP_FRICTION, _data.friction); compute.SetFloat(ShaderConst.PROP_PARTICLE_RADIUS, _data.radius); compute.SetFloat(ShaderConst.PROP_PENETRATION_BIAS, _data.penetrationBias); compute.SetVector(ShaderConst.PROP_BOUNDS, _data.bounds); }
static public int SetVector(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(int), typeof(UnityEngine.Vector4))) { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(string), typeof(UnityEngine.Vector4))) { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function SetVector to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
static public int SetVector(IntPtr l) { try { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static public int SetVector(IntPtr l) { try { UnityEngine.ComputeShader self = (UnityEngine.ComputeShader)checkSelf(l); System.String a1; checkType(l, 2, out a1); UnityEngine.Vector4 a2; checkType(l, 3, out a2); self.SetVector(a1, a2); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void SetParams(ComputeShader c) { c.SetInt(ShaderConst.PROP_HASH_GRID_NX, _grid.nx); c.SetInt(ShaderConst.PROP_HASH_GRID_NY, _grid.ny); c.SetVector(ShaderConst.PROP_HASH_GRID_PARAMS, new Vector4(_grid.w, _grid.h, _grid.nx / _grid.w, _grid.ny / _grid.h)); }
void SetParameters(ComputeShader mat) { mat.SetFloat("Rg", Rg); mat.SetFloat("Rt", Rt); mat.SetFloat("RL", RL); mat.SetInt("TRANSMITTANCE_W", TRANSMITTANCE_W); mat.SetInt("TRANSMITTANCE_H", TRANSMITTANCE_H); mat.SetInt("SKY_W", SKY_W); mat.SetInt("SKY_H", SKY_H); mat.SetInt("RES_R", RES_R); mat.SetInt("RES_MU", RES_MU); mat.SetInt("RES_MU_S", RES_MU_S); mat.SetInt("RES_NU", RES_NU); mat.SetFloat("AVERAGE_GROUND_REFLECTANCE", AVERAGE_GROUND_REFLECTANCE); mat.SetFloat("HR", HR); mat.SetFloat("HM", HM); mat.SetVector("betaR", BETA_R); mat.SetVector("betaMSca", BETA_MSca); mat.SetVector("betaMEx", BETA_MSca / 0.9f); mat.SetFloat("mieG", Mathf.Clamp(MIE_G, 0.0f, 0.99f)); }
public static void ReadSingleFromRenderTexture(RenderTexture tex, float x, float y, float z, ComputeBuffer buffer, ComputeShader readData, bool useBilinear) { if(tex == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - RenderTexture is null"); return; } if(buffer == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - buffer is null"); return; } if(readData == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - Computer shader is null"); return; } if(!tex.IsCreated()) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - tex has not been created (Call Create() on tex)"); return; } int kernel = -1; int depth = 1; //if(tex.isVolume) //{ // depth = tex.volumeDepth; // // if(useBilinear) // kernel = readData.FindKernel("readSingle3D"); // else // kernel = readData.FindKernel("readSingleBilinear3D"); // // readData.SetTexture(kernel, "_Tex3D", tex); // readData.SetBuffer(kernel, "BufferSingle3D", buffer); //} //else //{ if(useBilinear) kernel = readData.FindKernel("readSingle2D"); else kernel = readData.FindKernel("readSingleBilinear2D"); readData.SetTexture(kernel, "_Tex2D", tex); readData.SetBuffer(kernel, "BufferSingle2D", buffer); //} if(kernel == -1) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - could not find kernels"); return; } int width = tex.width; int height = tex.height; //used for point sampling readData.SetInt("_IdxX", (int)x); readData.SetInt("_IdxY", (int)y); readData.SetInt("_IdxZ", (int)z); //used for bilinear sampling readData.SetVector("_UV", new Vector4( x / (float)(width-1), y / (float)(height-1), z / (float)(depth-1), 0.0f)); readData.Dispatch(kernel, 1, 1, 1); }
public static void ReadSingleFromRenderTexture(RenderTexture tex, float x, float y, float z, ComputeBuffer buffer, ComputeShader readData, bool useBilinear) { if (tex == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - RenderTexture is null"); return; } if (buffer == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - buffer is null"); return; } if (readData == null) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - Computer shader is null"); return; } if (!tex.IsCreated()) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - tex has not been created (Call Create() on tex)"); return; } int num = 1; int num2; if (useBilinear) { num2 = readData.FindKernel("readSingle2D"); } else { num2 = readData.FindKernel("readSingleBilinear2D"); } readData.SetTexture(num2, "_Tex2D", tex); readData.SetBuffer(num2, "BufferSingle2D", buffer); if (num2 == -1) { Debug.Log("CBUtility::ReadSingleFromRenderTexture - could not find kernels"); return; } int width = tex.width; int height = tex.height; readData.SetInt("_IdxX", (int)x); readData.SetInt("_IdxY", (int)y); readData.SetInt("_IdxZ", (int)z); readData.SetVector("_UV", new Vector4(x / (float)(width - 1), y / (float)(height - 1), z / (float)(num - 1), 0f)); readData.Dispatch(num2, 1, 1, 1); }