Unexpected identifier cbuffer error
I have a hlsli file and would like to port it into Unity. However, it seems something wrong that Unity does not recognize some keywords such as "cbuffer", "textureCube", "texture2D". The following is...
View ArticleUsing Texture2DArray as RenderTarget and passing data to fragment shader
I'd like to render multiple views into an array of 2D textures, then pass this array into a fragment shader for processing. Imagine a stack of differing 2D viewpoints of the 3D scene, where on the 0th...
View ArticleNo acceptable conversion when converting cg shader to glsl
I have a simple shader where at some point I perfrom logical operations component-wise between boolean vectors: float2 x_ = ( (x >= 0) && (x < a) ) ? float2(0., 0.) : float2(0.5, 0.5);...
View ArticleExporting graphically created shaders in Visual Studio to Unity. [.glsl to...
Hello. Can I export Visual Studio “.glsl” shader into Unity? Visual Studio has a great tool for creating Shaders, but it cannot be converted to Unity Shaders, just “.hlsl”, “.h”, “.cso”. .glsl to .shader
View ArticleMoving UV's with a shader (tiling error)
With the following code I tried to animate a texture on a surface by moving its uvs. However it moves, but it doesn't tile correct as the net tile is just grey (stretched from texture's border). Now...
View ArticleCustom shader samples pixels per-texture rather than from the screen
Hi all, Thanks for reading (and sorry if this is a bit wordy), I've had a Google and a think on this but can't seem to work out what's happening. I'm new to shaders and after a few tutorials have...
View ArticleHLSL clip() function don't work on Adreno 320
HLSL clip() function don't work on Adreno 320 (for example Nexus 4) GPU if compile with Unity 5.3.5 or newer. On Adreno 330 (f.e. Nexus 5) works fine compile on any version, but on Adreno 320 works...
View ArticleShaders don't work properly on android
Hello, I am working on a way to create high resolution screenshots of a tilemap on android in order to achieve this i am manually drawing the image using GetPixel/SetPixel, and subsequently i am...
View ArticleHow can I make a shader pass that emits dynamic light?
I have been reading the docs and searching around on google for a few hours, so I doubt there is an answer on this website, but if there is, please answer with a link. So, back to my question, I have a...
View ArticleHow to use SampleGrad in Unity shader
The code in hlsl but I can't use it. Unity says "sampler2D object does not have methods" There's the detail [SampleGrad (DirectX HLSL Texture Object)][1] The article relate to [A Closer Look At...
View ArticleHow can I get correct lighting on a low poly water shader?
I have been working on this low poly water shader and I got each vertex to move up and down like I want to, I also got the shader to be transparent but I am having problems with lighting. If the...
View Articledoubles and compute shaders
I have a compute shader I use to crunch the n-body gravity calculations for my project. when I use all floats in the shader, it runs fine and can process the gravity calculations of 10,000 objects in...
View Article[Shader] Usage #ifdef DIRECTIONAL
How can I use #ifdef DIRECTIONAL in surf + vert shader? What conditions? M.b. some .cgiinc or .include or HLSLPROGRAM only etc here is full shader Shader "mitay/cutout tree" { Properties { _Color...
View ArticleHlsl Pow function platform-dependent error
Hi guys, it looks like the pow function does crazy things if the exponent is too big. For example if it's 10 it causes the shader to simply return 0, regardless the result of the operation. The...
View ArticleWebgl 1.0 error shader loop, workaround?
it seems webgl doenst support some kind of loops in the hlsl shader. My shader only have this variant. I wanna know a workaround this problem if possible and if anyone know in the future if these...
View ArticleWhy does this shader give different result Editor/ Android?
Hi, I've written a simple *curved* unlit shader in HLSL that basically translates each vertex based on the distance to the camera (the magic happens in the vertex shader): Properties { _BendFactor...
View Articlehow to approach instanceID in shader?
SkinnedMeshRenderer didn't batched in Unity. so i will implement GPU Skinning with GPU Instancing. i try to approach instanceID(like SV_InstanceID), but they are wrapped in preprocessor macro. so i...
View ArticleIs it possible to render to a texture via RWTexture2D without using...
I would like to save the output of a fragment shader to a texture, so that I can attempt to reuse the data in later shaders. I originally used Graphics.Blit, but the problem I found is that it submits...
View ArticleHow to reuse HLSL shader code?
Hello! I needed a set of shaders that curve based on the distance from camera. Basically, I took some of the default HLSL shaders Unity provides and changed the code in the vertex shader to adjust the...
View Article(Shader)How to find the cordinate of a given color inside a ramp texture?
I'm currently working on palette swap feature for my game's sprites on Unity . I know that this is normaly achieved by using a gayscale texture and then using a ramp texture to replace the colors or...
View Article