public FishRenderer(RenderBase rb, FishManager manager) { RenderBase = rb; Manager = manager; paramsBuffer = new UConstantBuffer(RenderBase, Utilities.SizeOf <Vector4>() * 2); var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShader = new UVertexShader(RenderBase, "shaders/Vertex_PC_Explode.hlsl", VertexPositionNormal.InputElements); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_PC_FishPointLights.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); vertexBuffer = new Buffer[3]; vertexCount = new int[vertexBuffer.Length]; vertexBuffer[0] = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, VertexPositionNormal.LoadSTL("models/fish.stl", out vertexCount[0])); vertexBuffer[1] = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, VertexPositionNormal.LoadSTL("models/fish4.stl", out vertexCount[1])); vertexBuffer[2] = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, VertexPositionNormal.LoadSTL("models/fish5.stl", out vertexCount[2])); coneVertexBuffer = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, new VertexPositionColor[] { new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), Color.White), new VertexPositionColor(new Vector3(1.0f, 1.0f, 0.0f), Color.White), new VertexPositionColor(new Vector3(1.0f, -1.0f, 0.0f), Color.White) }); }
public DecorRenderer(RenderBase rb) { RenderBase = rb; paramsBuffer = new UConstantBuffer(RenderBase, Utilities.SizeOf <Vector4>() * 2); var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShaderSway = new UVertexShader(RenderBase, "shaders/Vertex_PNI_Wave.hlsl", VertexPositionNormal.InputElementsInstanced); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_PNI_FishPointLightsAbs.hlsl", "main", "ps_4_0", shaderFlags)) plantPixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); vertexShader = new UVertexShader(RenderBase, "shaders/Vertex_PN_Standard.hlsl", VertexPositionNormal.InputElements); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_PC_FishPointLightsAbs.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); plantVertexBuffer = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, VertexPositionNormal.LoadSTL("models/plant.stl", out plantVertCount)); floorVertexBuffer = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, VertexPositionNormal.LoadSTL("models/tankFloor.stl", out floorVertCount)); /*plantData = new Vector4[] * { * new Vector4(-0.8f, .07f, 0, 0.1f), * new Vector4(0.9f, .04f, 0, 0.2f), * new Vector4(-0.95f, .06f, 0, 0.15f), * }; * plantWaveSpeed = new float[] * { * 1.0f, * 1.2f, * 0.6f, * };*/ Random rnd = new Random(); plantData = new Vector4[500]; plantWaveSpeed = new float[plantData.Length]; for (int i = 0; i < plantData.Length; i++) { var sizeMul = 0.333f; if (rnd.Next(0, 25) == 0) { sizeMul = 0.5f; } plantData[i] = new Vector4(rnd.NextFloat(-16.0f / 9.0f * 1.5f, 16.0f / 9.0f * 1.5f), rnd.NextFloat(0.01f, 0.1f) * sizeMul, 0, rnd.NextFloat(0.05f, 0.3f)); plantWaveSpeed[i] = rnd.NextFloat(0.01f, 2.0f); } plantInstanceBuffer = new DynamicVertexBuffer(rb, (Utilities.SizeOf <Matrix>() + Utilities.SizeOf <Vector4>()) * plantData.Length); }
public RaysRenderer(RenderBase rb) { RenderBase = rb; var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShader = new UVertexShader(RenderBase, "shaders/Vertex_FS.hlsl", null); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_GodRays.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); cb = new ConstantBuffers.UConstantBuffer(RenderBase, 4 * 4 * 2); }
public FishGlow(RenderBase rb, FishManager manager) { RenderBase = rb; Manager = manager; var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShader = new UVertexShader(RenderBase, "shaders/Vertex_FS.hlsl", null); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_FishGlow.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); cb = new ConstantBuffers.UConstantBuffer(RenderBase, 4 * 4 + FishManager.MAX_FISH_COUNT * 2 * 4 * 4); }
private void InitDebugShaders() { var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShader = new UVertexShader(this, "shaders/Vertex_P_PassThrough.hlsl", inputElements); /*using (var vertexShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Vertex_P_PassThrough.hlsl", "main", "vs_4_0", shaderFlags)) * { * inputSignature = ShaderSignature.GetInputSignature(vertexShaderByteCode); * vertexShader = new D3D.VertexShader(Device, vertexShaderByteCode); * }*/ using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_P_RedDebug.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new D3D.PixelShader(Device, pixelShaderByteCode); //inputLayout = new D3D.InputLayout(Device, inputSignature, inputElements); //DeviceContext.InputAssembler.InputLayout = inputLayout; }
public FoodRenderer(RenderBase rb, FoodManager manager) { RenderBase = rb; Manager = manager; paramsBuffer = new UConstantBuffer(RenderBase, Utilities.SizeOf <Vector4>() * 2); var shaderFlags = #if DEBUG ShaderFlags.Debug; #else ShaderFlags.None; #endif vertexShader = new UVertexShader(RenderBase, "shaders/Vertex_PN_Standard.hlsl", VertexPositionNormal.InputElements); using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile("shaders/Pixel_PC_FishPointLights.hlsl", "main", "ps_4_0", shaderFlags)) pixelShader = new PixelShader(RenderBase.Device, pixelShaderByteCode); vertexBuffer = Buffer.Create(RenderBase.Device, BindFlags.VertexBuffer, //new VertexPositionColor[] { new VertexPositionColor(new Vector3(-0.5f, 0.5f, 0.0f), Color.White), new VertexPositionColor(new Vector3(0.5f, 0.5f, 0.0f), Color.White), new VertexPositionColor(new Vector3(-0.5f, -0.5f, 0.0f), Color.White), // new VertexPositionColor(new Vector3(0.5f, -0.5f, 0.0f), Color.White), new VertexPositionColor(new Vector3(-0.5f, -0.5f, 0.0f), Color.White), new VertexPositionColor(new Vector3(0.5f, 0.5f, 0.0f), Color.White)}); VertexPositionNormal.LoadSTL("models/food.stl", out vertCount)); }