Quantcast
Channel: Questions in topic: "shader programming"
Viewing all articles
Browse latest Browse all 169

Parse error: syntax error, unexpected '}' in line 69 with URP shader.

$
0
0
I am a beginner in shader programming and I use URP. I wanted to create a raymarching cloud shader and keep getting this error - Parse error: syntax error, unexpected '}' in line 69. I don't know what to do and any help is very much appreciated. Here is the shader - ---------- Shader "Custom/ProceduralCloudsMobile" { Properties { _CloudColor("Cloud Color", Color) = (1,1,1,1) _ScatterColor("Scatter Color", Color) = (1,1,1,1) _ScatterAmount("Scatter Amount", Range(0, 1)) = 0.5 _CloudDensity("Cloud Density", Range(0, 1)) = 0.5 _CloudSharpness("Cloud Sharpness", Range(0, 1)) = 0.5 _CloudSpeed("Cloud Speed", Range(0, 1)) = 0.5 _CloudScale("Cloud Scale", Range(0, 10)) = 2 _CloudHeight("Cloud Height", Range(0, 1000)) = 500 _StepSize("Step Size", Range(0, 1)) = 0.01 _MaxSteps("Max Steps", Range(0, 100)) = 50 } SubShader { Tags { "RenderType" = "Opaque" } LOD 100 HLSLINCLUDE #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/PBSLights.hlsl" float3 GetCloudNoise(float3 pos) { return cnoise(pos * _CloudScale * _CloudSharpness + _Time.y * _CloudSpeed); } float SampleCloudDensity(float3 pos) { return saturate(GetCloudNoise(pos).r * _CloudDensity); } float SampleScatterAmount(float3 pos) { return saturate(GetCloudNoise(pos).r * _ScatterAmount); } void surf(SurfaceOutput o, inout SurfaceInput input) { // Calculate 3D position of the current pixel in world space float3 worldPos = mul(unity_ObjectToWorld, float4(input.uv, 0, 1)).xyz; worldPos.y += _CloudHeight; // Cast a ray into the scene and sample the cloud density along the ray float3 rayDir = normalize(worldPos - _WorldSpaceCameraPos); float rayLength = length(worldPos - _WorldSpaceCameraPos); float3 rayPos = _WorldSpaceCameraPos; float cloudDensity = 0; for (int i = 0; i < _MaxSteps; i++) { cloudDensity += SampleCloudDensity(rayPos) * _StepSize; rayPos += rayDir * _StepSize; if (cloudDensity >= 1) break; } // Calculate scatter amount at the final ray position float scatterAmount = SampleScatterAmount(rayPos); // Blend cloud color and scatter color based on density and scatter amount fixed4 cloudColor = lerp(_CloudColor, _ScatterColor, scatterAmount); o.Albedo = cloudColor.rgb * cloudDensity; o.Alpha = cloudDensity; } ENDHLSL } } `

Viewing all articles
Browse latest Browse all 169

Trending Articles